2025-03-18 22:00:51 +02:00

5.7 KiB

druid.layout API

at /druid/extended/layout.lua

The component used for managing the layout of nodes, placing them inside the node size with respect to the size and pivot of each node

Functions

Fields

init


layout:init(node_or_node_id, layout_type)
layout_type:
    | "horizontal"
    | "vertical"
    | "horizontal_wrap"
  • Parameters:
    • node_or_node_id (string|node):
    • layout_type ("horizontal"|"horizontal_wrap"|"vertical"):

update


layout:update()

get_entities


layout:get_entities()
  • Returns:
    • entities (node[]): The entities to manage the layout of

set_node_index


layout:set_node_index(node, index)
  • Parameters:

    • node (node): The node to set the index of
    • index (number): The index to set the node to
  • Returns:

    • self (druid.layout): for chaining

set_margin


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

set_padding


layout:set_padding([padding_x], [padding_y], [padding_z], [padding_w])
  • Parameters:

    • [padding_x] (number|nil): The padding x
    • [padding_y] (number|nil): The padding y
    • [padding_z] (number|nil): The padding z
    • [padding_w] (number|nil): The padding w
  • Returns:

    • self (druid.layout): Current layout instance

set_dirty


layout:set_dirty()
  • Returns:
    • self (druid.layout): Current layout instance

set_justify


layout:set_justify(is_justify)
  • Parameters:

    • is_justify (boolean):
  • Returns:

    • self (druid.layout): Current layout instance

set_type


layout:set_type(type)
  • Parameters:

    • type (string): The layout type: "horizontal", "vertical", "horizontal_wrap"
  • Returns:

    • self (druid.layout): Current layout instance

set_hug_content


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

add


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

remove


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

get_size


layout:get_size()
  • Returns:
    • `` (vector3):

get_content_size


layout:get_content_size()
  • Returns:
    • `` (number):
    • `` (number):

refresh_layout


layout:refresh_layout()
  • Returns:
    • self (druid.layout): Current layout instance

clear_layout


layout:clear_layout()
  • Returns:
    • self (druid.layout): Current layout instance

get_node_size


layout:get_node_size(node)
  • Parameters:

    • node (node):
  • Returns:

    • width (number): The width of the node
    • height (number): The height of the node

calculate_rows_data


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):

set_node_position


layout:set_node_position(node, x, y)
  • Parameters:

    • node (node):
    • x (number):
    • y (number):
  • Returns:

    • `` (node):

Fields

  • node (node): The node to manage the layout of

  • rows_data (druid.layout.rows_data): Last calculated rows data

  • is_dirty (boolean)

  • 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): The event triggered when the size of the layout is changed

  • size (unknown)