mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 02:17:52 +02:00
Other updated
This commit is contained in:
parent
45493bc9dd
commit
f2b930ba68
@ -64,4 +64,61 @@ function M:clear()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.on_item_click:subscribe(function(index)
|
||||||
|
self:remove_item(index)
|
||||||
|
output_list:add_log_text("Item removed: " .. index)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
local view_node = self.scroll.view_node
|
||||||
|
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_scroll", 0, function(value)
|
||||||
|
self.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_button("ui_add_element", function()
|
||||||
|
self:add_item()
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_button("ui_remove_element", function()
|
||||||
|
self:remove_item()
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_button("ui_clear_elements", function()
|
||||||
|
self.data_list:clear()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
function M:get_debug_info()
|
||||||
|
local data_list = self.data_list
|
||||||
|
|
||||||
|
local data = data_list:get_data()
|
||||||
|
local info = ""
|
||||||
|
info = info .. "Data length: " .. #data .. "\n"
|
||||||
|
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
||||||
|
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
||||||
|
|
||||||
|
local s = self.scroll
|
||||||
|
info = info .. "\n"
|
||||||
|
info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n"
|
||||||
|
info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n"
|
||||||
|
info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n"
|
||||||
|
info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n"
|
||||||
|
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -48,4 +48,48 @@ function M:on_button_click(index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.on_item_click:subscribe(function(index)
|
||||||
|
output_list:add_log_text("Item clicked: " .. index)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
local view_node = self.scroll.view_node
|
||||||
|
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_scroll", 0, function(value)
|
||||||
|
self.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
function M:get_debug_info()
|
||||||
|
local data_list = self.data_list
|
||||||
|
|
||||||
|
local data = data_list:get_data()
|
||||||
|
local info = ""
|
||||||
|
info = info .. "Data length: " .. #data .. "\n"
|
||||||
|
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
||||||
|
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
||||||
|
|
||||||
|
local s = self.scroll
|
||||||
|
info = info .. "\n"
|
||||||
|
info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n"
|
||||||
|
info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n"
|
||||||
|
info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n"
|
||||||
|
info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n"
|
||||||
|
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -39,4 +39,36 @@ function M:on_button_click(index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
local view_node = self.scroll.view_node
|
||||||
|
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
||||||
|
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
function M:get_debug_info()
|
||||||
|
local data_list = self.data_list
|
||||||
|
|
||||||
|
local data = data_list:get_data()
|
||||||
|
local info = ""
|
||||||
|
info = info .. "Data length: " .. #data .. "\n"
|
||||||
|
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
||||||
|
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
||||||
|
|
||||||
|
local s = self.scroll
|
||||||
|
info = info .. "\n"
|
||||||
|
info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n"
|
||||||
|
info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n"
|
||||||
|
info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n"
|
||||||
|
info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n"
|
||||||
|
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -68,4 +68,48 @@ function M:on_button_click(instance)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.on_item_click:subscribe(function(index)
|
||||||
|
output_list:add_log_text("Item clicked: " .. index)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
local view_node = self.scroll.view_node
|
||||||
|
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_scroll", 0, function(value)
|
||||||
|
self.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
function M:get_debug_info()
|
||||||
|
local data_list = self.data_list
|
||||||
|
|
||||||
|
local data = data_list:get_data()
|
||||||
|
local info = ""
|
||||||
|
info = info .. "Data length: " .. #data .. "\n"
|
||||||
|
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
||||||
|
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
||||||
|
|
||||||
|
local s = self.scroll
|
||||||
|
info = info .. "\n"
|
||||||
|
info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n"
|
||||||
|
info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n"
|
||||||
|
info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n"
|
||||||
|
info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n"
|
||||||
|
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -10,45 +10,6 @@ function M.get_examples()
|
|||||||
root = "data_list_basic/root",
|
root = "data_list_basic/root",
|
||||||
code_url = "example/examples/data_list/basic/data_list_basic.lua",
|
code_url = "example/examples/data_list/basic/data_list_basic.lua",
|
||||||
widget_class = require("example.examples.data_list.basic.data_list_basic"),
|
widget_class = require("example.examples.data_list.basic.data_list_basic"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.data_list_basic
|
|
||||||
instance.on_item_click:subscribe(function(index)
|
|
||||||
output_list:add_log_text("Item clicked: " .. index)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.data_list_basic
|
|
||||||
|
|
||||||
local view_node = instance.scroll.view_node
|
|
||||||
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_scroll", 0, function(value)
|
|
||||||
instance.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
get_debug_info = function(instance)
|
|
||||||
---@cast instance examples.data_list_basic
|
|
||||||
local data_list = instance.data_list
|
|
||||||
|
|
||||||
local data = data_list:get_data()
|
|
||||||
local info = ""
|
|
||||||
info = info .. "Data length: " .. #data .. "\n"
|
|
||||||
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
|
||||||
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
|
||||||
|
|
||||||
local s = instance.scroll
|
|
||||||
info = info .. "\n"
|
|
||||||
info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n"
|
|
||||||
info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n"
|
|
||||||
info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n"
|
|
||||||
info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n"
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -58,35 +19,6 @@ function M.get_examples()
|
|||||||
root = "data_list_horizontal_basic/root",
|
root = "data_list_horizontal_basic/root",
|
||||||
code_url = "example/examples/data_list/basic/data_list_horizontal_basic.lua",
|
code_url = "example/examples/data_list/basic/data_list_horizontal_basic.lua",
|
||||||
widget_class = require("example.examples.data_list.basic.data_list_horizontal_basic"),
|
widget_class = require("example.examples.data_list.basic.data_list_horizontal_basic"),
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.data_list_horizontal_basic
|
|
||||||
|
|
||||||
local view_node = instance.scroll.view_node
|
|
||||||
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
|
||||||
|
|
||||||
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)
|
|
||||||
end,
|
|
||||||
get_debug_info = function(instance)
|
|
||||||
---@cast instance examples.data_list_horizontal_basic
|
|
||||||
local data_list = instance.data_list
|
|
||||||
|
|
||||||
local data = data_list:get_data()
|
|
||||||
local info = ""
|
|
||||||
info = info .. "Data length: " .. #data .. "\n"
|
|
||||||
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
|
||||||
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
|
||||||
|
|
||||||
local s = instance.scroll
|
|
||||||
info = info .. "\n"
|
|
||||||
info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n"
|
|
||||||
info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n"
|
|
||||||
info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n"
|
|
||||||
info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n"
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -96,58 +28,6 @@ function M.get_examples()
|
|||||||
root = "data_list_add_remove_clear/root",
|
root = "data_list_add_remove_clear/root",
|
||||||
code_url = "example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua",
|
code_url = "example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua",
|
||||||
widget_class = require("example.examples.data_list.add_remove_clear.data_list_add_remove_clear"),
|
widget_class = require("example.examples.data_list.add_remove_clear.data_list_add_remove_clear"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.data_list_add_remove_clear
|
|
||||||
instance.on_item_click:subscribe(function(index)
|
|
||||||
instance:remove_item(index)
|
|
||||||
output_list:add_log_text("Item removed: " .. index)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.data_list_add_remove_clear
|
|
||||||
|
|
||||||
local view_node = instance.scroll.view_node
|
|
||||||
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_scroll", 0, function(value)
|
|
||||||
instance.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_button("ui_add_element", function()
|
|
||||||
instance:add_item()
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_button("ui_remove_element", function()
|
|
||||||
instance:remove_item()
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_button("ui_clear_elements", function()
|
|
||||||
instance.data_list:clear()
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
get_debug_info = function(instance)
|
|
||||||
---@cast instance examples.data_list_add_remove_clear
|
|
||||||
local data_list = instance.data_list
|
|
||||||
|
|
||||||
local data = data_list:get_data()
|
|
||||||
local info = ""
|
|
||||||
info = info .. "Data length: " .. #data .. "\n"
|
|
||||||
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
|
||||||
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
|
||||||
|
|
||||||
local s = instance.scroll
|
|
||||||
info = info .. "\n"
|
|
||||||
info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n"
|
|
||||||
info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n"
|
|
||||||
info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n"
|
|
||||||
info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n"
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -157,45 +37,6 @@ function M.get_examples()
|
|||||||
root = "data_list_cache_with_component/root",
|
root = "data_list_cache_with_component/root",
|
||||||
code_url = "example/examples/data_list/cache_with_component/cache_with_component.lua",
|
code_url = "example/examples/data_list/cache_with_component/cache_with_component.lua",
|
||||||
widget_class = require("example.examples.data_list.cache_with_component.cache_with_component"),
|
widget_class = require("example.examples.data_list.cache_with_component.cache_with_component"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.data_list_cache_with_component
|
|
||||||
instance.on_item_click:subscribe(function(index)
|
|
||||||
output_list:add_log_text("Item clicked: " .. index)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.data_list_cache_with_component
|
|
||||||
|
|
||||||
local view_node = instance.scroll.view_node
|
|
||||||
local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_scroll", 0, function(value)
|
|
||||||
instance.scroll:scroll_to_percent(vmath.vector3(0, 1 - value, 0), true)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
get_debug_info = function(instance)
|
|
||||||
---@cast instance examples.data_list_cache_with_component
|
|
||||||
local data_list = instance.data_list
|
|
||||||
|
|
||||||
local data = data_list:get_data()
|
|
||||||
local info = ""
|
|
||||||
info = info .. "Data length: " .. #data .. "\n"
|
|
||||||
info = info .. "First Visual Index: " .. data_list.top_index .. "\n"
|
|
||||||
info = info .. "Last Visual Index: " .. data_list.last_index .. "\n"
|
|
||||||
|
|
||||||
local s = instance.scroll
|
|
||||||
info = info .. "\n"
|
|
||||||
info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n"
|
|
||||||
info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n"
|
|
||||||
info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n"
|
|
||||||
info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n"
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -11,51 +11,6 @@ function M.get_examples()
|
|||||||
root = "gamepad_tester/root",
|
root = "gamepad_tester/root",
|
||||||
code_url = "example/examples/gamepad/gamepad_tester/gamepad_tester.lua",
|
code_url = "example/examples/gamepad/gamepad_tester/gamepad_tester.lua",
|
||||||
widget_class = require("example.examples.gamepad.gamepad_tester.gamepad_tester"),
|
widget_class = require("example.examples.gamepad.gamepad_tester.gamepad_tester"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.gamepad_tester
|
|
||||||
instance.button_left.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Left Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_right.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Right Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_up.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Up Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_down.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Down Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_a.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button A Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_b.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button B Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_x.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button X Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_y.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Y Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_back.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Back Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_start.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Start Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_l1.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button L1 Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_r1.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button R1 Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_stick_left.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Stick Left Clicked")
|
|
||||||
end)
|
|
||||||
instance.button_stick_right.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Button Stick Right Clicked")
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -91,4 +91,51 @@ function M:on_input(action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.button_left.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Left Clicked")
|
||||||
|
end)
|
||||||
|
self.button_right.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Right Clicked")
|
||||||
|
end)
|
||||||
|
self.button_up.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Up Clicked")
|
||||||
|
end)
|
||||||
|
self.button_down.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Down Clicked")
|
||||||
|
end)
|
||||||
|
self.button_a.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button A Clicked")
|
||||||
|
end)
|
||||||
|
self.button_b.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button B Clicked")
|
||||||
|
end)
|
||||||
|
self.button_x.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button X Clicked")
|
||||||
|
end)
|
||||||
|
self.button_y.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Y Clicked")
|
||||||
|
end)
|
||||||
|
self.button_back.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Back Clicked")
|
||||||
|
end)
|
||||||
|
self.button_start.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Start Clicked")
|
||||||
|
end)
|
||||||
|
self.button_l1.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button L1 Clicked")
|
||||||
|
end)
|
||||||
|
self.button_r1.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button R1 Clicked")
|
||||||
|
end)
|
||||||
|
self.button_stick_left.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Stick Left Clicked")
|
||||||
|
end)
|
||||||
|
self.button_stick_right.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Button Stick Right Clicked")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -70,4 +70,79 @@ function M:on_remove()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_padding", 0, function(value)
|
||||||
|
local padding = math.floor((value * 64) * 100) / 100
|
||||||
|
self.layout:set_padding(padding, padding, padding, padding)
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_margin_x", 0, function(value)
|
||||||
|
local margin = math.floor((value * 64) * 100) / 100
|
||||||
|
self.layout:set_margin(margin, nil)
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_slider("ui_margin_y", 0, function(value)
|
||||||
|
local margin = math.floor((value * 64) * 100) / 100
|
||||||
|
self.layout:set_margin(nil, margin)
|
||||||
|
end)
|
||||||
|
|
||||||
|
properties_panel:add_checkbox("ui_justify", false, function(value)
|
||||||
|
self.layout:set_justify(value)
|
||||||
|
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
|
||||||
|
self:set_pivot(pivot_list[pivot_index])
|
||||||
|
end)
|
||||||
|
|
||||||
|
local type_index = 1
|
||||||
|
local type_list = {
|
||||||
|
"horizontal_wrap",
|
||||||
|
"horizontal",
|
||||||
|
"vertical",
|
||||||
|
}
|
||||||
|
|
||||||
|
properties_panel:add_button("ui_type_next", function()
|
||||||
|
type_index = type_index + 1
|
||||||
|
if type_index > #type_list then
|
||||||
|
type_index = 1
|
||||||
|
end
|
||||||
|
self.layout:set_type(type_list[type_index])
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
function M:get_debug_info()
|
||||||
|
local layout = self.layout
|
||||||
|
local p = layout.padding
|
||||||
|
local info = ""
|
||||||
|
info = info .. "Layout: " .. layout.type .. "\n"
|
||||||
|
info = info .. "Padding: " .. math.floor(p.x) .. " " .. math.floor(p.y) .. " " .. math.floor(p.z) .. " " .. math.floor(p.w) .. "\n"
|
||||||
|
info = info .. "Margin: " .. layout.margin.x .. " " .. layout.margin.y .. "\n"
|
||||||
|
info = info .. "Justify: " .. tostring(layout.is_justify) .. "\n"
|
||||||
|
info = info .. "Pivot: " .. tostring(gui.get_pivot(layout.node)) .. "\n"
|
||||||
|
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -11,78 +11,6 @@ function M.get_examples()
|
|||||||
root = "basic_layout/root",
|
root = "basic_layout/root",
|
||||||
code_url = "example/examples/layout/basic/basic_layout.lua",
|
code_url = "example/examples/layout/basic/basic_layout.lua",
|
||||||
widget_class = require("example.examples.layout.basic.basic_layout"),
|
widget_class = require("example.examples.layout.basic.basic_layout"),
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.basic_layout
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_padding", 0, function(value)
|
|
||||||
local padding = math.floor((value * 64) * 100) / 100
|
|
||||||
instance.layout:set_padding(padding, padding, padding, padding)
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_margin_x", 0, function(value)
|
|
||||||
local margin = math.floor((value * 64) * 100) / 100
|
|
||||||
instance.layout:set_margin(margin, nil)
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_slider("ui_margin_y", 0, function(value)
|
|
||||||
local margin = math.floor((value * 64) * 100) / 100
|
|
||||||
instance.layout:set_margin(nil, margin)
|
|
||||||
end)
|
|
||||||
|
|
||||||
properties_panel:add_checkbox("ui_justify", false, function(value)
|
|
||||||
instance.layout:set_justify(value)
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
local type_index = 1
|
|
||||||
local type_list = {
|
|
||||||
"horizontal_wrap",
|
|
||||||
"horizontal",
|
|
||||||
"vertical",
|
|
||||||
}
|
|
||||||
|
|
||||||
properties_panel:add_button("ui_type_next", function()
|
|
||||||
type_index = type_index + 1
|
|
||||||
if type_index > #type_list then
|
|
||||||
type_index = 1
|
|
||||||
end
|
|
||||||
instance.layout:set_type(type_list[type_index])
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
get_debug_info = function(instance)
|
|
||||||
---@cast instance examples.basic_layout
|
|
||||||
local layout = instance.layout
|
|
||||||
local p = layout.padding
|
|
||||||
local info = ""
|
|
||||||
info = info .. "Layout: " .. layout.type .. "\n"
|
|
||||||
info = info .. "Padding: " .. math.floor(p.x) .. " " .. math.floor(p.y) .. " " .. math.floor(p.z) .. " " .. math.floor(p.w) .. "\n"
|
|
||||||
info = info .. "Margin: " .. layout.margin.x .. " " .. layout.margin.y .. "\n"
|
|
||||||
info = info .. "Justify: " .. tostring(layout.is_justify) .. "\n"
|
|
||||||
info = info .. "Pivot: " .. tostring(gui.get_pivot(layout.node)) .. "\n"
|
|
||||||
|
|
||||||
return info
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -70,4 +70,25 @@ function M:setup_rich_text()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param properties_panel properties_panel
|
||||||
|
function M:properties_control(properties_panel)
|
||||||
|
local vertical_time = panthera.get_time(self.animation_vertical)
|
||||||
|
|
||||||
|
local vertical_slider = properties_panel:add_slider("ui_animation_vertical", vertical_time, function(value)
|
||||||
|
panthera.set_time(self.animation_vertical, "vertical", value)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local horizontal_time = panthera.get_time(self.animation_horizontal)
|
||||||
|
|
||||||
|
local horizontal_slider = properties_panel:add_slider("ui_animation_horizontal", horizontal_time, function(value)
|
||||||
|
panthera.set_time(self.animation_horizontal, "horizontal", value)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.on_update:subscribe(function()
|
||||||
|
vertical_slider:set_value(panthera.get_time(self.animation_vertical))
|
||||||
|
horizontal_slider:set_value(panthera.get_time(self.animation_horizontal))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -19,25 +19,6 @@ function M.get_examples()
|
|||||||
root = "animation_blend/root",
|
root = "animation_blend/root",
|
||||||
code_url = "example/examples/panthera/animation_blend/animation_blend.lua",
|
code_url = "example/examples/panthera/animation_blend/animation_blend.lua",
|
||||||
widget_class = require("example.examples.panthera.animation_blend.animation_blend"),
|
widget_class = require("example.examples.panthera.animation_blend.animation_blend"),
|
||||||
properties_control = function(instance, properties_panel)
|
|
||||||
---@cast instance examples.animation_blend
|
|
||||||
local vertical_time = panthera.get_time(instance.animation_vertical)
|
|
||||||
|
|
||||||
local vertical_slider = properties_panel:add_slider("ui_animation_vertical", vertical_time, function(value)
|
|
||||||
panthera.set_time(instance.animation_vertical, "vertical", value)
|
|
||||||
end)
|
|
||||||
|
|
||||||
local horizontal_time = panthera.get_time(instance.animation_horizontal)
|
|
||||||
|
|
||||||
local horizontal_slider = properties_panel:add_slider("ui_animation_horizontal", horizontal_time, function(value)
|
|
||||||
panthera.set_time(instance.animation_horizontal, "horizontal", value)
|
|
||||||
end)
|
|
||||||
|
|
||||||
instance.on_update:subscribe(function()
|
|
||||||
vertical_slider:set_value(panthera.get_time(instance.animation_vertical))
|
|
||||||
horizontal_slider:set_value(panthera.get_time(instance.animation_horizontal))
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -11,12 +11,6 @@ function M.get_examples()
|
|||||||
root = "window_language/root",
|
root = "window_language/root",
|
||||||
code_url = "example/examples/windows/window_language/window_language.lua",
|
code_url = "example/examples/windows/window_language/window_language.lua",
|
||||||
widget_class = require("example.examples.windows.window_language.window_language"),
|
widget_class = require("example.examples.windows.window_language.window_language"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.window_language
|
|
||||||
instance.on_language_change:subscribe(function(language)
|
|
||||||
output_list:add_log_text("Language changed to " .. language)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name_id = "ui_example_window_confirmation",
|
name_id = "ui_example_window_confirmation",
|
||||||
@ -25,20 +19,6 @@ function M.get_examples()
|
|||||||
information_text_id = "ui_example_window_language_description",
|
information_text_id = "ui_example_window_language_description",
|
||||||
code_url = "example/examples/windows/window_confirmation/window_confirmation.lua",
|
code_url = "example/examples/windows/window_confirmation/window_confirmation.lua",
|
||||||
widget_class = require("example.examples.windows.window_confirmation.window_confirmation"),
|
widget_class = require("example.examples.windows.window_confirmation.window_confirmation"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.window_confirmation
|
|
||||||
instance.text_header:translate("ui_confirmation")
|
|
||||||
instance.text_button_accept:translate("ui_confirm")
|
|
||||||
instance.text_button_decline:translate("ui_cancel")
|
|
||||||
instance.text_description:translate("ui_confirmation_description")
|
|
||||||
|
|
||||||
instance.button_accept.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Confirmation Accepted")
|
|
||||||
end)
|
|
||||||
instance.button_decline.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Confirmation Declined")
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name_id = "ui_example_window_information",
|
name_id = "ui_example_window_information",
|
||||||
@ -47,16 +27,6 @@ function M.get_examples()
|
|||||||
information_text_id = "ui_example_window_information_description",
|
information_text_id = "ui_example_window_information_description",
|
||||||
code_url = "example/examples/windows/window_info/window_info.lua",
|
code_url = "example/examples/windows/window_info/window_info.lua",
|
||||||
widget_class = require("example.examples.windows.window_info.window_info"),
|
widget_class = require("example.examples.windows.window_info.window_info"),
|
||||||
on_create = function(instance, output_list)
|
|
||||||
---@cast instance examples.window_info
|
|
||||||
instance.text_header:translate("ui_information")
|
|
||||||
instance.text_button_accept:translate("ui_confirm")
|
|
||||||
instance.text_description:translate("ui_example_window_information_text")
|
|
||||||
|
|
||||||
instance.button_accept.on_click:subscribe(function()
|
|
||||||
output_list:add_log_text("Information Accepted")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -34,4 +34,20 @@ function M:on_button_close()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.text_header:translate("ui_confirmation")
|
||||||
|
self.text_button_accept:translate("ui_confirm")
|
||||||
|
self.text_button_decline:translate("ui_cancel")
|
||||||
|
self.text_description:translate("ui_confirmation_description")
|
||||||
|
|
||||||
|
self.button_accept.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Confirmation Accepted")
|
||||||
|
end)
|
||||||
|
self.button_decline.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Confirmation Declined")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -30,4 +30,16 @@ function M:on_button_close()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.text_header:translate("ui_information")
|
||||||
|
self.text_button_accept:translate("ui_confirm")
|
||||||
|
self.text_description:translate("ui_example_window_information_text")
|
||||||
|
|
||||||
|
self.button_accept.on_click:subscribe(function()
|
||||||
|
output_list:add_log_text("Information Accepted")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -110,4 +110,12 @@ function M:on_language_button(lang_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param output_list output_list
|
||||||
|
function M:on_example_created(output_list)
|
||||||
|
self.on_language_change:subscribe(function(language)
|
||||||
|
output_list:add_log_text("Language changed to " .. language)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Loading…
x
Reference in New Issue
Block a user