pub struct LayoutStyle { /* private fields */ }Implementations§
Source§impl LayoutStyle
impl LayoutStyle
Sourcepub fn new() -> LayoutStyle
pub fn new() -> LayoutStyle
A block box, as in CSS: children stack vertically and the flex properties do nothing.
Worth saying out loud because the ones that do nothing do it silently. gap,
justify_content and align_items all belong to
flex layout, so on a box that never called flex_row or
flex_column they are accepted and ignored — a row written without
flex_row comes out as a column, and the reading on screen is not “that row is a column” but
“why is this panel twice as tall as it should be”.
Sourcepub fn flex_row(self) -> LayoutStyle
pub fn flex_row(self) -> LayoutStyle
A flex row along the inline axis: items run left-to-right under Direction::Ltr and right-to-left
under Direction::Rtl, the way flex-direction: row follows dir on the web. Use
flex_row_reverse for a row that is reversed in both directions.
Sourcepub fn flex_row_reverse(self) -> LayoutStyle
pub fn flex_row_reverse(self) -> LayoutStyle
pub fn flex_column(self) -> LayoutStyle
pub fn flex_wrap(self) -> LayoutStyle
Sourcepub fn display_none(self) -> LayoutStyle
pub fn display_none(self) -> LayoutStyle
Declares the node out of layout flow (no space, not laid out) as part of its own style — e.g. a tab panel that should start inactive, as opposed to the out-of-band LayoutEngine::set_display.
Sourcepub fn absolute_fill(self) -> LayoutStyle
pub fn absolute_fill(self) -> LayoutStyle
Takes the node out of normal flow (position: absolute) with all four insets pinned to 0, so it
fills its containing block without affecting sibling layout — used by overlay to cover the
viewport. Combine with flex_column/alignment to position the overlay’s content within the layer.
Sourcepub fn absolute(self) -> LayoutStyle
pub fn absolute(self) -> LayoutStyle
Takes the node out of normal flow (position: absolute) leaving every inset at auto, so the
edges it is pinned by are exactly the ones the caller names. absolute_fill
is this plus all four insets at 0; a floating panel wants three of them and its own size on the
fourth axis, which pinning everything would override.
Sourcepub fn inset_top(self, px: f32) -> LayoutStyle
pub fn inset_top(self, px: f32) -> LayoutStyle
Inset from the top edge, for a node already taken out of flow. Physical, not logical: top does not
swap under RTL the way inset_start does.
Sourcepub fn inset_bottom(self, px: f32) -> LayoutStyle
pub fn inset_bottom(self, px: f32) -> LayoutStyle
Inset from the bottom edge, for a node already taken out of flow.
Sourcepub fn width_px(&self) -> Option<f32>
pub fn width_px(&self) -> Option<f32>
The node’s width in pixels if it is a definite length, else None (e.g. percent or auto).
Lets widgets with an intrinsic size (e.g. <svg>/<img>) inspect a caller-supplied width before registering their layout leaf.
Sourcepub fn is_width_auto(&self) -> bool
pub fn is_width_auto(&self) -> bool
True when width was left at its default, which taffy also treats as auto.
pub fn width(self, dim: impl Into<SizeDimension>) -> LayoutStyle
Sourcepub fn height_px(&self) -> Option<f32>
pub fn height_px(&self) -> Option<f32>
The node’s height in pixels if it is a definite length, else None (e.g. percent or auto).
Sourcepub fn is_height_auto(&self) -> bool
pub fn is_height_auto(&self) -> bool
True when height was left at its default, which taffy also treats as auto.
pub fn height(self, dim: impl Into<SizeDimension>) -> LayoutStyle
pub fn min_width(self, dim: impl Into<SizeDimension>) -> LayoutStyle
pub fn min_height(self, dim: impl Into<SizeDimension>) -> LayoutStyle
Sourcepub fn max_width_px(&self) -> Option<f32>
pub fn max_width_px(&self) -> Option<f32>
The node’s max-width in pixels if it is a definite length, else None
(e.g. percent or unset). Used by the layout pass to pin a resolved width.
pub fn max_width(self, dim: impl Into<SizeDimension>) -> LayoutStyle
pub fn max_height(self, dim: impl Into<SizeDimension>) -> LayoutStyle
pub fn flex_grow(self, grow: f32) -> LayoutStyle
pub fn flex_shrink(self, shrink: f32) -> LayoutStyle
pub fn flex_basis(self, dim: impl Into<SizeDimension>) -> LayoutStyle
pub fn padding_all(self, px: f32) -> LayoutStyle
pub fn padding_horizontal(self, px: f32) -> LayoutStyle
pub fn padding_vertical(self, px: f32) -> LayoutStyle
pub fn padding_top(self, px: f32) -> LayoutStyle
pub fn padding_bottom(self, px: f32) -> LayoutStyle
pub fn padding_left(self, px: f32) -> LayoutStyle
pub fn padding_right(self, px: f32) -> LayoutStyle
Sourcepub fn padding_start(self, px: f32) -> LayoutStyle
pub fn padding_start(self, px: f32) -> LayoutStyle
Padding on the edge the text starts from — left under Direction::Ltr, right under
Direction::Rtl.
Sourcepub fn padding_end(self, px: f32) -> LayoutStyle
pub fn padding_end(self, px: f32) -> LayoutStyle
Padding on the edge the text runs towards — right under Direction::Ltr, left under
Direction::Rtl.
Sourcepub fn margin(self, m: Margin) -> LayoutStyle
pub fn margin(self, m: Margin) -> LayoutStyle
All four margins at once, named by axis rather than by side so they follow the writing direction.
Sourcepub fn margin_block_start(self, px: f32) -> LayoutStyle
pub fn margin_block_start(self, px: f32) -> LayoutStyle
Margin on the edge the block axis starts from — the top, in every writing mode this engine supports.
Sourcepub fn margin_block_end(self, px: f32) -> LayoutStyle
pub fn margin_block_end(self, px: f32) -> LayoutStyle
Margin on the edge the block axis ends at — the bottom.
Sourcepub fn margin_inline_start(self, px: f32) -> LayoutStyle
pub fn margin_inline_start(self, px: f32) -> LayoutStyle
Margin on the edge the text starts from — left under Direction::Ltr, right under
Direction::Rtl.
Sourcepub fn margin_inline_end(self, px: f32) -> LayoutStyle
pub fn margin_inline_end(self, px: f32) -> LayoutStyle
Margin on the edge the text runs towards — right under Direction::Ltr, left under
Direction::Rtl.
Sourcepub fn margin_from_left(self, px: f32) -> LayoutStyle
pub fn margin_from_left(self, px: f32) -> LayoutStyle
A margin from the viewport’s physical left edge, which does not follow the writing direction.
The one place that is right: placing an in-flow box at an x already worked out in physical viewport
coordinates — a dropdown panel under its trigger, a picker under its anchor. Those come from a
laid-out rect, so mirroring them under RTL would put the panel on the wrong side of the screen. For a
margin that is part of a box’s own spacing, use margin_inline_start.
Sourcepub fn inset_start(self, px: f32) -> LayoutStyle
pub fn inset_start(self, px: f32) -> LayoutStyle
Inset from the edge the text starts from, for a node already taken out of flow (see
absolute_fill); ignored on an in-flow node, as inset is in CSS.
Sourcepub fn inset_end(self, px: f32) -> LayoutStyle
pub fn inset_end(self, px: f32) -> LayoutStyle
Inset from the edge the text runs towards, for a node already taken out of flow.
pub fn gap(self, px: f32) -> LayoutStyle
pub fn gap_x(self, px: f32) -> LayoutStyle
pub fn gap_y(self, px: f32) -> LayoutStyle
pub fn align_items(self, value: AlignItems) -> LayoutStyle
pub fn align_self_stretch(self) -> LayoutStyle
Sourcepub fn align_self_center(self) -> LayoutStyle
pub fn align_self_center(self) -> LayoutStyle
Overrides the parent’s align_items for this child, centering it on the cross axis instead of
stretching — so a fixed-size child (e.g. a square icon chip) keeps its size and stays centered.
Sourcepub fn align_self_start(self) -> LayoutStyle
pub fn align_self_start(self) -> LayoutStyle
Aligns this child to the start of the cross axis, overriding the parent’s align_items.
Sourcepub fn align_self_end(self) -> LayoutStyle
pub fn align_self_end(self) -> LayoutStyle
Aligns this child to the end of the cross axis, overriding the parent’s align_items.
pub fn justify_content(self, value: AlignContent) -> LayoutStyle
pub fn display_grid(self) -> LayoutStyle
pub fn grid_template_columns(self, tracks: Vec<TemplateTrack>) -> LayoutStyle
pub fn grid_column_span(self, count: u16) -> LayoutStyle
pub fn grid_row_span(self, count: u16) -> LayoutStyle
pub fn aspect_ratio(self, ratio: f32) -> LayoutStyle
Trait Implementations§
Source§impl Clone for LayoutStyle
impl Clone for LayoutStyle
Source§fn clone(&self) -> LayoutStyle
fn clone(&self) -> LayoutStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more