Update example app

This commit is contained in:
Insality
2024-10-19 10:57:55 +03:00
parent c787ed860e
commit ad339508cf
25 changed files with 903 additions and 1388 deletions

View File

@@ -85,7 +85,7 @@ nodes {
z: 0.322
}
type: TYPE_TEXT
text: "Confirm"
text: "Hold Me"
font: "text_bold"
id: "text"
outline {

View File

@@ -1,77 +0,0 @@
fonts {
name: "text_bold"
font: "/example/assets/fonts/text_bold.font"
}
textures {
name: "druid"
texture: "/example/assets/druid.atlas"
}
nodes {
size {
x: 200.0
y: 100.0
}
type: TYPE_BOX
id: "root"
inherit_alpha: true
size_mode: SIZE_MODE_AUTO
visible: false
}
nodes {
size {
x: 40.0
y: 40.0
}
color {
x: 0.463
y: 0.475
z: 0.49
}
type: TYPE_BOX
texture: "druid/rect_round2_width1"
id: "button"
parent: "root"
inherit_alpha: true
slice9 {
x: 4.0
y: 4.0
z: 4.0
w: 4.0
}
}
nodes {
color {
x: 0.722
y: 0.741
z: 0.761
}
type: TYPE_BOX
texture: "druid/icon_check"
id: "icon"
parent: "button"
inherit_alpha: true
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
y: -20.0
}
size {
x: 40.0
y: 4.0
}
color {
x: 0.894
y: 0.506
z: 0.333
}
type: TYPE_BOX
texture: "druid/pixel"
id: "selected"
pivot: PIVOT_S
adjust_mode: ADJUST_MODE_STRETCH
parent: "button"
inherit_alpha: true
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT

View File

@@ -1,41 +0,0 @@
local component = require("druid.component")
---@class basic_checkbox: druid.base_component
---@field druid druid_instance
---@field button druid.button
local M = component.create("basic_checkbox")
---@param template string
---@param nodes table<hash, node>
function M:init(template, nodes)
self.druid = self:get_druid(template, nodes)
self.button = self.druid:new_button("button", self.on_checkbox_click) -- Button to handle checkbox
self.icon = self:get_node("icon") -- Checkbox icon to hide/show
self.selected = self:get_node("selected") -- Selected effect to show when checkbox is changed
gui.set_alpha(self.selected, 0)
self:set_state(false)
end
function M:on_checkbox_click()
self:set_state(not self.is_enabled)
end
function M:set_state(is_enabled)
if self.is_enabled == is_enabled then
return
end
self.is_enabled = is_enabled
gui.set_enabled(self.icon, self.is_enabled)
gui.set_alpha(self.selected, 1)
gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16)
end
return M

View File

