pub struct LayoutNode {Show 54 fields
pub children: Vec<LayoutNode>,
pub text: Option<Animated<String>>,
pub shape: Option<LayoutShape>,
pub display: Option<Display>,
pub flex_direction: Option<FlexDirection>,
pub flex_wrap: Option<FlexWrap>,
pub grid_template_columns: Option<TrackList>,
pub grid_template_rows: Option<TrackList>,
pub grid_auto_columns: Option<TrackList>,
pub grid_auto_rows: Option<TrackList>,
pub grid_auto_flow: Option<GridAutoFlow>,
pub gap: Option<Animated<LayoutSize>>,
pub row_gap: Option<Animated<LayoutSize>>,
pub column_gap: Option<Animated<LayoutSize>>,
pub justify_content: Option<JustifyContent>,
pub align_items: Option<AlignItems>,
pub align_content: Option<AlignContent>,
pub justify_items: Option<AlignItems>,
pub padding: Option<Animated<Insets>>,
pub background: Option<Animated<Paint>>,
pub border: Option<LayoutBorder>,
pub border_radius: Option<Animated<LayoutSize>>,
pub overflow: Option<Overflow>,
pub width: Option<Animated<LayoutLength>>,
pub height: Option<Animated<LayoutLength>>,
pub min_width: Option<Animated<LayoutLength>>,
pub min_height: Option<Animated<LayoutLength>>,
pub max_width: Option<Animated<LayoutLength>>,
pub max_height: Option<Animated<LayoutLength>>,
pub aspect_ratio: Option<f32>,
pub margin: Option<Animated<Insets>>,
pub flex_grow: Option<Animated<f32>>,
pub flex_shrink: Option<Animated<f32>>,
pub flex_basis: Option<Animated<LayoutLength>>,
pub align_self: Option<AlignItems>,
pub justify_self: Option<AlignItems>,
pub grid_column: Option<GridPlacement>,
pub grid_row: Option<GridPlacement>,
pub position: Option<Position>,
pub inset: Option<LayoutInset>,
pub font_family: Option<String>,
pub font_size: Option<Animated<LayoutSize>>,
pub fill: Option<Paint>,
pub line_height: Option<f32>,
pub letter_spacing: Option<f32>,
pub font_weight: Option<u16>,
pub text_align: Option<TextAlign>,
pub strokes: Option<Vec<TextStroke>>,
pub shadows: Option<Vec<TextShadow>>,
pub text_animators: Vec<TextAnimator>,
pub opacity: Option<Animated<f32>>,
pub translate: Option<Animated<LayoutOffset>>,
pub scale: Option<Animated<Vec2>>,
pub rotation_degrees: Option<Animated<f32>>,
}Expand description
One box of a layout tree.
A box lays its children out by flexbox (the default) or grid. It is a container with children, a leaf with text or shape content, and empty otherwise (a spacer or decoration). Each box draws background, then border, then content. Boxes draw in document order; reversed directions and grid placement move them but do not change paint order.
Fields§
§children: Vec<LayoutNode>Boxes laid out in this one, in document (and paint) order. Not with text or shape.
text: Option<Animated<String>>The box’s text, wrapped at its content width in the inherited style; \n starts a line.
At most MAX_TEXT_CONTENT_BYTES bytes per value; may be empty. Keyframes all hold.
Not with children or shape.
shape: Option<LayoutShape>Shapes drawn on a picture the size of the box’s content box. Not with children or
text.
display: Option<Display>How the box lays its children out. Default flex. Like every container field, not on a
box with text or shape content.
flex_direction: Option<FlexDirection>The main axis of a flex container’s children. Default row.
flex_wrap: Option<FlexWrap>Whether a flex container’s children wrap onto more lines. Default nowrap.
grid_template_columns: Option<TrackList>A grid’s explicit columns, as CSS writes them ("1fr 2fr",
"repeat(3, minmax(100px, 1fr))"). Default none.
grid_template_rows: Option<TrackList>A grid’s explicit rows. Default none.
grid_auto_columns: Option<TrackList>The size of a grid’s implicit columns. Default auto.
grid_auto_rows: Option<TrackList>The size of a grid’s implicit rows. Default auto.
grid_auto_flow: Option<GridAutoFlow>How a grid places items without a placement. Default row.
gap: Option<Animated<LayoutSize>>Space between children, on both axes. At least 0; default 0.
row_gap: Option<Animated<LayoutSize>>Space between rows (or lines of a wrapping row flex container), in place of gap. At
least 0.
column_gap: Option<Animated<LayoutSize>>Space between columns, in place of gap. At least 0.
justify_content: Option<JustifyContent>Where children lie along the main (for a grid, inline) axis. Default start.
align_items: Option<AlignItems>Where children lie across the main axis, or in their grid areas’ rows. Default stretch.
align_content: Option<AlignContent>Where lines of a wrapping flex container, or a grid’s rows, lie across the container.
Default stretch.
justify_items: Option<AlignItems>Where a grid’s children lie in their grid areas’ columns. Default stretch.
padding: Option<Animated<Insets>>Space inside the border: a length, the CSS shorthand ("8px 16px"), or the sides object.
Sides at least 0; default 0.
background: Option<Animated<Paint>>What covers the border box, rounded by border_radius. Positions are normalized to the
border box.
border: Option<LayoutBorder>A border inside the border box.
border_radius: Option<Animated<LayoutSize>>The corner radius of the border box. At least 0; default 0. Capped at half the box’s shorter side.
overflow: Option<Overflow>Whether content past the padding box is drawn. Default visible.
width: Option<Animated<LayoutLength>>Border-box width. None is auto. Like every item field, not on the root.
height: Option<Animated<LayoutLength>>Border-box height. None is auto.
min_width: Option<Animated<LayoutLength>>Smallest width. None is auto, the CSS automatic minimum size.
min_height: Option<Animated<LayoutLength>>Smallest height. None is auto.
max_width: Option<Animated<LayoutLength>>Largest width. None is none.
max_height: Option<Animated<LayoutLength>>Largest height. None is none.
aspect_ratio: Option<f32>Width over height. Positive.
margin: Option<Animated<Insets>>Space outside the border, written as padding is. Sides may be negative; no auto.
flex_grow: Option<Animated<f32>>How much of a flex container’s free space the box takes. At least 0; default 0. Like every flex item field, not in a grid.
flex_shrink: Option<Animated<f32>>How much the box gives up when a flex container’s space runs short. At least 0; default 1.
flex_basis: Option<Animated<LayoutLength>>The main size before growing and shrinking. None is auto.
align_self: Option<AlignItems>Where the box lies across its flex container’s main axis, or in its grid area’s row.
None follows the parent’s align_items.
justify_self: Option<AlignItems>Where the box lies in its grid area’s column. None follows the parent’s
justify_items. Like every grid item field, not in a flex container.
grid_column: Option<GridPlacement>The box’s columns in its grid, as CSS writes them (2, "1 / 3", "span 2"). Default
auto.
grid_row: Option<GridPlacement>The box’s rows in its grid. Default auto.
position: Option<Position>Whether the box is in its parent’s flow. Default relative.
inset: Option<LayoutInset>Where an absolute box lies in its parent’s padding box.
font_family: Option<String>The family the box’s text draws in, as a text style’s font_family. Inherited; the
root’s is the host’s first font.
font_size: Option<Animated<LayoutSize>>Font size: positive, at most MAX_LAYOUT_FONT_SIZE of the picture’s shorter side.
Inherited; the root’s is 0.05.
fill: Option<Paint>What paints the text’s glyphs, as a text style’s fill. Inherited; the root’s is white.
line_height: Option<f32>Baseline-to-baseline distance in font sizes, in [0.5, 3], as a text style’s
line_height. Inherited; the root’s is 1.2.
letter_spacing: Option<f32>Space after each character, as a fraction of the font size, in [-0.5, 1], as a text
style’s letter_spacing. Not animated. Inherited; the root’s is 0.
font_weight: Option<u16>The weight in [1, 1000] used to match the family’s faces, as a text style’s
font_weight. Not animated. Inherited; the root’s is 400.
text_align: Option<TextAlign>How lines align within the content width. Inherited; the root’s is start.
strokes: Option<Vec<TextStroke>>Bands around the glyphs, as a text style’s strokes. Inherited as a whole list; the root
has none.
shadows: Option<Vec<TextShadow>>Shadows of the glyphs and strokes, as a text style’s shadows. Inherited as a whole list
(as CSS text-shadow); the root has none.
text_animators: Vec<TextAnimator>Per-character motion of the box’s own text, Range selectors only (layout text has no
runs). At most crate::MAX_TEXT_ANIMATORS, keyed in picture time. Not inherited; never
changes layout.
opacity: Option<Animated<f32>>Opacity of the box and everything in it as one group, in 0..=1. Applied after layout.
translate: Option<Animated<LayoutOffset>>Offset of the box and everything in it after layout: the object, or one or two lengths as
CSS translate writes them.
scale: Option<Animated<Vec2>>Per-axis scale of the box and everything in it about its border-box centre, after layout.
rotation_degrees: Option<Animated<f32>>Clockwise rotation of the box and everything in it about its border-box centre, in degrees, after layout.
Implementations§
Source§impl LayoutNode
impl LayoutNode
Sourcepub const fn has_visual(&self) -> bool
pub const fn has_visual(&self) -> bool
Whether the node has a visual field: opacity, translate, scale, or rotation.
Sourcepub const fn is_isolated(&self) -> bool
pub const fn is_isolated(&self) -> bool
Whether the node is drawn into its own composite (a visual field or hidden overflow). Presence decides, not values.
Sourcepub fn is_animated(&self) -> bool
pub fn is_animated(&self) -> bool
Whether the node, its subtree, or a shape in it changes over time.
Sourcepub fn walk(&self, visit: impl FnMut(&str, &Self))
pub fn walk(&self, visit: impl FnMut(&str, &Self))
Every node of the tree in preorder, with its path from the root.
Sourcepub fn without_px(&self, shorter_side: f32) -> Self
pub fn without_px(&self, shorter_side: f32) -> Self
The tree with every pixel length converted to a fraction of a picture shorter_side
pixels on its shorter side, so pixels and fractions interpolate as one kind.