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: f32Non-negative share of remaining main-axis space; default 0.0.
flex_shrink: f32Non-negative shrink weight under deficit; default 0.0.
flex_basis: LengthPreferred 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
impl FlexItemStyle
Sourcepub fn new() -> Self
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);Sourcepub fn flex_grow(self, value: f32) -> Self
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);Sourcepub fn flex_shrink(self, value: f32) -> Self
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);Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
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));Sourcepub fn align_self(self, value: AlignItems) -> Self
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
impl Clone for FlexItemStyle
Source§fn clone(&self) -> FlexItemStyle
fn clone(&self) -> FlexItemStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more