Module DynamicGrid
Component to handle placing components in row
init(self, parent) |
Component init function |
get_pos(self, index, node[, origin_index]) |
Return pos for grid node index |
add(self, node[, index[, is_shift_left=false]]) |
Add new node to the grid |
remove(self, index[, is_shift_left=false]) |
Remove the item from the grid. |
get_size(self, border) |
Return grid content size |
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 |
-
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[, is_shift_left=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)
- is_shift_left
bool
If true, shift all nodes to the left, otherwise shift nodes to the right
(default false)
-
remove(self, index[, is_shift_left=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
- is_shift_left
bool
If true, shift all nodes to the left, otherwise shift nodes to the right
(default false)
-
get_size(self, border)
-
Return grid content size
Parameters:
- self
DynamicGrid
- border
vector3
Returns:
vector3
The grid content size
-
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:
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:
Returns:
druid.dynamic_grid
Current grid instance
-
_get_side_vector(self, side, is_forward)
-
Return side vector to correct node shifting
Parameters:
-
on_add_item
-
On item add callback(self, node, index)
-
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_update_positions
-
On update item positions callback(self)
- on_update_positions
druid_event
-
parent
-
Parent gui node
-
nodes
-
List of all grid nodes
-
first_index
-
The first index of node in grid
-
last_index
-
The last index of node in grid
-
node_size
-
Item size