Skip to main content

LayoutStyle

Struct LayoutStyle 

Source
pub struct LayoutStyle {
Show 20 fields pub width: Length, pub height: Length, pub padding: Edges, pub margin: Edges, pub min_width: f32, pub max_width: f32, pub min_height: f32, pub max_height: f32, pub flex: f32, pub flex_shrink: f32, pub flex_basis: Option<Length>, pub align_self: Option<Align>, pub aspect_ratio: Option<f32>, pub indent_top: Option<f32>, pub indent_bottom: Option<f32>, pub indent_left: Option<f32>, pub indent_right: Option<f32>, pub position: Position, pub overflow: Overflow, pub hit_testable: bool,
}
Expand description

Layout properties for a single view.

Fields§

§width: Length

Requested width.

§height: Length

Requested height.

§padding: Edges

Space between the border and the content.

§margin: Edges

Space around the view outside its border.

§min_width: f32

Lower bound for the resolved width.

§max_width: f32

Upper bound for the resolved width.

§min_height: f32

Lower bound for the resolved height.

§max_height: f32

Upper bound for the resolved height.

§flex: f32

Grow weight along the parent’s main axis.

§flex_shrink: f32

Shrink weight along the parent’s main axis.

§flex_basis: Option<Length>

Optional basis used before flex distribution.

§align_self: Option<Align>

Cross-axis alignment override; None inherits from the container.

§aspect_ratio: Option<f32>

Preferred width-to-height ratio.

§indent_top: Option<f32>

Extra indent from the top edge of a docked container.

§indent_bottom: Option<f32>

Extra indent from the bottom edge of a docked container.

§indent_left: Option<f32>

Extra indent from the left edge of a docked container.

§indent_right: Option<f32>

Extra indent from the right edge of a docked container.

§position: Position

Positioning mode.

§overflow: Overflow

Overflow handling for content that exceeds the view.

§hit_testable: bool

Whether the view participates in hit testing.

Implementations§

Source§

impl LayoutStyle

Source

pub fn width(self, width: Length) -> LayoutStyle

Sets the requested width.

Source

pub fn height(self, height: Length) -> LayoutStyle

Sets the requested height.

Source

pub fn fit(self) -> LayoutStyle

Sets both dimensions to fit their content.

Source

pub fn hit_testable(self, on: bool) -> LayoutStyle

Enables or disables hit testing for this view.

Source

pub fn padding(self, padding: impl Into<Edges>) -> LayoutStyle

Sets the padding on every side.

Source

pub fn pad(self, padding: impl Into<Edges>) -> LayoutStyle

Source

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

Sets the horizontal and vertical padding.

Source

pub fn padding_x(self, x: f32) -> LayoutStyle

Sets the left and right padding.

Source

pub fn padding_y(self, y: f32) -> LayoutStyle

Sets the top and bottom padding.

Source

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

Sets the left padding.

Source

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

Sets the right padding.

Source

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

Sets the top padding.

Source

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

Sets the bottom padding.

Source

pub fn min_width(self, v: f32) -> LayoutStyle

Sets the minimum width.

Source

pub fn max_width(self, v: f32) -> LayoutStyle

Sets the maximum width.

Source

pub fn min_height(self, v: f32) -> LayoutStyle

Sets the minimum height.

Source

pub fn max_height(self, v: f32) -> LayoutStyle

Sets the maximum height.

Source

pub fn clamp_width(self, w: f32) -> f32

Clamps a width to this style’s minimum and maximum.

Source

pub fn clamp_height(self, h: f32) -> f32

Clamps a height to this style’s minimum and maximum.

Source

pub fn clamp_size(self, size: Size) -> Size

Clamps a size to this style’s minimum and maximum.

Source

pub fn margin(self, margin: impl Into<Edges>) -> LayoutStyle

Sets the margin on every side.

Source

pub fn margin_xy(self, x: f32, y: f32) -> LayoutStyle

Sets the horizontal and vertical margin.

Source

pub fn margin_x(self, x: f32) -> LayoutStyle

Sets the left and right margin.

Source

pub fn margin_y(self, y: f32) -> LayoutStyle

Sets the top and bottom margin.

Source

pub fn margin_left(self, v: f32) -> LayoutStyle

Sets the left margin.

Source

pub fn margin_right(self, v: f32) -> LayoutStyle

Sets the right margin.

Source

pub fn margin_top(self, v: f32) -> LayoutStyle

Sets the top margin.

Source

pub fn margin_bottom(self, v: f32) -> LayoutStyle

Sets the bottom margin.

Source

pub fn flex(self, weight: f32) -> LayoutStyle

Sets the flex grow weight.

Source

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

Sets the flex grow weight.

Source

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

Sets the flex shrink weight.

Source

pub fn flex_full( self, grow: f32, shrink: f32, basis: Option<Length>, ) -> LayoutStyle

Sets the grow weight, shrink weight, and basis together.

Source

pub fn flex_basis(self, basis: Option<Length>) -> LayoutStyle

Sets the flex basis.

