Skip to main content

Sizing

Enum Sizing 

Source
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

Source

pub const GROW: Sizing

Grow(1.0): an equal share of the leftover space, the weight nearly every grow declares.

Source§

impl Sizing

Source

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.

Source

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.

Source

pub fn with_amount(self, v: f32) -> Self

The same form with a different amount (Fit and a Calc stay).

Trait Implementations§

Source§

impl Clone for Sizing

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Sizing

Source§

impl Debug for Sizing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Sizing

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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.

Source§

fn from(px: f32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Sizing

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Sizing

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.