Add more annotations, update grid_page example

This commit is contained in:
Insality
2020-11-29 22:17:51 +03:00
parent 14a4e4365e
commit 897d401142
6 changed files with 63 additions and 22 deletions

View File

@@ -10614,9 +10614,9 @@ nodes {
w: 1.0
}
color {
x: 0.6
y: 0.3019608
z: 0.4
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX

View File

@@ -91,6 +91,7 @@ end
local function add_node_dynamic(self, index, is_shift_left)
local node = gui.clone(self.prefab_dynamic)
gui.set_color(node, vmath.vector4(math.random() * 0.2 + 0.8))
gui.set_enabled(node, true)
gui.set_size(node, vmath.vector3(250, math.random(60, 150), 0))
self.grid_dynamic_grid:add(node, index, is_shift_left)
@@ -99,24 +100,51 @@ local function add_node_dynamic(self, index, is_shift_left)
remove_dynamic_node(self, button)
end)
button.on_long_click:subscribe(function()
remove_dynamic_node(self, button, const.SHIFT.lEFT)
remove_dynamic_node(self, button, const.SHIFT.LEFT)
end)
button:set_click_zone(self.grid_dynamic_scroll.view_node)
table.insert(self.dynamic_node_buttons, button)
end
local function remove_dynamic_hor_node(self, button, shift_policy)
gui.delete_node(button.node)
self.druid:remove(button)
local index = self.grid_dynamic_hor_grid:get_index_by_node(button.node)
self.grid_dynamic_hor_grid:remove(index, shift_policy)
for i = 1, #self.dynamic_node_hor_buttons do
if self.dynamic_node_hor_buttons[i] == button then
table.remove(self.dynamic_node_hor_buttons, i)
break
end
end
end
local function add_node_dynamic_hor(self, index)
local node = gui.clone(self.prefab_hor_dynamic)
gui.set_color(node, vmath.vector4(math.random() * 0.2 + 0.8))
gui.set_enabled(node, true)
gui.set_size(node, vmath.vector3(80 + math.random(0, 80), 80, 0))
local button = self.druid:new_button(node, function(_, params, button)
remove_dynamic_hor_node(self, button)
end)
button.on_long_click:subscribe(function()
remove_dynamic_hor_node(self, button, const.SHIFT.LEFT)
end)
button:set_click_zone(self.grid_dynamic_hor_scroll.view_node)
self.grid_dynamic_hor_grid:add(node, index)
table.insert(self.dynamic_node_hor_buttons, button)
end
local function init_dynamic_grid(self)
-- Vertical horizontal grid
self.dynamic_node_buttons = {}
self.dynamic_node_hor_buttons = {}
self.prefab_dynamic = gui.get_node("grid_dynamic_prefab")
gui.set_enabled(self.prefab_dynamic, false)
@@ -125,7 +153,7 @@ local function init_dynamic_grid(self)
add_node_dynamic(self, i)
end
self.druid:new_button("button_add_start_dynamic/button", function()
local start_index = (self.grid_dynamic_grid.first_index or 2) - 1
local start_index = self.grid_dynamic_grid.first_index or 1
add_node_dynamic(self, start_index)
end)
self.druid:new_button("button_add_end_dynamic/button", function()
@@ -141,7 +169,8 @@ local function init_dynamic_grid(self)
end
self.druid:new_button("button_add_start_dynamic_hor/button", function()
add_node_dynamic_hor(self, 1)
local start_index = self.grid_dynamic_hor_grid.first_index or 1
add_node_dynamic_hor(self, start_index)
end)
self.druid:new_button("button_add_end_dynamic_hor/button", function()
add_node_dynamic_hor(self)