@@ -144,6 +144,27 @@ function M.get_examples()
end
instance.text:set_text_adjust(adjust_types[adjust_index], 0.8)
end)
local pivot_index = 1
local pivot_list = {
gui.PIVOT_CENTER,
gui.PIVOT_W,
gui.PIVOT_SW,
gui.PIVOT_S,
gui.PIVOT_SE,
gui.PIVOT_E,
gui.PIVOT_NE,
gui.PIVOT_N,
gui.PIVOT_NW,
}
properties_panel:add_button("ui_pivot_next", function()
pivot_index = pivot_index + 1
if pivot_index > #pivot_list then
pivot_index = 1
end
instance:set_pivot(pivot_list[pivot_index])
end)
end,
get_debug_info = function(instance)
---@cast instance multiline_text
@@ -323,6 +344,7 @@ function M.get_examples()
end,
properties_control = function(instance, properties_panel)
---@cast instance scroll
local scroll = instance.scroll
local is_stretch = instance.scroll.style.EXTRA_STRETCH_SIZE > 0
properties_panel:add_checkbox("ui_elastic_scroll", is_stretch, function(value)
instance.scroll:set_extra_stretch_size(value and 100 or 0)
@@ -333,6 +355,35 @@ function M.get_examples()
properties_panel:add_checkbox("ui_clipping", is_stencil, function(value)
gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE)
end)
local slider_frict = properties_panel:add_slider("ui_slider_friction", 0, function(value)
scroll.style.FRICT = 1 - ((1 - value) * 0.1)
end)
slider_frict:set_text_function(function(value)
return string.format("%.2f", 1 - ((1 - value) * 0.1))
end)
slider_frict:set_value(1 - (1 - scroll.style.FRICT) / 0.1)
local slider_speed = properties_panel:add_slider("ui_slider_speed", 0, function(value)
scroll.style.INERT_SPEED = value * 50
end)
slider_speed:set_value(scroll.style.INERT_SPEED / 50)
slider_speed:set_text_function(function(value)
return string.format("%.1f", value * 50)
end)
local slider_wheel_speed = properties_panel:add_slider("ui_slider_wheel_speed", 0, function(value)
scroll.style.WHEEL_SCROLL_SPEED = value * 30
end)
slider_wheel_speed:set_value(scroll.style.WHEEL_SCROLL_SPEED / 30)
slider_wheel_speed:set_text_function(function(value)
return string.format("%.1f", value * 30)
end)
local wheel_by_inertion = properties_panel:add_checkbox("ui_wheel_by_inertion", scroll.style.WHEEL_SCROLL_BY_INERTION, function(value)
scroll.style.WHEEL_SCROLL_BY_INERTION = value
end)
wheel_by_inertion:set_value(scroll.style.WHEEL_SCROLL_BY_INERTION)
end,
get_debug_info = function(instance)
---@cast instance scroll
@@ -377,10 +428,12 @@ function M.get_examples()
properties_control = function(instance, properties_panel)
---@cast instance grid
local grid = instance.grid
local slider = properties_panel:add_slider("ui_grid_in_row", 0.3, function(value)
local in_row_amount = math.ceil(value * 10)
in_row_amount = math.max(1, in_row_amount)
instance.grid:set_in_row(in_row_amount)
grid:set_in_row(in_row_amount)
end)
slider:set_text_function(function(value)
return tostring(math.ceil(value * 10))
@@ -400,7 +453,58 @@ function M.get_examples()
properties_panel:add_button("ui_clear_elements", function()
instance:clear()
end)
properties_panel:add_checkbox("ui_dynamic_pos", grid.style.IS_DYNAMIC_NODE_POSES, function()
grid.style.IS_DYNAMIC_NODE_POSES = not grid.style.IS_DYNAMIC_NODE_POSES
grid:refresh()
end)
properties_panel:add_checkbox("ui_align_last_row", grid.style.IS_ALIGN_LAST_ROW, function()
grid.style.IS_ALIGN_LAST_ROW = not grid.style.IS_ALIGN_LAST_ROW
grid:refresh()
end)
local pivot_index = 1
local pivot_list = {
gui.PIVOT_CENTER,
gui.PIVOT_W,
gui.PIVOT_SW,
gui.PIVOT_S,
gui.PIVOT_SE,
gui.PIVOT_E,
gui.PIVOT_NE,
gui.PIVOT_N,
gui.PIVOT_NW,
}
properties_panel:add_button("ui_pivot_next", function()
pivot_index = pivot_index + 1
if pivot_index > #pivot_list then
pivot_index = 1
end
grid:set_pivot(pivot_list[pivot_index])
end)
local slider_size = properties_panel:add_slider("ui_item_size", 0.5, function(value)
local size = 50 + value * 100
grid:set_item_size(size, size)
end)
slider_size:set_text_function(function(value)
return tostring(50 + math.ceil(value * 100))
end)
slider_size:set_value(0.5)
end,
get_debug_info = function(instance)
---@cast instance grid
local info = ""
local grid = instance.grid
info = info .. "Grid Items: " .. #grid.nodes .. "\n"
info = info .. "Grid Item Size: " .. grid.node_size.x .. " x " .. grid.node_size.y .. "\n"
info = info .. "Pivot: " .. tostring(grid.pivot)
return info
end
},
{
name_id = "ui_example_basic_scroll_bind_grid",
@@ -702,19 +806,47 @@ function M.get_examples()
end,
},
{
name_id = "ui_example_basic_checkbox",
information_text_id = "ui_example_basic_checkbox_description",
template = "basic_checkbox",
root = "basic_checkbox/root",
code_url = "example/examples/basic/checkbox/basic_checkbox.lua",
component_class = require("example.examples.basic.checkbox.basic_checkbox"),
name_id = "ui_example_checkbox",
information_text_id = "ui_example_checkbox_description",
template = "checkbox",
root = "checkbox/root",
code_url = "example/examples/basic/checkbox/checkbox.lua",
component_class = require("example.examples.basic.checkbox.checkbox"),
on_create = function(instance, output_log)
---@cast instance basic_checkbox
---@cast instance checkbox
instance.button.on_click:subscribe(function()
output_log:add_log_text("Checkbox Clicked: " .. tostring(instance.is_enabled))
end)
end,
},
{
name_id = "ui_example_checkbox_group",
information_text_id = "ui_example_checkbox_group_description",
template = "checkbox_group",
root = "checkbox_group/root",
code_url = "example/examples/basic/checkbox_group/checkbox_group.lua",
component_class = require("example.examples.basic.checkbox_group.checkbox_group"),
on_create = function(instance, output_log)
---@cast instance checkbox_group
instance.on_state_changed:subscribe(function(state1, state2, state3)
output_log:add_log_text("State: " .. tostring(state1) .. " " .. tostring(state2) .. " " .. tostring(state3))
end)
end,
},
{
name_id = "ui_example_radio_group",
information_text_id = "ui_example_radio_group_description",
template = "radio_group",
root = "radio_group/root",
code_url = "example/examples/basic/radio_group/radio_group.lua",
component_class = require("example.examples.basic.radio_group.radio_group"),
on_create = function(instance, output_log)
---@cast instance radio_group
instance.on_state_changed:subscribe(function(selected)
output_log:add_log_text("Selected: " .. selected)
end)
end,
},
}
end

