Skip to main content

Module grid

Module grid 

Source
Expand description

Owned native-GUI grid layout solver.

Implements the frozen grid contract from docs/design/owned-layout-engine.md (sections 2, 3, and 7) as an native-gui-owned solver, consistent with the owned flexbox solver in super::flex:

  • Track sizing: Fixed(px), Percent(%), Flex(fr), Auto, and MinMax(min, max).
  • Placement: explicit 1-based start line + span, plus sequential row-major (GridAutoFlow::Row) or column-major (GridAutoFlow::Column) auto flow.
  • Sparse placement only. Dense packing and subgrid are rejected by the contract (keyboard-accessibility invariant) and are not modeled here.
  • Gaps are applied between tracks only, never outside the track set.
  • Items are positioned within their grid area by justify (inline axis) and align (block axis), defaulting to Start.

Numerical invariants: all inputs are required to be finite; resolved dimensions are clamped to be non-negative; percentage track sizes resolve against the container’s content box; percentage item sizes resolve against the item’s grid area.

The solver is a pure function of the container style, container content box, available space, and the in-flow children (id, style, hypothetical border-box size), returning one LayoutRect per child. It is invoked from super::tree::LayoutTree::solve_node_depth when a node’s Style::display is super::Display::Grid.

Functions§

compute_grid
Computes owned native-GUI grid layout for a container and its in-flow children.