Better grid example hints

This commit is contained in:
Insality
2020-09-28 02:33:47 +03:00
parent 1c292f44b7
commit 0e96c582c9
3 changed files with 91 additions and 184 deletions

View File

@@ -66,19 +66,18 @@ local function init_static_grid(self)
self.druid:new_button("button_add/button", function()
add_node(self)
end)
self.druid:new_button("button_clear/button", clear_nodes)
local remove_button = self.druid:new_button("button_remove/button", remove_node)
gui.set_enabled(remove_button.node, false)
self.druid:new_button("button_clear/button", function()
clear_nodes(self)
end)
end
local function remove_dynamic_node(self, button)
local function remove_dynamic_node(self, button, is_shift_left)
gui.delete_node(button.node)
self.druid:remove(button)
local index = self.grid_dynamic_grid:get_index_by_node(button.node)
self.grid_dynamic_grid:remove(index)
self.grid_dynamic_grid:remove(index, is_shift_left)
for i = 1, #self.dynamic_node_buttons do
if self.dynamic_node_buttons[i] == button then
table.remove(self.dynamic_node_buttons, i)
@@ -97,6 +96,9 @@ local function add_node_dynamic(self, index, is_shift_left)
local button = self.druid:new_button(node, function(_, params, button)
remove_dynamic_node(self, button)
end)
button.on_long_click:subscribe(function()
remove_dynamic_node(self, button, true)
end)
button:set_click_zone(self.grid_dynamic_scroll.view_node)
table.insert(self.dynamic_node_buttons, button)
end