View File

@@ -21,9 +21,6 @@ nodes {
visible: false
}
nodes {
position {
x: -200.0
}
size {
x: 400.0
y: 100.0
@@ -36,7 +33,6 @@ nodes {
text: "Hello I\'m a Rich Text!"
font: "text_regular"
id: "text"
pivot: PIVOT_W
parent: "root"
inherit_alpha: true
outline_alpha: 0.0

View File

@@ -1,4 +1,3 @@
script: ""
fonts {
name: "text_bold"
font: "/example/assets/fonts/text_bold.font"
@@ -7,111 +6,30 @@ textures {
name: "druid"
texture: "/example/assets/druid.atlas"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: false
material: ""
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 400.0
y: 1000.0
z: 0.0
w: 1.0
}
color {
x: 0.173
y: 0.184
z: 0.204
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "druid/ui_circle_32"
id: "scroll_view"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 16.0
@@ -120,57 +38,25 @@ nodes {
w: 16.0
}
clipping_mode: CLIPPING_MODE_STENCIL
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 0.0
y: 500.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 400.0
y: 1700.0
z: 0.0
w: 1.0
y: 2700.0
}
color {
x: 0.173
y: 0.184
z: 0.204
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "druid/empty"
id: "scroll_content"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "scroll_view"
layer: ""
inherit_alpha: true
slice9 {
x: 16.0
@@ -178,219 +64,50 @@ nodes {
z: 16.0
w: 16.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: false
material: ""
}
nodes {
position {
x: 0.0
y: -946.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_tutorial"
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
template: "/example/templates/button_text_green.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 280.0
y: 90.0
z: 0.0
w: 1.0
}
color {
x: 0.557
y: 0.835
z: 0.62
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "druid/ui_circle_32"
id: "button_tutorial/root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_tutorial"
layer: "druid"
inherit_alpha: true
slice9 {
x: 16.0
y: 16.0
z: 16.0
w: 16.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 245.0
y: 50.0
z: 0.0
w: 1.0
}
color {
x: 0.31
y: 0.318
z: 0.322
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "I do nothing!"
font: "text_bold"
id: "button_tutorial/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_tutorial/root"
layer: "text_bold"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: -185.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 500.0
y: 900.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "To setup scroll in your scene\n"
"\n"
"- Place \"View\" box node\n"
@@ -400,477 +117,280 @@ nodes {
"- Init scroll with `druid:new_scroll(\"view\", \"content\")"
font: "text_bold"
id: "ui_scroll_text_1"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: -185.0
y: -482.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 500.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Now your content node can be scrollable in View node borders. In this example the content node contains this tutorial text"
font: "text_bold"
id: "ui_scroll_text_2"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: -185.0
y: -713.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 500.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "All other components are placed as usual.\n"
"\n"
"For example, button:"
font: "text_bold"
id: "ui_scroll_text_3"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: -185.0
y: -1042.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 500.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "You probably wish to add \"stencil\" to your view node to clip all content what outside scroll"
font: "text_bold"
id: "ui_scroll_text_4"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: -185.0
y: -1257.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 500.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Druid automatically checks the stencil nodes to add a \"click zone\" for input elements like buttons to prevent the input if they are outside of stencil nodes"
font: "text_bold"
id: "ui_scroll_text_5"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 0.0
y: -1605.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_stencil"
parent: "scroll_content"
layer: ""
inherit_alpha: true
alpha: 1.0
template: "/example/templates/button_text_green.gui"
template_node_child: false
custom_type: 0
enabled: true
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 280.0
y: 90.0
z: 0.0
w: 1.0
}
color {
x: 0.557
y: 0.835
z: 0.62
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "druid/ui_circle_32"
id: "button_stencil/root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_stencil"
layer: "druid"
inherit_alpha: true
slice9 {
x: 16.0
y: 16.0
z: 16.0
w: 16.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
x: 0.8
y: 0.8
}
size {
x: 245.0
x: 300.0
y: 50.0
z: 0.0
w: 1.0
}
color {
x: 0.31
y: 0.318
z: 0.322
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Try click me outside"
font: "text_bold"
text: "Click outside stencil node"
id: "button_stencil/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
line_break: true
parent: "button_stencil/root"
overridden_fields: 3
overridden_fields: 4
overridden_fields: 8
overridden_fields: 18
template_node_child: true
}
nodes {
position {
x: -185.0
y: -1751.0
}
scale {
x: 0.75
y: 0.75
}
size {
x: 500.0
y: 400.0
}
color {
x: 0.722
y: 0.741
z: 0.761
}
type: TYPE_TEXT
text: "--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
"\n"
"--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
"--------\n"
"\n"
"--------\n"
""
font: "text_bold"
id: "ui_scroll_text_fill"
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "button_stencil/root"
layer: "text_bold"
parent: "scroll_content"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
overridden_fields: 8
overridden_fields: 18
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@@ -68,7 +68,7 @@ nodes {
}
nodes {
position {
y: 160.0
y: 170.0
}
size {
x: 150.0

View File

@@ -1,3 +1,4 @@
local helper = require("druid.helper")
local component = require("druid.component")
local container = require("example.components.container.container")
@@ -17,10 +18,25 @@ function M:init(template, nodes)
-- This code is for adjustable text area with mouse
self.container = self.druid:new(container, "text_area", nil, function(_, size)
self.text:set_size(size)
self:refresh_text_position()
end) --[[@as druid.container]]
self.container:create_draggable_corners()
end
function M:set_pivot(pivot)
self.text:set_pivot(pivot)
self:refresh_text_position()
end
function M:refresh_text_position()
-- Need to update text position with different pivot
local pivot = gui.get_pivot(self.text.node)
local pivot_offset = helper.get_pivot_offset(pivot)
gui.set_position(self.text.node, vmath.vector3(pivot_offset.x * self.text.start_size.x, pivot_offset.y * self.text.start_size.y, 0))
end
return M

View File

@@ -117,15 +117,15 @@ function M.get_examples()
instance.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
end)
properties_panel:add_button("ui_add_item", function()
properties_panel:add_button("ui_add_element", function()
instance:add_item()
end)
properties_panel:add_button("ui_remove_item", function()
properties_panel:add_button("ui_remove_element", function()
instance:remove_item()
end)
properties_panel:add_button("ui_clear_items", function()
properties_panel:add_button("ui_clear_elements", function()
instance.data_list:clear()
end)
end,

View File

@@ -4,6 +4,7 @@ local data_list_examples = require("example.examples.data_list.examples_list")
local layout_examples = require("example.examples.layout.examples_list")
local gamepad_examples = require("example.examples.gamepad.examples_list")
local window_examples = require("example.examples.windows.examples_list")
local widgets_examples = require("example.examples.widgets.examples_list")
local panthera_examples = require("example.examples.panthera.examples_list")
local M = {}
@@ -42,6 +43,7 @@ function M.get_examples()
add_examples(examples, "ui_examples_gamepad", gamepad_examples.get_examples())
add_examples(examples, "ui_examples_window", window_examples.get_examples())
add_examples(examples, "ui_examples_panthera", panthera_examples.get_examples())
add_examples(examples, "ui_examples_widgets", widgets_examples.get_examples())
return examples
end

View File

@@ -6,6 +6,7 @@ function M.get_examples()
return {
{
name_id = "ui_example_window_language",
information_text_id = "ui_example_window_language_description",
template = "window_language",
root = "window_language/root",
code_url = "example/examples/windows/window_language/window_language.lua",
@@ -38,9 +39,6 @@ function M.get_examples()
output_list:add_log_text("Confirmation Declined")
end)
end,
get_debug_info = function(instance)
return "Any info we want"
end
},
{
name_id = "ui_example_window_information",