Module druid.dynamic_grid

Component to handle placing components in row

Functions

init(parent) Component init function
get_pos(index, node) Return pos for grid node index
add(node[, index[, is_shift_left=false]]) Add new node to the grid
remove(index[, is_shift_left=false]) Remove the item from the grid.
get_size() Return grid content size
get_index_by_node(node) Return grid index by node
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.
DynamicGrid:_get_side_vector(side, is_forward) Return side vector to correct node shifting

Tables

Events Component events
Fields Component fields


Functions

init(parent)
Component init function

Parameters:

  • parent node The gui node parent, where items will be placed
get_pos(index, node)
Return pos for grid node index

Parameters:

  • index number The grid element index
  • node node The node to be placed

Returns:

    vector3 Node position
add(node[, index[, is_shift_left=false]])
Add new node to the grid

Parameters:

  • node node Gui node
  • index number The node position. By default add as last node (optional)
  • is_shift_left bool If true, shift all nodes to the left, otherwise shift nodes to the right (default false)
remove(index[, is_shift_left=false])
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_left bool If true, shift all nodes to the left, otherwise shift nodes to the right (default false)
get_size()
Return grid content size

Returns:

    vector3 The grid content size
get_index_by_node(node)
Return grid index by node

Parameters:

  • node node The gui node in the grid

Returns:

    number The node index
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.dynamic_grid Current grid instance
clear()
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

Returns:

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

Parameters:

  • side
  • is_forward

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
  • 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