Skip to main content

Styled

Trait Styled 

Source
pub trait Styled: Sized {
Show 16 methods // Required method fn style_mut(&mut self) -> &mut Style; // Provided methods fn padding(self, p: f32) -> Self { ... } fn padding_xy(self, x: f32, y: f32) -> Self { ... } fn gap(self, g: f32) -> Self { ... } fn grow(self, g: f32) -> Self { ... } fn shrink(self, s: f32) -> Self { ... } fn width(self, w: f32) -> Self { ... } fn height(self, h: f32) -> Self { ... } fn min_width(self, w: f32) -> Self { ... } fn min_height(self, h: f32) -> Self { ... } fn max_height(self, h: f32) -> Self { ... } fn fill(self) -> Self { ... } fn fill_width(self) -> Self { ... } fn align(self, a: AlignItems) -> Self { ... } fn justify(self, j: JustifyContent) -> Self { ... } fn wrap(self) -> Self { ... }
}
Expand description

Flex-layout modifiers shared by every widget that owns a Style.

Required Methods§

Source

fn style_mut(&mut self) -> &mut Style

The taffy style the modifiers write; also an escape hatch for the rest.

Provided Methods§

Source

fn padding(self, p: f32) -> Self

Space between the box’s edges and its children on all sides, logical px.

Source

fn padding_xy(self, x: f32, y: f32) -> Self

Padding of x left and right and y top and bottom, logical px.

Source

fn gap(self, g: f32) -> Self

Space between children, along both axes, logical px.

Source

fn grow(self, g: f32) -> Self

Share of the parent’s spare main-axis space to take; 0 by default. The content still sets the minimum, so see fill around a scroll().

Source

fn shrink(self, s: f32) -> Self

How much to give up when the parent is too small; 1 by default, 0 keeps the size.

Source

fn width(self, w: f32) -> Self

Fixed width, logical px.

Source

fn height(self, h: f32) -> Self

Fixed height, logical px.

Source

fn min_width(self, w: f32) -> Self

Lower bound on the width, logical px; min_width(0.0) lets a flex child shrink below its content.

Source

fn min_height(self, h: f32) -> Self

Lower bound on the height, logical px; min_height(0.0) lets a flex child shrink below its content.

Source

fn max_height(self, h: f32) -> Self

Upper bound on the height, logical px, e.g. a scroll() that grows with its content up to a point.

Source

fn fill(self) -> Self

Takes the space left along the parent’s main axis, and no more: unlike grow(1.0), the content’s size doesn’t push the parent. Use it on every flex box between the window and a scroll(). In a row, siblings that all fill get equal widths, whatever their content.

Source

fn fill_width(self) -> Self

As wide as the parent’s content box, whatever the flex direction.

Source

fn align(self, a: AlignItems) -> Self

Places children on the cross axis: across a row, along a column.

Source

fn justify(self, j: JustifyContent) -> Self

Distributes children and spare space along the main axis.

Source

fn wrap(self) -> Self

Children that don’t fit start a new line instead of shrinking.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§