# Defold Druid UI Library

# Module `DynamicGrid`

Component to handle placing components in row

## Functions

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

## Fields

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

## Functions

_get_side_vector(self, side, is_forward)
  Return side vector to correct node shifting

  ### Parameters:

  - self
  - side
  - is_forward
add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]])
  Add new node to the grid

  ### Parameters:

  - self DynamicGrid 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_instant boolean If true, update node positions instantly (default false)
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 DynamicGrid

  ### Returns:

  druid.dynamic_grid Current grid instance
get_all_pos(self)
  Return array of all node positions

  ### Parameters:

  - self DynamicGrid DynamicGrid

  ### Returns:

  vector3[] All grid node positions
get_borders(self)
  Return grid content borders

  ### Parameters:

  - self DynamicGrid DynamicGrid

  ### Returns:

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

  ### Parameters:

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

  ### Returns:

  number The node index
get_offset(self)
  Return DynamicGrid offset, where DynamicGrid content starts.

  ### Parameters:

  - self DynamicGrid DynamicGrid The DynamicGrid instance

  ### Returns:

  vector3 The DynamicGrid offset
get_pos(self, index, node[, origin_index])
  Return pos for grid node index

  ### Parameters:

  - self DynamicGrid 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
get_size(self, border)
  Return grid content size

  ### Parameters:

  - self DynamicGrid DynamicGrid
  - border vector3

  ### Returns:

  vector3 The grid content size
init(self, parent)
  Component init function

  ### Parameters:

  - self DynamicGrid DynamicGrid
  - parent node The gui node parent, where items will be placed
remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]])
  Remove the item from the grid. Note that gui node will be not deleted

  ### Parameters:

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

  ### Returns:

  node The deleted gui node from grid
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 DynamicGrid
  - callback function Function on node set position

  ### Returns:

  druid.dynamic_grid Current grid instance

## Fields

border
  The size of item content
  - border vector4
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
nodes
  List of all grid elements. Contains from node, pos, size, pivot
  - nodes node[]
on_add_item
  On item add callback(self, node, index)
  - on_add_item DruidEvent DruidEvent
on_change_items
  On item add or remove callback(self, index)
  - on_change_items DruidEvent DruidEvent
on_clear
  On grid clear callback(self)
  - on_clear DruidEvent DruidEvent
on_remove_item
  On item remove callback(self, index)
  - on_remove_item DruidEvent DruidEvent
on_update_positions
  On update item positions callback(self)
  - on_update_positions DruidEvent DruidEvent
parent
  Parent gui node
  - parent node

generated by LDoc TESTING Last updated 2015-01-01 12:00:00