mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
#51 Get default grid anchor from node
This commit is contained in:
parent
e18d150523
commit
6f8190f1a6
@ -20,6 +20,7 @@
|
|||||||
-- @tfield vector3 border_offer The border offset for correct anchor calculations
|
-- @tfield vector3 border_offer The border offset for correct anchor calculations
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("grid")
|
local M = component.create("grid")
|
||||||
@ -35,7 +36,10 @@ function M.init(self, parent, element, in_row)
|
|||||||
self.nodes = {}
|
self.nodes = {}
|
||||||
|
|
||||||
self.offset = vmath.vector3(0)
|
self.offset = vmath.vector3(0)
|
||||||
self.anchor = vmath.vector3(0.5, 0, 0)
|
|
||||||
|
local pivot = const.PIVOTS[gui.get_pivot(self.parent)]
|
||||||
|
self.anchor = vmath.vector3(0.5 + pivot.x, 0.5 - pivot.y, 0)
|
||||||
|
|
||||||
self.in_row = in_row or 1
|
self.in_row = in_row or 1
|
||||||
self.node_size = gui.get_size(self:get_node(element))
|
self.node_size = gui.get_size(self:get_node(element))
|
||||||
self.border = vmath.vector4(0)
|
self.border = vmath.vector4(0)
|
||||||
|
@ -6,7 +6,6 @@ local function init_grid(self)
|
|||||||
|
|
||||||
local grid_scroll = self.druid:new_scroll("grid_content", "scroll_with_grid_size")
|
local grid_scroll = self.druid:new_scroll("grid_content", "scroll_with_grid_size")
|
||||||
local grid = self.druid:new_grid("grid_content", "grid_prefab", 20)
|
local grid = self.druid:new_grid("grid_content", "grid_prefab", 20)
|
||||||
grid:set_anchor(vmath.vector3(0, 0.5, 0))
|
|
||||||
|
|
||||||
for i = 1, 40 do
|
for i = 1, 40 do
|
||||||
local clone_prefab = gui.clone_tree(prefab)
|
local clone_prefab = gui.clone_tree(prefab)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user