mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Remove side from dynamic_grid, move it to node pivot
This commit is contained in:
parent
d0385a3c03
commit
f25a8acd95
@ -106,6 +106,7 @@ Druid 0.5.0:
|
|||||||
- Element size got from _gui.get_size_ * _gui.get_scale_
|
- Element size got from _gui.get_size_ * _gui.get_scale_
|
||||||
- This grid can not have spaces between elements. You will get the error, if spawn element far away from other elements
|
- This grid can not have spaces between elements. You will get the error, if spawn element far away from other elements
|
||||||
- The grid can spawn elements only in row or in collumn
|
- The grid can spawn elements only in row or in collumn
|
||||||
|
- The grid node should have West or North pivot (vertical or horizontal element placement)
|
||||||
- **#37** Add _on_layout_change_ support. Druid will keep and restore GUI component data between changing game layout. Override function _on_layout_change_ in your custom components to do stuff you need.
|
- **#37** Add _on_layout_change_ support. Druid will keep and restore GUI component data between changing game layout. Override function _on_layout_change_ in your custom components to do stuff you need.
|
||||||
- **#85** Move several components from `base` folder to `extended`. In future, to use them, you have to register them manually. This is need for decrease build size by excluding unused components
|
- **#85** Move several components from `base` folder to `extended`. In future, to use them, you have to register them manually. This is need for decrease build size by excluding unused components
|
||||||
- Add _scroll:set_vertical_scroll_ and _scroll:set_horizontal_scroll_ for disable scroll sides
|
- Add _scroll:set_vertical_scroll_ and _scroll:set_horizontal_scroll_ for disable scroll sides
|
||||||
|
@ -37,16 +37,19 @@ local SIDE_VECTORS = {
|
|||||||
--- Component init function
|
--- Component init function
|
||||||
-- @function dynamic_grid:init
|
-- @function dynamic_grid:init
|
||||||
-- @tparam node parent The gui node parent, where items will be placed
|
-- @tparam node parent The gui node parent, where items will be placed
|
||||||
-- @tparam enum.side side The grid side. By default - vertical
|
|
||||||
function DynamicGrid:init(parent, side)
|
function DynamicGrid:init(parent, side)
|
||||||
self.nodes = {}
|
|
||||||
self.side = side or const.SIDE.Y
|
|
||||||
self.parent = self:get_node(parent)
|
self.parent = self:get_node(parent)
|
||||||
|
local parent_pivot = gui.get_pivot(self.parent)
|
||||||
|
|
||||||
|
self.pivot = helper.get_pivot_offset(parent_pivot)
|
||||||
|
self.anchor = vmath.vector3(0.5 + self.pivot.x, 0.5 - self.pivot.y, 0)
|
||||||
|
|
||||||
|
assert(parent_pivot == gui.PIVOT_W or parent_pivot == gui.PIVOT_N, const.ERRORS.GRID_DYNAMIC_ANCHOR)
|
||||||
|
self.side = (parent_pivot == gui.PIVOT_W and const.SIDE.X or const.SIDE.Y)
|
||||||
|
|
||||||
|
self.nodes = {}
|
||||||
self.offset = vmath.vector3(0)
|
self.offset = vmath.vector3(0)
|
||||||
self.border = vmath.vector4(0) -- Current grid content size
|
self.border = vmath.vector4(0) -- Current grid content size
|
||||||
self.pivot = helper.get_pivot_offset(gui.get_pivot(self.parent))
|
|
||||||
self.anchor = vmath.vector3(0.5 + self.pivot.x, 0.5 - self.pivot.y, 0)
|
|
||||||
|
|
||||||
self.on_add_item = Event()
|
self.on_add_item = Event()
|
||||||
self.on_remove_item = Event()
|
self.on_remove_item = Event()
|
||||||
|
@ -102,6 +102,11 @@ M.SWIPE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.ERRORS = {
|
||||||
|
GRID_DYNAMIC_ANCHOR = "The pivot of dynamic grid node should be West or North"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
M.EMPTY_FUNCTION = function() end
|
M.EMPTY_FUNCTION = function() end
|
||||||
M.EMPTY_STRING = ""
|
M.EMPTY_STRING = ""
|
||||||
M.SPACE_STRING = " "
|
M.SPACE_STRING = " "
|
||||||
|
@ -79,7 +79,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function init_dynamic_grid(self)
|
local function init_dynamic_grid(self)
|
||||||
self.dynamic_grid = self.druid:new_dynamic_grid("grid_dynamic_nodes", druid_const.SIDE.Y)
|
self.dynamic_grid = self.druid:new_dynamic_grid("grid_dynamic_nodes")
|
||||||
|
|
||||||
self.prefab_dynamic = gui.get_node("grid_dynamic_prefab")
|
self.prefab_dynamic = gui.get_node("grid_dynamic_prefab")
|
||||||
gui.set_enabled(self.prefab_dynamic, false)
|
gui.set_enabled(self.prefab_dynamic, false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user