mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add Bind layout and hotkey node bind
This commit is contained in:
@@ -445,6 +445,33 @@ function M:bind_grid(grid)
|
||||
end
|
||||
|
||||
|
||||
---Bind the layout component to recalculate
|
||||
-- scroll size on layout changes
|
||||
---@param layout druid.layout|nil Druid layout component
|
||||
---@return druid.scroll self Current scroll instance
|
||||
function M:bind_layout(layout)
|
||||
if self._layout_on_change then
|
||||
self._layout_on_change:unsubscribe(self._layout_on_change_callback)
|
||||
|
||||
self._layout_on_change = nil
|
||||
self._layout_on_change_callback = nil
|
||||
end
|
||||
|
||||
if not layout then
|
||||
return self
|
||||
end
|
||||
|
||||
self._layout_on_change = layout.on_size_changed
|
||||
self._layout_on_change_callback = function(size)
|
||||
self:set_size(size)
|
||||
end
|
||||
self._layout_on_change:subscribe(self._layout_on_change_callback)
|
||||
self:set_size(layout:get_size())
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---Strict drag scroll area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
---@param node node|string Gui node
|
||||
|
@@ -243,6 +243,13 @@ function M:remove(index, shift_policy, is_instant)
|
||||
end
|
||||
|
||||
|
||||
---Return items count in grid
|
||||
---@return number count The items count in grid
|
||||
function M:get_items_count()
|
||||
return #self.nodes
|
||||
end
|
||||
|
||||
|
||||
---Return grid content size
|
||||
---@return vector3 size The grid content size
|
||||
function M:get_size()
|
||||
|
Reference in New Issue
Block a user