Enum zng_layout::unit::Length
source · 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: Into<Length>> AddAssign<L> for Length
impl<L: Into<Length>> 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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<F: Into<Factor>> DivAssign<F> for Length
impl<F: Into<Factor>> DivAssign<F> for Length
source§fn div_assign(&mut self, rhs: F)
fn div_assign(&mut self, rhs: F)
/=
operation. Read moresource§impl From<FactorPercent> for Length
impl From<FactorPercent> for Length
source§fn from(percent: FactorPercent) -> Self
fn from(percent: FactorPercent) -> Self
Conversion to Length::Factor
source§impl From<Length> for GridSpacing
impl From<Length> for GridSpacing
source§impl IntoVar<GridSpacing> for Length
impl IntoVar<GridSpacing> for Length
source§impl IntoVar<Length> for FactorPercent
impl IntoVar<Length> for FactorPercent
source§impl IntoVar<SideOffsets> for Length
impl IntoVar<SideOffsets> for Length
source§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: Into<Factor>> MulAssign<F> for Length
impl<F: Into<Factor>> MulAssign<F> for Length
source§fn mul_assign(&mut self, rhs: F)
fn mul_assign(&mut self, rhs: F)
*=
operation. Read moresource§impl<L: Into<Length>> SubAssign<L> for Length
impl<L: Into<Length>> 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
source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
self
-> to
by step
.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§
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
)§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> 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