pub enum Length {
}
Expand description
Variants§
Default
The default (initial) value.
Dip(Dip)
The exact length in device independent units.
Px(Px)
The exact length in device pixel units.
Pt(f32)
The exact length in font points.
Factor(Factor)
Relative to the fill length.
Leftover(Factor)
Relative to the leftover fill length.
Em(Factor)
Relative to the font-size of the widget.
RootEm(Factor)
Relative to the font-size of the root widget.
ViewportWidth(Factor)
Relative to the width of the nearest viewport ancestor.
ViewportHeight(Factor)
Relative to the height of the nearest viewport ancestor.
ViewportMin(Factor)
Relative to the smallest of the nearest viewport ancestor’s dimensions.
ViewportMax(Factor)
Relative to the smallest of the nearest viewport ancestor’s dimensions.
DipF32(f32)
The exact length in device independent units, defined using a f32
value.
This value will be rounded to the nearest pixel after layout, but it will be used as is in the evaluation of length expressions.
PxF32(f32)
The exact length in device pixel units, defined using a f32
value.
This value will be rounded to the nearest pixel after layout, but it will be used as is in the evaluation of length expressions.
Expr(Box<LengthExpr>)
Expression.
Implementations§
source§impl Length
impl Length
sourcepub fn max(&self, other: impl Into<Length>) -> Length
pub fn max(&self, other: impl Into<Length>) -> Length
Returns a length that resolves to the maximum layout length between self
and other
.
sourcepub fn min(&self, other: impl Into<Length>) -> Length
pub fn min(&self, other: impl Into<Length>) -> Length
Returns a length that resolves to the minimum layout length between self
and other
.
sourcepub fn clamp(&self, min: impl Into<Length>, max: impl Into<Length>) -> Length
pub fn clamp(&self, min: impl Into<Length>, max: impl Into<Length>) -> Length
Returns a length that constraints the computed layout length between min
and max
.
sourcepub fn is_zero(&self) -> Option<bool>
pub fn is_zero(&self) -> Option<bool>
If this length is zero in any finite layout context.
Returns None
if the value depends on the default value.
sourcepub fn pt_to_px(pt: f32, scale_factor: Factor) -> Px
pub fn pt_to_px(pt: f32, scale_factor: Factor) -> Px
Convert a pt
unit value to Px
given a scale_factor
.
sourcepub fn pt_to_px_f32(pt: f32, scale_factor: Factor) -> f32
pub fn pt_to_px_f32(pt: f32, scale_factor: Factor) -> f32
Same operation as pt_to_px
but without rounding to nearest pixel.
sourcepub fn px_to_pt(px: Px, scale_factor: Factor) -> f32
pub fn px_to_pt(px: Px, scale_factor: Factor) -> f32
Convert a Px
unit value to a Pt
value given a scale_factor
.
sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
If is Length::Default
.
sourcepub fn replace_default(&mut self, overwrite: &Length)
pub fn replace_default(&mut self, overwrite: &Length)
Replaces self
with overwrite
if self
is Default
.
sourcepub fn memory_used(&self) -> ByteLength
pub fn memory_used(&self) -> ByteLength
Gets the total memory allocated by this length.
This includes the sum of all nested Length::Expr
heap memory.
sourcepub fn heap_memory_used(&self) -> ByteLength
pub fn heap_memory_used(&self) -> ByteLength
Sum total memory used in nested Length::Expr
heap memory.
Trait Implementations§
source§impl<L> AddAssign<L> for Length
impl<L> AddAssign<L> for Length
source§fn add_assign(&mut self, rhs: L)
fn add_assign(&mut self, rhs: L)
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Length
impl<'de> Deserialize<'de> for Length
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Length, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Length, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<F> DivAssign<F> for Length
impl<F> DivAssign<F> for Length
source§fn div_assign(&mut self, rhs: F)
fn div_assign(&mut self, rhs: F)
/=
operation. Read moresource§impl From<&Length> for WidgetLength
impl From<&Length> for WidgetLength
source§fn from(value: &Length) -> WidgetLength
fn from(value: &Length) -> WidgetLength
source§impl From<FactorPercent> for Length
impl From<FactorPercent> for Length
source§fn from(percent: FactorPercent) -> Length
fn from(percent: FactorPercent) -> Length
Conversion to Length::Factor
source§impl From<Length> for CornerRadius
impl From<Length> for CornerRadius
source§fn from(all: Length) -> CornerRadius
fn from(all: Length) -> CornerRadius
All corners same length.
source§impl From<Length> for GradientRadius
impl From<Length> for GradientRadius
source§fn from(radius: Length) -> GradientRadius
fn from(radius: Length) -> GradientRadius
Ellipse GradientRadius::farthest_corner
.
source§impl From<Length> for GradientStop
impl From<Length> for GradientStop
source§fn from(color_hint: Length) -> GradientStop
fn from(color_hint: Length) -> GradientStop
source§impl From<Length> for GridSpacing
impl From<Length> for GridSpacing
source§fn from(all: Length) -> GridSpacing
fn from(all: Length) -> GridSpacing
Same spacing for both columns and rows.
source§impl From<Length> for SideOffsets
impl From<Length> for SideOffsets
source§fn from(all: Length) -> SideOffsets
fn from(all: Length) -> SideOffsets
All sides equal.
source§impl IntoVar<CornerRadius> for Length
impl IntoVar<CornerRadius> for Length
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GradientRadius> for Length
impl IntoVar<GradientRadius> for Length
source§fn into_var(self) -> <Length as IntoVar<GradientRadius>>::Var
fn into_var(self) -> <Length as IntoVar<GradientRadius>>::Var
Ellipse GradientRadius::farthest_corner
.
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GradientStop> for Length
impl IntoVar<GradientStop> for Length
source§fn into_var(self) -> <Length as IntoVar<GradientStop>>::Var
fn into_var(self) -> <Length as IntoVar<GradientStop>>::Var
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<GridSpacing> for Length
impl IntoVar<GridSpacing> for Length
source§fn into_var(self) -> <Length as IntoVar<GridSpacing>>::Var
fn into_var(self) -> <Length as IntoVar<GridSpacing>>::Var
Same spacing for both columns and rows.
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<Length> for FactorPercent
impl IntoVar<Length> for FactorPercent
source§impl IntoVar<SideOffsets> for Length
impl IntoVar<SideOffsets> for Length
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl Layout1d for Length
impl Layout1d for Length
source§fn layout_dft(&self, axis: LayoutAxis, default: Px) -> Px
fn layout_dft(&self, axis: LayoutAxis, default: Px) -> Px
LAYOUT
context with default
.source§fn layout_f32_dft(&self, axis: LayoutAxis, default: f32) -> f32
fn layout_f32_dft(&self, axis: LayoutAxis, default: f32) -> f32
LAYOUT
context with default
.source§fn affect_mask(&self) -> LayoutMask
fn affect_mask(&self) -> LayoutMask
LayoutMask
that flags all contextual values that affect the result of layout
.source§fn layout(&self, axis: LayoutAxis) -> Px
fn layout(&self, axis: LayoutAxis) -> Px
LAYOUT
context.source§fn layout_dft_x(&self, default: Px) -> Px
fn layout_dft_x(&self, default: Px) -> Px
LAYOUT
context x axis with default
.source§fn layout_dft_y(&self, default: Px) -> Px
fn layout_dft_y(&self, default: Px) -> Px
LAYOUT
context y axis with default
.source§fn layout_dft_z(&self, default: Px) -> Px
fn layout_dft_z(&self, default: Px) -> Px
LAYOUT
context z axis with default
.source§fn layout_f32(&self, axis: LayoutAxis) -> f32
fn layout_f32(&self, axis: LayoutAxis) -> f32
LAYOUT
context.source§fn layout_f32_x(&self) -> f32
fn layout_f32_x(&self) -> f32
LAYOUT
context x axis.source§fn layout_f32_y(&self) -> f32
fn layout_f32_y(&self) -> f32
LAYOUT
context y axis.source§fn layout_f32_z(&self) -> f32
fn layout_f32_z(&self) -> f32
LAYOUT
context z axis.source§fn layout_f32_dft_x(&self, default: f32) -> f32
fn layout_f32_dft_x(&self, default: f32) -> f32
LAYOUT
context x axis with default
.source§impl<F> MulAssign<F> for Length
impl<F> MulAssign<F> for Length
source§fn mul_assign(&mut self, rhs: F)
fn mul_assign(&mut self, rhs: F)
*=
operation. Read moresource§impl SelectorValue for Length
impl SelectorValue for Length
source§impl Serialize for Length
impl Serialize for Length
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl<L> SubAssign<L> for Length
impl<L> SubAssign<L> for Length
source§fn sub_assign(&mut self, rhs: L)
fn sub_assign(&mut self, rhs: L)
-=
operation. Read moresource§impl Transitionable for Length
impl Transitionable for Length
impl IntoValue<CornerRadius> for Length
impl IntoValue<GradientRadius> for Length
impl IntoValue<GradientStop> for Length
impl IntoValue<GridSpacing> for Length
impl IntoValue<Length> for Dip
impl IntoValue<Length> for Factor
impl IntoValue<Length> for FactorPercent
impl IntoValue<Length> for Px
impl IntoValue<Length> for f32
impl IntoValue<Length> for i32
impl IntoValue<Point> for Length
impl IntoValue<SideOffsets> for Length
impl IntoValue<Size> for Length
impl IntoValue<Vector> for Length
Auto Trait Implementations§
impl Freeze for Length
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnwindSafe for Length
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> DataNoteValue for T
impl<T> DataNoteValue for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.