Module druid.static_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
get_pos(index) Return pos for grid node index
get_index(pos) Return index for grid pos
get_index_by_node(node) Return grid index by node
set_anchor(anchor) Set grid anchor.
add(item[, index]) Add new item to the grid
remove(index, is_shift_nodes) Remove the item from the grid.
get_size() Return grid content size
get_all_pos() Return array of all node positions
set_position_function(callback) Change set position function for grid nodes.
clear() Clear grid nodes array.

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)
get_pos(index)
Return pos for grid node index

Parameters:

  • index number The grid element index

Returns:

    vector3 Node position
get_index(pos)
Return index for grid pos

Parameters:

  • pos vector3 The node position in the grid

Returns:

    number The node index
get_index_by_node(node)
Return grid index by node

Parameters:

  • node node The gui node in the grid

Returns:

    number The node index
set_anchor(anchor)
Set grid anchor. Default anchor is equal to anchor of grid parent node

Parameters:

  • anchor 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)
remove(index, is_shift_nodes)
Remove the item from the grid. Note that gui node will be not deleted

Parameters:

  • index number The grid node index to remove
  • is_shift_nodes bool If true, will shift nodes left after index
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
set_position_function(callback)
Change set position function for grid nodes. It will call on update poses on grid elements. Default: gui.set_position

Parameters:

  • callback function Function on node set position

Returns:

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

Returns:

    druid.static_grid Current grid instance

Tables

Events
Component events

Fields:

  • on_add_item druid_event On item add callback
  • on_remove_item druid_event On item remove callback
  • on_change_items druid_event On item add or 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
  • first_index number The first index of node in grid
  • last_index number The last index of node in grid
  • anchor vector3 Item anchor
  • node_size vector3 Item size
  • border vector4 The size of item content
generated by LDoc 1.4.6 Last updated 2020-09-29 23:46:16