Skip to main content

LayoutStyle

Struct LayoutStyle 

Source
pub struct LayoutStyle { /* private fields */ }

Implementations§

Source§

impl LayoutStyle

Source

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

Source

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.

Source

pub fn flex_row_reverse(self) -> LayoutStyle

A flex row laid out against the writing direction, unconditionally. Unlike flex_row this is a physical choice and does not flip with Direction.

Source

pub fn flex_column(self) -> LayoutStyle

Source

pub fn flex_wrap(self) -> LayoutStyle

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn inset_bottom(self, px: f32) -> LayoutStyle

Inset from the bottom edge, for a node already taken out of flow.

Source

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.

Source

pub fn is_width_auto(&self) -> bool

True when width was left at its default, which taffy also treats as auto.

Source

pub fn width(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

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

Source

pub fn is_height_auto(&self) -> bool

True when height was left at its default, which taffy also treats as auto.

Source

pub fn height(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

pub fn min_width(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

pub fn min_height(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

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.

Source

pub fn max_width(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

pub fn max_height(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

pub fn flex_grow(self, grow: f32) -> LayoutStyle

Source

pub fn flex_shrink(self, shrink: f32) -> LayoutStyle

Source

pub fn flex_basis(self, dim: impl Into<SizeDimension>) -> LayoutStyle

Source

pub fn padding_all(self, px: f32) -> LayoutStyle

Source

pub fn padding_horizontal(self, px: f32) -> LayoutStyle

Source

pub fn padding_vertical(self, px: f32) -> LayoutStyle

Source

pub fn padding_top(self, px: f32) -> LayoutStyle

Source

pub fn padding_bottom(self, px: f32) -> LayoutStyle

Source

pub fn padding_left(self, px: f32) -> LayoutStyle

Source

pub fn padding_right(self, px: f32) -> LayoutStyle

Source

pub fn padding_start(self, px: f32) -> LayoutStyle

Padding on the edge the text starts from — left under Direction::Ltr, right under Direction::Rtl.

Source

pub fn padding_end(self, px: f32) -> LayoutStyle

Padding on the edge the text runs towards — right under Direction::Ltr, left under Direction::Rtl.

Source

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.

Source

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.

Source

pub fn margin_block_end(self, px: f32) -> LayoutStyle

Margin on the edge the block axis ends at — the bottom.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn inset_end(self, px: f32) -> LayoutStyle

Inset from the edge the text runs towards, for a node already taken out of flow.

Source

pub fn gap(self, px: f32) -> LayoutStyle

Source

pub fn gap_x(self, px: f32) -> LayoutStyle

Source

pub fn gap_y(self, px: f32) -> LayoutStyle

Source

pub fn align_items(self, value: AlignItems) -> LayoutStyle

Source

pub fn align_self_stretch(self) -> LayoutStyle

Source

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.

Source

pub fn align_self_start(self) -> LayoutStyle

Aligns this child to the start of the cross axis, overriding the parent’s align_items.

Source

pub fn align_self_end(self) -> LayoutStyle

Aligns this child to the end of the cross axis, overriding the parent’s align_items.

Source

pub fn justify_content(self, value: AlignContent) -> LayoutStyle

Source

pub fn display_grid(self) -> LayoutStyle

Source

pub fn grid_template_columns(self, tracks: Vec<TemplateTrack>) -> LayoutStyle

Source

pub fn grid_column_span(self, count: u16) -> LayoutStyle

Source

pub fn grid_row_span(self, count: u16) -> LayoutStyle

Source

pub fn aspect_ratio(self, ratio: f32) -> LayoutStyle

Trait Implementations§

Source§

impl Clone for LayoutStyle

Source§

fn clone(&self) -> LayoutStyle

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 Default for LayoutStyle

Source§

fn default() -> LayoutStyle

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

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.