Enum vizia_core::layout::Units
pub enum Units {
Pixels(f32),
Percentage(f32),
Stretch(f32),
Auto,
}
Expand description
Units which describe spacing and size.
Variants§
Pixels(f32)
A number of logical pixels.
Percentage(f32)
A percentage of the parent dimension.
A percentage of the parent’s width when applied to left, width, right properties. A percentage of the parent’s height when applied to top, height, bottom properties.
Stretch(f32)
A factor of the remaining free space.
The remaining free space is the parent space minus the space and size of any fixed-size nodes in that axis. The remaining free space is then shared between any stretch nodes based on the ratio of their stretch factors.
For example, given two stretch nodes with factors of 1.0 and 2.0 respectively. The first will occupy 1/3 of the remaining free space while the second will occupy 2/3 of the remaining free space.
Auto
Automatically determine the value.
When applied to space (left, right, top, bottom) the spacing may be overridden by the parent’s child-space on the same side.
For example, a node in a column with Auto
left space, with a parent which has Pixel(100.0) child-left space, will get a left spacing of 100px.
When applied to size (width, height) Auto will either size to fit its children, or if there are no children
the node will be sized based on the content_size
property of the node.
Implementations§
§impl Units
impl Units
pub fn to_px(&self, parent_value: f32, default: f32) -> f32
pub fn to_px(&self, parent_value: f32, default: f32) -> f32
Returns the units converted to pixels or a provided default.
pub fn to_px_clamped( &self, parent_value: f32, default: f32, min: Units, max: Units, ) -> f32
pub fn clamp(&self, min: Units, max: Units) -> Units
pub fn is_percentage(&self) -> bool
pub fn is_percentage(&self) -> bool
Returns true if the value is a percentage.
pub fn is_stretch(&self) -> bool
pub fn is_stretch(&self) -> bool
Returns true if the value is a stretch factor.
Trait Implementations§
§impl From<Units> for LengthOrPercentage
impl From<Units> for LengthOrPercentage
§fn from(units: Units) -> LengthOrPercentage
fn from(units: Units) -> LengthOrPercentage
impl Copy for Units
impl StructuralPartialEq for Units
Auto Trait Implementations§
impl Freeze for Units
impl RefUnwindSafe for Units
impl Send for Units
impl Sync for Units
impl Unpin for Units
impl UnwindSafe for Units
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> 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.