Struct FlexItemStyle

Source
pub struct FlexItemStyle {
    pub flex_grow: f32,
    pub flex_shrink: f32,
    pub flex_basis: Length,
    pub align_self: Option<AlignItems>,
}
Expand description

Flex item style for a child of Row / Column (flex_grow, align_self, …).

§Examples

use ailloli_ui_core::style::{AlignItems, FlexItemStyle};
let item = FlexItemStyle::new().flex_grow(1.0).align_self(AlignItems::Center);
assert_eq!(item.flex_grow, 1.0);

Fields§

§flex_grow: f32

Non-negative share of remaining main-axis space; default 0.0.

§flex_shrink: f32

Non-negative shrink weight under deficit; default 0.0.

§flex_basis: Length

Preferred main-axis size before grow/shrink; default Length::Auto.

§align_self: Option<AlignItems>

Child-specific cross-axis alignment, or None to inherit the container.

Implementations§

Source§

impl FlexItemStyle

Source

pub fn new() -> Self

Creates a non-growing, non-shrinking item with automatic basis/alignment.

§Examples
use ailloli_ui_core::style::{FlexItemStyle, Length};
assert_eq!(FlexItemStyle::new().flex_basis, Length::Auto);
Source

pub fn flex_grow(self, value: f32) -> Self

Sets the grow factor, clamped to at least zero.

NaN and negative infinity become zero through floating-point max semantics; positive infinity remains infinite.

§Examples
use ailloli_ui_core::style::FlexItemStyle;
assert_eq!(FlexItemStyle::new().flex_grow(-1.0).flex_grow, 0.0);
Source

pub fn flex_shrink(self, value: f32) -> Self

Sets the shrink factor, clamped to at least zero.

NaN and negative infinity become zero through floating-point max semantics; positive infinity remains infinite.

§Examples
use ailloli_ui_core::style::FlexItemStyle;
assert_eq!(FlexItemStyle::new().flex_shrink(2.0).flex_shrink, 2.0);
Source

pub fn flex_basis(self, value: impl Into<Length>) -> Self

Replaces the preferred main-axis basis.

§Examples
use ailloli_ui_core::style::{FlexItemStyle, Length};
assert_eq!(FlexItemStyle::new().flex_basis(20.0).flex_basis, Length::Px(20.0));
Source

pub fn align_self(self, value: AlignItems) -> Self

Overrides the container’s cross-axis alignment for this child.

§Examples
use ailloli_ui_core::style::{AlignItems, FlexItemStyle};
assert_eq!(FlexItemStyle::new().align_self(AlignItems::End).align_self, Some(AlignItems::End));

Trait Implementations§

Source§

impl Clone for FlexItemStyle

Source§

fn clone(&self) -> FlexItemStyle

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FlexItemStyle

Source§

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

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

impl Default for FlexItemStyle

Source§

fn default() -> FlexItemStyle

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

impl PartialEq for FlexItemStyle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FlexItemStyle

Source§

impl StructuralPartialEq for FlexItemStyle

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> Same for T

Source§

type Output = T

Should always be Self
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.