# Module `druid.grid`

Component to handle placing components by row and columns.

Grid can anchor your elements, get content size and other

## Functions

init(parent, element[, in_row=1]) | Component init function
set_offset(offset) | Set grid items offset, the distance between items
set_anchor(acnhor) | Set grid anchor
add(item[, index]) | Add new item to the grid
get_size() | Return grid content size
get_all_pos() | Return array of all node positions
clear() | Clear all items from the grid

## Tables

Events | Component events
Fields | Component fields

## Functions

init(parent, element[, in_row=1])
  Component init function

  ### Parameters:

  - parent node The gui node parent, where items will be placed
  - element node Element prefab. Need to get it size
  - in_row number How many nodes in row can be placed (default 1)
set_offset(offset)
  Set grid items offset, the distance between items

  ### Parameters:

  - offset vector3 Offset
set_anchor(acnhor)
  Set grid anchor

  ### Parameters:

  - acnhor vector3 Anchor
add(item[, index])
  Add new item to the grid

  ### Parameters:

  - item node Gui node
  - index number The item position. By default add as last item (optional)
get_size()
  Return grid content size

  ### Returns:

  vector3 The grid content size
get_all_pos()
  Return array of all node positions

  ### Returns:

  vector3[] All grid node positions
clear()
  Clear all items from the grid

## Tables

Events
  Component events

  ### Fields:

  - on_add_item druid_event On item add callback
  - on_remove_item druid_event On item remove callback
  - on_clear druid_event On grid clear callback
  - on_update_positions druid_event On update item positions callback
Fields
  Component fields

  ### Fields:

  - parent node Parent gui node
  - nodes node[] List of all grid nodes
  - offset vector3 Item distance between each other items
  - anchor vector3 Item anchor
  - node_size vector3 Item size
  - border vector4 The size of item content
  - border_offer vector3 The border offset for correct anchor calculations

generated by LDoc 1.4.6 Last updated 2020-04-18 14:39:17