pub struct LayoutSpec {Show 20 fields
pub width: Sizing,
pub height: Sizing,
pub min_w: Min,
pub max_w: f32,
pub min_h: Min,
pub max_h: f32,
pub dir: Dir,
pub padding: Edges,
pub gap: f32,
pub wrap: bool,
pub table: bool,
pub cross_gap: f32,
pub main_align: Align,
pub cross_align: Align,
pub aspect: f32,
pub clip: bool,
pub scroll_x: bool,
pub scroll_y: bool,
pub anchor: bool,
pub float: Option<FloatConfig>,
}Expand description
The layout half of a NodeSpec: sizing, clamps, direction, padding,
gap, alignment, overflow and floating. Set through the NodeSpec
builders; read by the solver.
Fields§
§width: Sizing§height: Sizing§min_w: MinClamps applied after width/height resolve (Fit, Grow, Percent and
Fixed alike), so “grow but at most N” and “fit but at least N” work.
A min may also be Min::FIT: “grow but never below my content”.
max_w: f32A ceiling in px, or, as a negative, a size expression layout has
yet to resolve (max_of_calc); set it through
NodeSpec::max_width, which keeps a px one at or above zero
(px_ceiling). max_h is the same.
min_h: Min§max_h: f32§dir: Dir§padding: Edges§gap: f32§wrap: boolRow children that don’t fit the main-axis content box start a new
line instead of overflowing (or shrinking). Rows only: breaking
needs a definite main size, and the pass order gives a row one —
its width is final before its height is measured — where a column
would need its height first. Ignored on a column and on a
scroll_x row, both with a warning (diag::WRAP_IGNORED).
table: boolA column whose rows’ children line up in columns: the nth in-flow
child of every in-flow row is a cell of column n, and
a column is as wide as its widest cell — its cells’ own widths
say how the column sizes (a Fixed or Fit cell is content that
sets the column’s fit width, a Grow cell makes the column grow,
a Percent one takes its cut of the row) and their minWidth /
maxWidth clamp it. The rows are ordinary rows — a row’s gap is
the space between its cells, its padding its own, and it takes
its background, its click and its hover as any row does — except
that a row of a table never wraps (diag::WRAP_IGNORED). Set by
NodeSpec::table, which is a column; dir stays Column, and
the flag is read on a column only (LayoutSpec::is_table): a
Row carrying it — a shape only these public fields can build —
is the row it says it is. The rows are the in-flow Row children;
a column, a table or a leaf straight under the table is a child
with its own width and no cells.
cross_gap: f32Space between wrap lines, across the main axis. gap is still the
space between children along it.
main_align: AlignAlignment of children along the main axis, the spreads
(SpaceBetween / SpaceAround / SpaceEvenly) included.
cross_align: AlignAlignment of children across the main axis; Baseline on a row.
aspect: f32Width over height (CSS’s aspect-ratio); 0 = none.
It sizes the axis whose sizing is Fit: a fit height is the final
width over the ratio, and a fit width under a Fixed height is
that height times it. With both axes declared it has nothing to set.
The derived axis is neither shrunk nor fitted to the children,
which overflow it — min_h: Min::FIT floors it at them.
clip: boolClip children to this node’s rect.
scroll_x: boolOverflowing content scrolls (implies clipping). Offsets are retained
across frames in the core, keyed by this node’s Key.
scroll_y: bool§anchor: boolScroll anchoring (CSS’s overflow-anchor): the
first child in view keeps its place on screen when the content
before it changes size — a chat that prepends history, a log that
inserts above the viewport, a row whose estimate was corrected.
On the scroll axis that is the container’s main axis only.
float: Option<FloatConfig>Out-of-flow positioning; see FloatConfig.