pub enum Length {
Fit,
Fill,
FillPortion(u16),
Shrink,
Fixed(f32),
Bounded {
bounds: Bounds,
sizing: Sizing,
},
Fluid(Constraint),
}Expand description
The strategy used to fill space in a specific dimension.
Variants§
Fit
Fill the minimum amount of space based on the intrinsic size of the element; normally defined by its contents.
This is the default sizing strategy of most widgets.
Fill
Fill all the remaining space.
FillPortion(u16)
Fill a portion of the remaining space relative to other elements.
Let’s say we have two elements: one with FillPortion(2) and one with
FillPortion(3). The first will get 2 portions of the available space,
while the second one would get 3.
Length::Fill is equivalent to Length::FillPortion(1).
Shrink
Fill the least amount of space; compressing contents if possible.
Fixed(f32)
Fill a fixed amount of space in pixels.
Bounded
Fields
Fluid(Constraint)
Fill the remaining space like Fill, but subject to a single
open-ended Constraint.
Implementations§
Source§impl Length
impl Length
Sourcepub fn min(self, min: impl Into<Pixels>) -> Self
pub fn min(self, min: impl Into<Pixels>) -> Self
Returns a new Bounded length with the given minimum bounds.
Sourcepub fn max(self, max: impl Into<Pixels>) -> Self
pub fn max(self, max: impl Into<Pixels>) -> Self
Returns a new Bounded length with the given maximum bounds.
Sourcepub fn fill_factor(&self) -> u16
pub fn fill_factor(&self) -> u16
Returns the fill factor of the Length.
The fill factor is a relative unit describing how much of the remaining space should be filled when compared to other elements. It is only meant to be used by layout engines.
Sourcepub fn is_fill(&self) -> bool
pub fn is_fill(&self) -> bool
Returns true if the Length is either Length::Fill or
Length::FillPortion.
Sourcepub fn stack(self, other: Length) -> Self
pub fn stack(self, other: Length) -> Self
Stacks the constraints of the current Length with the given one, if applicable.
Specifically, minimum constraints will be added together and accumulated.
You should use this when a container lays out multiple elements along a given axis and need to inherit their constraints in the main axis.
Sourcepub fn cross(self, other: Length) -> Self
pub fn cross(self, other: Length) -> Self
Crosses the constraints of the current Length with the given one, if applicable.
Specifically, minimum constraints will be compared and the maximum will be returned.
You should use this when a container lays out multiple elements along a given axis and need to inherit their constraints in the cross axis.