Skip to Content
defold-typescript libraries
Pause-Gamesflow

Pause-Games/flow/flow.layout

Flow's flexbox layout pass, which computes the position and size of every element in a tree.

  • GitHub: Pause-Games/flow — pinned to 1.0.0
    1. Pick a release from Pause-Games/flow releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as layout from "flow.layout"

Functions

compute(node: Flow_Element, x: number, y: number, w: number, h: number)

Compute layout for a node tree. Writes layout.x/y/w/h to every node in the tree recursively, using bottom-left origin coordinates.

Algorithm:

  1. Measure all regular (non-overlay) children to sum fixed sizes and flex_grow weights.
  2. Distribute remaining free space according to justify_content.
  3. Place each child along the main axis, applying align_items / align_self on the cross axis.
  4. Recurse into each child.
  5. Layout overlay children (popup, bottom_sheet) at full parent bounds as a final pass.

Parameters

  • node: Flow_Element — The root element to compute layout for
  • x: number — Left edge of the available area in layout space (px)
  • y: number — Bottom edge of the available area in layout space (px)
  • w: number — Available width in pixels
  • h: number — Available height in pixels

On this page