at /druid/extended/layout.lua
Druid component to manage the layout of nodes, placing them inside the node size with respect to the size and pivot of each node.
Create layout component with druid: layout = druid:new_layout(node, layout_type)
- Layout can be horizontal, vertical or horizontal with wrapping
- Layout can resize parent node to fit content
- Layout can justify content
- Layout supports margins and padding
- Layout automatically updates when nodes are added or removed
- Layout can be manually updated by calling set_dirty()
- init
- update
- get_entities
- get_entities_count
- set_node_index
- set_margin
- set_padding
- set_dirty
- set_justify
- set_type
- set_hug_content
- add
- remove
- get_size
- get_content_size
- refresh_layout
- clear_layout
- get_node_size
- calculate_rows_data
- set_node_position
- set_position_function
- node
- rows_data
- is_dirty
- entities
- margin
- padding
- type
- is_resize_width
- is_resize_height
- is_justify
- on_size_changed
- size
layout:init(node_or_node_id, layout_type)layout_type:
| "horizontal"
| "vertical"
| "horizontal_wrap"- Parameters:
node_or_node_id(string|node): The node to manage the layout oflayout_type("horizontal"|"horizontal_wrap"|"vertical"): The type of layout (horizontal, vertical, horizontal_wrap)
layout:update()layout:get_entities()- Returns:
entities(node[]): The entities to manage the layout of
layout:get_entities_count()- Returns:
count(number): The count of entities in layout
layout:set_node_index(node, index)-
Parameters:
node(node): The node to set the index ofindex(number): The index to set the node to
-
Returns:
self(druid.layout): for chaining
layout:set_margin([margin_x], [margin_y])Set the margin of the layout
-
Parameters:
[margin_x](number|nil): The margin x[margin_y](number|nil): The margin y
-
Returns:
self(druid.layout): Current layout instance
layout:set_padding([padding_x], [padding_y], [padding_z], [padding_w])-
Parameters:
[padding_x](number|nil): From Left[padding_y](number|nil): From Top[padding_z](number|nil): From Right[padding_w](number|nil): From Bottom
-
Returns:
self(druid.layout): Current layout instance
layout:set_dirty()- Returns:
self(druid.layout): Current layout instance
layout:set_justify(is_justify)-
Parameters:
is_justify(boolean):
-
Returns:
self(druid.layout): Current layout instance
layout:set_type(layout_type)layout_type:
| "horizontal"
| "vertical"
| "horizontal_wrap"-
Parameters:
layout_type("horizontal"|"horizontal_wrap"|"vertical"):
-
Returns:
self(druid.layout): Current layout instance
layout:set_hug_content(is_hug_width, is_hug_height)-
Parameters:
is_hug_width(boolean):is_hug_height(boolean):
-
Returns:
self(druid.layout): Current layout instance
layout:add(node_or_node_id)Add node to layout
-
Parameters:
node_or_node_id(string|node): node_or_node_id
-
Returns:
self(druid.layout): Current layout instance
layout:remove(node_or_node_id)Remove node from layout
-
Parameters:
node_or_node_id(string|node): node_or_node_id
-
Returns:
self(druid.layout): for chaining
layout:get_size()- Returns:
- `` (vector3):
layout:get_content_size()- Returns:
- `` (number):
- `` (number):
layout:refresh_layout([is_instant])-
Parameters:
[is_instant](boolean|nil): If true, node position update instantly, otherwise with set_position_function callback
-
Returns:
self(druid.layout): Current layout instance
layout:clear_layout()- Returns:
self(druid.layout): Current layout instance
layout:get_node_size(node)-
Parameters:
node(node):
-
Returns:
width(number): The width of the nodeheight(number): The height of the node
layout:calculate_rows_data()Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row)
- Returns:
- `` (druid.layout.rows_data):
layout:set_node_position(node, x, y, [is_instant])-
Parameters:
node(node):x(number):y(number):[is_instant](any):
-
Returns:
- `` (node):
layout:set_position_function(callback)Set custom position function for layout nodes. It will call on update poses on layout elements. Default: gui.set_position
-
Parameters:
callback(function):
-
Returns:
self(druid.layout): Current layout instance
- node (node): The node to manage the layout of
- rows_data (druid.layout.rows_data): Last calculated rows data
- is_dirty (boolean): True if layout needs to be updated
- entities (node[]): The entities to manage the layout of
- margin ({ x: number, y: number }): The margin of the layout
- padding (vector4): The padding of the layout
- type (string): The type of the layout
- is_resize_width (boolean): True if the layout should resize the width of the node
- is_resize_height (boolean): True if the layout should resize the height of the node
- is_justify (boolean): True if the layout should justify the nodes
- on_size_changed (event.on_size_changed): fun(self: druid.layout, size: vector3) The event triggered when the size of the layout is changed
- size (unknown)