Pure Elixir "Flexbox Lite" layout engine.
Computes layout for a tree of %ElixirOpentui.Element{} structs, producing
a map of %{element_ref => %Rect{x, y, w, h}} results.
Implements the TUI-relevant subset of CSS Flexbox:
flex_direction: :row | :column | :row_reverse | :column_reverse
- flex_grow, flex_shrink, flex_basis
flex_wrap: :no_wrap | :wrap | :wrap_reverse
justify_content: :flex_start | :flex_end | :center | :space_between | :space_around | :space_evenly
align_items, align_self: :flex_start | :flex_end | :center | :stretch
- width, height (fixed, :auto, {:percent, p})
- padding, margin, gap
position: :relative | :absolute (with top/left/right/bottom)
NOT implemented (not used in TUI): align-content, order, CSS grid.
Three-pass algorithm:
- Measure (bottom-up): compute intrinsic sizes
- Flex resolve (top-down): distribute space via grow/shrink
- Position (top-down): compute absolute coordinates
Summary
Functions
Compute layout for an element tree within the given available space.
Types
@type layout_result() :: %{required(reference()) => ElixirOpentui.Layout.Rect.t()}
Functions
@spec compute(ElixirOpentui.Element.t(), non_neg_integer(), non_neg_integer()) :: {ElixirOpentui.Element.t(), layout_result()}
Compute layout for an element tree within the given available space.
Returns a map keyed by element reference (using make_ref() assigned during layout)
mapping to %Rect{} structs.