basic implementation of grid (#19)

* basic implementation of grid

* add dirty example of grid
This commit is contained in:
Maxim Tuprikov
2019-04-04 23:10:03 +03:00
committed by GitHub
parent d49cd2777e
commit bd2c06d81b
4 changed files with 404 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ local lang = {
local start_x = 300
local page_width = 600
local cur_page = 1
local max_page = 2
local max_page = 3
@@ -73,11 +73,10 @@ local function init_progress(self)
vert:to(val)
end)
local rich = self.druid:new_progress_rich("rich_fill", "rich_red", "rich_green", "x")
rich:set_to(0.3)
local rich_val = 0.3
self.druid:new_button("rich_add", function()
rich_val = rich_val + 0.1
@@ -90,6 +89,45 @@ local function init_progress(self)
end
local function init_grid(self)
local prefab = gui.get_node("prefab")
-- 4 items per row
local grid = self.druid:new_grid("grid_1", prefab, 4)
grid:set_offset(vmath.vector3(2, 2, 0))
for i = 1, 16 do
local node = gui.clone(prefab)
grid:add(node)
end
local val = 0
timer.delay(0.1, true, function()
val = val + 0.5
grid:set_offset(vmath.vector3(val))
if val > 4 then
val = 0
end
end)
-- 1 item per row
local grid2 = self.druid:new_grid("grid_2", prefab, 1)
grid2:set_offset(vmath.vector3(0, 10, 0))
for i = 1, 4 do
local node = gui.clone(prefab)
grid2:add(node)
end
local grid3 = self.druid:new_grid("grid_3", prefab, 10)
grid3:set_offset(vmath.vector3(5, 0, 0))
for i = 1, 4 do
local node = gui.clone(prefab)
grid3:add(node)
end
end
function init(self)
setup_druid(self)
self.druid = druid.new(self)
@@ -97,6 +135,7 @@ function init(self)
init_pages(self)
init_buttons(self)
init_progress(self)
init_grid(self)
self.druid:new_android_back(log, "some")
end