Solve #165 Add set_in_row function for StaticGrid

This commit is contained in:
Insality 2022-02-28 22:18:07 +02:00
parent bd0c5545ae
commit 129a102cc8

View File

@ -12,7 +12,7 @@
--- On item remove callback(self, index) --- On item remove callback(self, index)
-- @tfield druid_event on_remove_item -- @tfield druid_event on_remove_item
--- On item add or remove callback(self, index) --- On item add, remove or change in_row callback(self, index|nil)
-- @tfield druid_event on_change_items -- @tfield druid_event on_change_items
--- On grid clear callback(self) --- On grid clear callback(self)
@ -353,6 +353,20 @@ function StaticGrid:get_offset()
end end
--- Set new in_row elements for grid
-- @tparam StaticGrid self
-- @tparam number in_row The new in_row value
-- @treturn druid.static_grid Current grid instance
function StaticGrid:set_in_row(in_row)
self.in_row = in_row
self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x
self:_update(true)
self.on_change_items:trigger(self:get_context())
return self
end
--- Update grid inner state --- Update grid inner state
-- @tparam StaticGrid self -- @tparam StaticGrid self
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback