pub enum Sizing {
Fit,
Grow(f32),
Fixed(f32),
Percent(f32),
Calc(Calc),
}Expand description
How a node sizes one axis. A plain number converts to Fixed, so
.width(120.0) and .width(Sizing::Fixed(120.0)) are the same.
Variants§
Fit
Size to content.
Grow(f32)
Share leftover space, weighted by factor.
Fixed(f32)
Absolute logical pixels.
Percent(f32)
Fraction of the parent’s content box (0.0..=1.0).
Calc(Calc)
A size expression resolved against the parent’s content box, the
box a Percent takes its cut of: "clamp(400px, 80%, 1000px)"
(see crate::calc). Layout treats it as it treats a Percent:
nothing in the fit pass, its size once the parent’s is known, and
a parent that overflows shrinks it as it would one.
Implementations§
Source§impl Sizing
impl Sizing
Sourcepub fn describe(self) -> String
pub fn describe(self) -> String
The sizing the way a spec spells it — fit, grow(1), 120px,
50% — for a reader: the devtools’ inspector and a nodes() row.
Sourcepub fn amount(self) -> Option<f32>
pub fn amount(self) -> Option<f32>
The animatable number inside: a grow factor, a px size, a fraction.
None for Fit and a Calc, which have nothing to ease.
Sourcepub fn with_amount(self, v: f32) -> Self
pub fn with_amount(self, v: f32) -> Self
The same form with a different amount (Fit and a Calc stay).
Trait Implementations§
impl Copy for Sizing
Source§impl From<f32> for Sizing
A number is that many logical px, so .width(120.0) is
.width(Sizing::Fixed(120.0)), the way min_width(120.0) already read.
impl From<f32> for Sizing
A number is that many logical px, so .width(120.0) is
.width(Sizing::Fixed(120.0)), the way min_width(120.0) already read.