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) -> Sizing
pub fn with_amount(self, v: f32) -> Sizing
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.
impl StructuralPartialEq for Sizing
Auto Trait Implementations§
impl Freeze for Sizing
impl RefUnwindSafe for Sizing
impl Send for Sizing
impl Sync for Sizing
impl Unpin for Sizing
impl UnsafeUnpin for Sizing
impl UnwindSafe for Sizing
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.