LittleJS 1.28.0

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

Extends UIObject

Constructor

new UILayout(pos, columns, gap, padding, transparent)uiSystem.js:1950

Create a UILayout container that auto-arranges children

pos Vector2 optional
columns number optional, default 1

Number of columns (1 = vertical list)

gap number optional, default 10

Space between children

padding number optional, default 10

Space between container border and children

transparent boolean optional, default false

If true, draws no background, outline, or shadow

Members

Methods

Inherited from UIObject

Members

columns : numberuiSystem.js:1968

Number of columns in the layout

gap : numberuiSystem.js:1970

Space between children

padding : numberuiSystem.js:1972

Space between container border and children

Methods

addChild(child) → UIObjectuiSystem.js:1990

Add a child UIObject and re-layout

child UIObject
Returns

The child object added

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)uiSystem.js:1999

Remove a child UIObject and re-layout

child UIObject