UISystem. UILayout

UILayout - A container that auto-arranges children in a vertical list, horizontal list, or grid

  • Set columns to 1 for a vertical list (default)
  • Set columns to children.length for a horizontal list
  • Set columns to N (1 < N < children.length) for a grid with N columns
  • Per-child sizing: each row's height = max child.size.y in that row, each column's width = max child.size.x in that column
  • Children are positioned centered in their cell
  • Container auto-sizes to fit children plus padding
  • Hidden children take no cell, call relayout after showing or hiding one

Constructor

new UILayout(posopt, columnsopt, gapopt, paddingopt, transparentopt)

Create a UILayout container that auto-arranges children

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
columnsnumber<optional>
1

Number of columns (1 = vertical list)

gapnumber<optional>
10

Space between children

paddingnumber<optional>
10

Space between container border and children

transparentboolean<optional>
false

If true, draws no background, outline, or shadow

Extends

  • UIObject

Members

columns

Properties
TypeDescription
number

Number of columns in the layout

gap

Properties
TypeDescription
number

Space between children

padding

Properties
TypeDescription
number

Space between container border and children

Methods

addChild(child) → {UIObject}

Add a child UIObject and re-layout

Parameters:
NameTypeDescription
childUIObject
Returns:

The child object added

Type: 
UIObject

relayout()

Recompute child positions and container size based on per-child sizes. Called automatically by addChild and removeChild. Call manually if you mutate a child's size, show or hide one, or change columns, gap, or padding.

removeChild(child)

Remove a child UIObject and re-layout

Parameters:
NameTypeDescription
childUIObject