Source

pub fn no_basis(self) -> LayoutStyle

Clears the flex basis.

Source

pub fn expand(self) -> LayoutStyle

Sets the flex grow weight to one.

Source

pub fn flex_weight(self) -> f32

Returns the sanitized flex grow weight.

Source

pub fn flex_grow_weight(self) -> f32

Returns the sanitized flex grow weight.

Source

pub fn flex_shrink_weight(self) -> f32

Returns the sanitized flex shrink weight.

Source

pub fn align_self(self, align: Option<Align>) -> LayoutStyle

Sets the cross-axis alignment override.

Source

pub fn align_self_value(self, align: Align) -> LayoutStyle

Sets an explicit cross-axis alignment override.

Source

pub fn auto_align(self) -> LayoutStyle

Clears the alignment override so the container’s alignment is used.

Source

pub fn effective_align(self, container: Align) -> Align

Resolves the effective alignment against a container alignment.

Source

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

Sets the aspect ratio, ignoring invalid values.

Source

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

Sets the aspect ratio to ratio.

Source

pub fn no_aspect(self) -> LayoutStyle

Clears the aspect ratio.

Source

pub fn position(self, position: Position) -> LayoutStyle

Sets the positioning mode.

Source

pub fn absolute(self) -> LayoutStyle

Positions the view absolutely with auto insets.

Source

pub fn absolute_at(self, left: f32, top: f32) -> LayoutStyle

Positions the view absolutely at the given left and top offsets.

Source

pub fn absolute_inset(self, inset: Inset) -> LayoutStyle

Positions the view absolutely with the given insets.

Source

pub fn is_absolute(self) -> bool

Returns true if the view is positioned absolutely.

Source

pub fn absolute_inset_of(self) -> Option<Inset>

Returns the absolute insets, or None for flow positioning.

Source

pub fn margin_main(self, axis: Axis) -> f32

Returns the horizontal or vertical margin for the given axis.

Source

pub fn margin_cross(self, axis: Axis) -> f32

Returns the cross-axis margin for the given main axis.

Source

pub fn apply_aspect( self, w: f32, h: f32, w_auto: bool, h_auto: bool, ) -> (f32, f32)

Applies the aspect ratio to the size, deriving either auto axis.

Source

pub fn outer_size(self, inner: Size) -> Size

Expands an inner size by this style’s margins.

Source

pub fn min_main(self, axis: Axis) -> f32

Returns the minimum size along the given axis.

Source

pub fn max_main(self, axis: Axis) -> f32

Returns the maximum size along the given axis.

Source

pub fn clamp_main(self, value: f32, axis: Axis) -> f32

Clamps a value to the minimum and maximum along the given axis.

Source

pub fn overflow(self, overflow: Overflow) -> LayoutStyle

Sets the overflow behavior.

Source

pub fn indent_top(self, v: f32) -> LayoutStyle

Sets the top indent.

Source

pub fn indent_bottom(self, v: f32) -> LayoutStyle

Sets the bottom indent.

Source

pub fn indent_left(self, v: f32) -> LayoutStyle

Sets the left indent.

Source

pub fn indent_right(self, v: f32) -> LayoutStyle

Sets the right indent.

Source

pub fn clear_indent_top(self) -> LayoutStyle

Clears the top indent.

Source

pub fn clear_indent_bottom(self) -> LayoutStyle

Clears the bottom indent.

Source

pub fn clear_indent_left(self) -> LayoutStyle

Clears the left indent.

Source

pub fn clear_indent_right(self) -> LayoutStyle

Clears the right indent.

Source

pub fn clear_indents(self) -> LayoutStyle

Clears every indent.

Source

pub fn indent(self, indents: Indents) -> LayoutStyle

Applies the set sides from indents.

Source

pub fn indent_all(self, v: f32) -> LayoutStyle

Sets the same indent on every side.

Source

pub fn indent_xy(self, x: f32, y: f32) -> LayoutStyle

Sets the horizontal and vertical indents.

Source

pub fn indent_axes(self, horizontal: f32, vertical: f32) -> LayoutStyle

Sets the horizontal and vertical indents.

Source

pub fn indent_main_start(self, axis: Axis) -> Option<f32>

Returns the indent at the main-axis start for the given axis.

Source

pub fn indent_main_end(self, axis: Axis) -> Option<f32>

Returns the indent at the main-axis end for the given axis.

Source

pub fn indent_cross_start(self, axis: Axis) -> Option<f32>

Returns the indent at the cross-axis start for the given main axis.

Source

pub fn indent_cross_end(self, axis: Axis) -> Option<f32>

Returns the indent at the cross-axis end for the given main axis.

Source

pub fn indents(self) -> Indents

Collects the four optional indents.

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

Source§

impl Debug for LayoutStyle

Source§

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

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

impl Default for LayoutStyle

Source§

fn default() -> LayoutStyle

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

impl PartialEq for LayoutStyle

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LayoutStyle

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

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

impl<T> ViewState for T
where T: Default + 'static,