Skip to main content

WrapStyle

Struct WrapStyle 

Source
pub struct WrapStyle {
    pub axis: Axis,
    pub align: Align,
    pub column_gap: f32,
    pub row_gap: f32,
    pub columns: Option<usize>,
    pub rows: Option<usize>,
}
Expand description

Wrapping configuration for children along a main axis.

Fields§

§axis: Axis

Main axis along which children are placed.

§align: Align

Cross-axis alignment of the items within each line.

§column_gap: f32

Gap between items on the same line.

§row_gap: f32

Gap between wrapped lines.

§columns: Option<usize>

Explicit number of columns, overriding width-based wrapping.

§rows: Option<usize>

Explicit number of rows, overriding width-based wrapping.

Implementations§

Source§

impl WrapStyle

Source

pub fn new(axis: Axis) -> WrapStyle

Creates a wrapping style for the given main axis.

Source

pub fn main_gap(self) -> f32

Returns the gap used between items along the main axis.

Source

pub fn cross_gap(self) -> f32

Returns the gap used between wrapped lines.

Source

pub fn gap(self, gap: f32) -> WrapStyle

Sets both the column and row gap.

Source

pub fn column_gap(self, gap: f32) -> WrapStyle

Sets the gap between items on the same line.

Source

pub fn row_gap(self, gap: f32) -> WrapStyle

Sets the gap between wrapped lines.

Source

pub fn align(self, align: Align) -> WrapStyle

Sets the cross-axis alignment of items within a line.

Source

pub fn axis(self, axis: Axis) -> WrapStyle

Sets the main axis and reinterprets the main and cross gaps.

Source

pub fn columns(self, columns: usize) -> WrapStyle

Forces the layout to use exactly columns columns.

Values below one are clamped to one. For a horizontal axis this is the number of items per line; for a vertical axis it is the number of lines.

Source

pub fn rows(self, rows: usize) -> WrapStyle

Forces the layout to use exactly rows rows.

Values below one are clamped to one. For a vertical axis this is the number of items per line; for a horizontal axis it is the number of lines.

Source

pub fn clear_columns(self) -> WrapStyle

Removes the explicit column count and restores width-based wrapping.

Source

pub fn clear_rows(self) -> WrapStyle

Removes the explicit row count and restores width-based wrapping.

Source

pub fn items_per_line(self, count: usize) -> Option<usize>

Returns how many items fit on one line when an explicit count is set.

The count matching the main axis wins: columns for a horizontal axis and rows for a vertical axis. The other count is treated as the desired number of lines.

Source

pub fn lines(self, main_sizes: &[f32], avail_main: f32) -> Vec<(usize, usize)>

Splits main_sizes into lines using the explicit counts when present.

Trait Implementations§

Source§

impl Clone for WrapStyle

Source§

fn clone(&self) -> WrapStyle

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 WrapStyle

Source§

impl Debug for WrapStyle

Source§

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

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

impl Default for WrapStyle

Source§

fn default() -> WrapStyle

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

impl PartialEq for WrapStyle

Source§

fn eq(&self, other: &WrapStyle) -> 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 WrapStyle

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,