# Module `DynamicGrid`

Component to handle placing components in row

## Functions

init(self, parent) | Component init function
get_pos(self, index, node[, origin_index]) | Return pos for grid node index
add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]]) | Add new node to the grid
remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]) | Remove the item from the grid.
get_size(self, border) | Return grid content size
get_offset(self) | Return DynamicGrid offset, where DynamicGrid content starts.
get_borders(self) | Return grid content borders
get_index_by_node(self, node) | Return grid index by node
get_all_pos(self) | Return array of all node positions
set_position_function(self, callback) | Change set position function for grid nodes.
clear(self) | Clear grid nodes array.
_get_side_vector(self, side, is_forward) | Return side vector to correct node shifting

## Fields

on_add_item | On item add callback(self, node, index)
on_remove_item | On item remove callback(self, index)
on_change_items | On item add or remove callback(self, index)
on_clear | On grid clear callback(self)
on_update_positions | On update item positions callback(self)
parent | Parent gui node
nodes | List of all grid elements.
first_index | The first index of node in grid
last_index | The last index of node in grid
node_size | Item size
border | The size of item content

## Functions

init(self, parent)
  Component init function

  ### Parameters:

  - self DynamicGrid
  - parent node The gui node parent, where items will be placed
get_pos(self, index, node[, origin_index])
  Return pos for grid node index

  ### Parameters:

  - self DynamicGrid
  - index number The grid element index
  - node node The node to be placed
  - origin_index number Index of nearby node (optional)

  ### Returns:

  vector3 Node position
add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]])
  Add new node to the grid

  ### Parameters:

  - self DynamicGrid
  - node node Gui node
  - index number The node position. By default add as last node (optional)
  - shift_policy number How shift nodes, if required. See const.SHIFT (default SHIFT.RIGHT)
  - is_instance boolean If true, update node positions instantly (default false)
remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]])
  Remove the item from the grid. Note that gui node will be not deleted

  ### Parameters:

  - self DynamicGrid
  - index number The grid node index to remove
  - shift_policy number How shift nodes, if required. See const.SHIFT (default SHIFT.RIGHT)
  - is_instance boolean If true, update node positions instantly (default false)

  ### Returns:

  Node The deleted gui node from grid
get_size(self, border)
  Return grid content size

  ### Parameters:

  - self DynamicGrid
  - border vector3

  ### Returns:

  vector3 The grid content size
get_offset(self)
  Return DynamicGrid offset, where DynamicGrid content starts.

  ### Parameters:

  - self DynamicGrid The DynamicGrid instance

  ### Returns:

  vector3 The DynamicGrid offset
get_borders(self)
  Return grid content borders

  ### Parameters:

  - self DynamicGrid

  ### Returns:

  vector3 The grid content borders
get_index_by_node(self, node)
  Return grid index by node

  ### Parameters:

  - self DynamicGrid
  - node node The gui node in the grid

  ### Returns:

  number The node index
get_all_pos(self)
  Return array of all node positions

  ### Parameters:

  - self DynamicGrid

  ### Returns:

  vector3[] All grid node positions
set_position_function(self, callback)
  Change set position function for grid nodes. It will call on update poses on grid elements. Default: gui.set_position

  ### Parameters:

  - self DynamicGrid
  - callback function Function on node set position

  ### Returns:

  druid.dynamic_grid Current grid instance
clear(self)
  Clear grid nodes array. GUI nodes will be not deleted! If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear

  ### Parameters:

  - self DynamicGrid

  ### Returns:

  druid.dynamic_grid Current grid instance
_get_side_vector(self, side, is_forward)
  Return side vector to correct node shifting

  ### Parameters:

  - self
  - side
  - is_forward

## Fields

on_add_item
  On item add callback(self, node, index)
  - on_add_item druid_event
on_remove_item
  On item remove callback(self, index)
  - on_remove_item druid_event
on_change_items
  On item add or remove callback(self, index)
  - on_change_items druid_event
on_clear
  On grid clear callback(self)
  - on_clear druid_event
on_update_positions
  On update item positions callback(self)
  - on_update_positions druid_event
parent
  Parent gui node
  - parent node
nodes
  List of all grid elements. Contains from node, pos, size, pivot
  - nodes node[]
first_index
  The first index of node in grid
  - first_index number
last_index
  The last index of node in grid
  - last_index number
node_size
  Item size
  - node_size vector3
border
  The size of item content
  - border vector4

generated by LDoc 1.4.6 Last updated 2022-02-12 17:16:44