mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +02:00
Update grid usage at grid example page
This commit is contained in:
parent
0dc9f32b7a
commit
cf87c89cff
@ -102,5 +102,6 @@ Druid 0.5.0:
|
||||
- **Fix #76:** Add params for lang text localization component
|
||||
- **Fix #79:** Fix druid:remove inside on_input callback
|
||||
- **Fix #80:** Fix hover set_enable typo function call
|
||||
- _druid:create_ deprecated. Use _druid:new_ instead (for custom components)
|
||||
- Add `component.tempalte.lua` as template for Druid custom component
|
||||
|
||||
|
@ -46,7 +46,7 @@ function M.init(self, parent, element, in_row)
|
||||
self.node_size = gui.get_size(node)
|
||||
self.node_pivot = const.PIVOTS[gui.get_pivot(node)]
|
||||
|
||||
self.border = vmath.vector4(0)
|
||||
self.border = vmath.vector4(0) -- Current grid content size
|
||||
self.border_offset = vmath.vector3(0)
|
||||
|
||||
self.on_add_item = Event()
|
||||
|
@ -431,6 +431,15 @@ function Druid.new_grid(self, ...)
|
||||
end
|
||||
|
||||
|
||||
--- Create staic grid basic component
|
||||
-- @function druid:new_staic_grid
|
||||
-- @tparam args ... grid init args
|
||||
-- @treturn Component grid component
|
||||
function Druid.new_static_grid(self, ...)
|
||||
return Druid.create(self, static_grid, ...)
|
||||
end
|
||||
|
||||
|
||||
--- Create scroll basic component
|
||||
-- @function druid:new_scroll
|
||||
-- @tparam args ... scroll init args
|
||||
|
@ -5,11 +5,19 @@ local function add_node(self)
|
||||
local prefab = gui.get_node("grid_nodes_prefab")
|
||||
local cloned = gui.clone_tree(prefab)
|
||||
gui.set_enabled(cloned["grid_nodes_prefab"], true)
|
||||
local index = #self.grid_nodes + 1
|
||||
local index = #self.grid_nodes.nodes + 1
|
||||
gui.set_text(cloned["grid_nodes_text"], index)
|
||||
|
||||
local button = self.druid:new_button(cloned["grid_nodes_prefab"], function()
|
||||
print(index)
|
||||
local button = self.druid:new_button(cloned["grid_nodes_prefab"], function(_, params, button)
|
||||
gui.delete_node(button.node)
|
||||
self.druid:remove(button)
|
||||
self.grid_nodes:remove(index)
|
||||
for i = 1, #self.grid_node_buttons do
|
||||
if self.grid_node_buttons[i] == button then
|
||||
table.remove(self.grid_node_buttons, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
table.insert(self.grid_node_buttons, button)
|
||||
|
||||
@ -19,8 +27,8 @@ end
|
||||
|
||||
local function clear_nodes(self)
|
||||
local nodes = self.grid_nodes.nodes
|
||||
for i = 1, #nodes do
|
||||
gui.delete_node(nodes[i])
|
||||
for i, node in pairs(nodes) do
|
||||
gui.delete_node(node)
|
||||
end
|
||||
|
||||
for i = 1, #self.grid_node_buttons do
|
||||
@ -38,7 +46,10 @@ end
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
self.grid_nodes = self.druid:new_grid("grid_nodes", "grid_nodes_prefab", 5)
|
||||
self.grid_nodes = self.druid:new_static_grid("grid_nodes", "grid_nodes_prefab", 5)
|
||||
self.grid_nodes:set_position_function(function(node, pos)
|
||||
gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2)
|
||||
end)
|
||||
self.grid_node_buttons = {}
|
||||
gui.set_enabled(gui.get_node("grid_nodes_prefab"), false)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user