Add Bind layout and hotkey node bind

This commit is contained in:
Insality
2025-04-21 19:53:44 +03:00
parent c33dbd5942
commit 4e71fee9ba
5 changed files with 61 additions and 5 deletions

View File

@@ -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

View File

@@ -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()