pub struct Dimension(/* private fields */);layout only.Expand description
Implementations§
Source§impl Dimension
impl Dimension
Sourcepub const fn length(val: f32) -> Dimension
pub const fn length(val: f32) -> Dimension
An absolute length in some abstract units. Users of Taffy may define what they correspond to in their application (pixels, logical pixels, mm, etc) as they see fit.
Sourcepub const fn percent(val: f32) -> Dimension
pub const fn percent(val: f32) -> Dimension
A percentage length relative to the size of the containing block.
NOTE: percentages are represented as a f32 value in the range [0.0, 1.0] NOT the range [0.0, 100.0]
Sourcepub const fn auto() -> Dimension
pub const fn auto() -> Dimension
The dimension should be automatically computed according to algorithm-specific rules regarding the default size of boxes.
Sourcepub const fn min_content() -> Dimension
pub const fn min_content() -> Dimension
The size should be the “min-content” size. This is the smallest size that can fit the item’s contents with ALL soft line-wrapping opportunities taken
Sourcepub const fn max_content() -> Dimension
pub const fn max_content() -> Dimension
The size should be the “max-content” size. This is the smallest size that can fit the item’s contents with NO soft line-wrapping opportunities taken
Sourcepub const fn fit_content() -> Dimension
pub const fn fit_content() -> Dimension
The size should be computed according to the “fit content” formula:
max(min_content, min(max_content, stretch))
where stretch is the size the box would take if it filled the available space
Sourcepub const fn fit_content_px(limit: f32) -> Dimension
pub const fn fit_content_px(limit: f32) -> Dimension
The size should be computed according to the “fit content” formula:
max(min_content, min(max_content, limit))
where limit is a LENGTH value
Sourcepub const fn stretch() -> Dimension
pub const fn stretch() -> Dimension
The size should be the “stretch-fit” size: the size the box would take if it filled the available space (https://www.w3.org/TR/css-sizing-4/#stretch-fit-sizing)
Sourcepub const fn content() -> Dimension
pub const fn content() -> Dimension
The size should be an automatic size based on the box’s content (https://www.w3.org/TR/css-flexbox-1/#valdef-flex-basis-content)
This keyword is only valid for flex-basis. In any other context it behaves as auto.
Sourcepub const fn fit_content_percent(limit: f32) -> Dimension
pub const fn fit_content_percent(limit: f32) -> Dimension
The size should be computed according to the “fit content” formula:
max(min_content, min(max_content, limit))
where limit is a PERCENTAGE value
Sourcepub const unsafe fn from_raw(val: CompactLength) -> Dimension
pub const unsafe fn from_raw(val: CompactLength) -> Dimension
Create a LengthPercentageAuto from a raw CompactLength.
§Safety
CompactLength must represent a valid variant for LengthPercentageAuto
Sourcepub const fn into_raw(self) -> CompactLength
pub const fn into_raw(self) -> CompactLength
Get the underlying CompactLength representation of the value
Sourcepub fn into_option(self) -> Option<f32>
Available on crate feature grid only.
pub fn into_option(self) -> Option<f32>
grid only.Get Length value if value is Length variant
Sourcepub fn is_sizing_keyword(self) -> bool
pub fn is_sizing_keyword(self) -> bool
Returns true if value is min-content, max-content, fit-content, fit-content(…), or stretch
Sourcepub fn is_stretch(self) -> bool
pub fn is_stretch(self) -> bool
Returns true if value is the stretch keyword
Sourcepub fn is_content(self) -> bool
pub fn is_content(self) -> bool
Returns true if value is the content keyword
Sourcepub fn value(self) -> f32
pub fn value(self) -> f32
Get the raw CompactLength value for non-calc variants that have a numeric parameter
Sourcepub fn expand(self) -> ExpandedDimension
pub fn expand(self) -> ExpandedDimension
Expand the compact representation into an ExpandedDimension enum.
This is useful when integrating with other libraries (e.g. for style inspection or
serialization) as it allows the value to be pattern-matched without having to work
with the raw CompactLength tagged-pointer representation directly.
Trait Implementations§
impl Copy for Dimension
Source§impl From<Dimension> for MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>
impl From<Dimension> for MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>
Source§fn from(
input: Dimension,
) -> MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>
fn from( input: Dimension, ) -> MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>
Source§impl From<ExpandedDimension> for Dimension
impl From<ExpandedDimension> for Dimension
Source§fn from(value: ExpandedDimension) -> Dimension
fn from(value: ExpandedDimension) -> Dimension
Source§impl From<LengthPercentage> for Dimension
impl From<LengthPercentage> for Dimension
Source§fn from(input: LengthPercentage) -> Dimension
fn from(input: LengthPercentage) -> Dimension
Source§impl From<LengthPercentageAuto> for Dimension
impl From<LengthPercentageAuto> for Dimension
Source§fn from(input: LengthPercentageAuto) -> Dimension
fn from(input: LengthPercentageAuto) -> Dimension
Source§impl FromLength for Dimension
impl FromLength for Dimension
Source§impl FromPercent for Dimension
impl FromPercent for Dimension
impl StructuralPartialEq for Dimension
Auto Trait Implementations§
impl !Send for Dimension
impl !Sync for Dimension
impl Freeze for Dimension
impl RefUnwindSafe for Dimension
impl Unpin for Dimension
impl UnsafeUnpin for Dimension
impl UnwindSafe for Dimension
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more