Skip to main content

LayoutNode

Struct LayoutNode 

Source
pub struct LayoutNode {
Show 50 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 color: Option<Rgba>, pub line_height: Option<f32>, pub text_align: Option<TextAlign>, pub outline: Option<TextOutline>, 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 (display: flex, the default) or grid (display: grid). It is a container when it has children, a leaf when it has text or shape content, and empty otherwise (a spacer or a decoration). Per box, its background is drawn first, then its border, then its content. Boxes are drawn in document order; a reversed direction or a grid placement moves them, not their 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 and drawn in the style it inherits; \n starts a line. At most MAX_TEXT_CONTENT_BYTES bytes per value; may be empty. Its 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. Not on a box with text or shape content, as every container field.

§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 (between 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 (inline, for a grid) 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. A radius past half the box’s shorter side is capped.

§overflow: Option<Overflow>

Whether content past the padding box is drawn. Default visible.

§width: Option<Animated<LayoutLength>>

Border-box width. None is auto. Not on the root, as every item field.

§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; there is no auto.

§flex_grow: Option<Animated<f32>>

How much of a flex container’s free space the box takes. At least 0; default 0. Not in a grid, as every flex item field.

§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. Not in a flex container, as every grid item field.

§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.

§color: Option<Rgba>

Text color. Inherited; the root’s is white.

§line_height: Option<f32>

Baseline-to-baseline distance in font sizes, in [0.5, 3]. Inherited; the root’s is 1.2.

§text_align: Option<TextAlign>

How lines align within the content width. Inherited; the root’s is start.

§outline: Option<TextOutline>

A band around the glyphs; its width a fraction of the font size. Inherited; the root has none.

§opacity: Option<Animated<f32>>

Opacity of the box and everything in it, as one group, in 0..=1. Drawn after layout; it never moves a box.

§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

Source

pub const fn has_visual(&self) -> bool

Whether the node has a visual field: opacity, translate, scale, or rotation.

Source

pub const fn is_isolated(&self) -> bool

Whether the node is drawn into its own composite: it has a visual field or hidden overflow. Presence decides, not values.

Source

pub fn is_animated(&self) -> bool

Whether the node, its subtree, or a shape in it changes over time.

Source

pub fn walk(&self, visit: impl FnMut(&str, &Self))

Every node of the tree in preorder, with its path from the root.

Source

pub fn without_px(&self, shorter_side: f32) -> Self

The tree with every pixel length turned into a fraction of a picture shorter_side pixels on its shorter side: what a plan evaluates, so that pixels and fractions interpolate as one kind.

Trait Implementations§

Source§

impl Clone for LayoutNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LayoutNode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for LayoutNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LayoutNode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for LayoutNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LayoutNode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.