pub enum Size {
Pixel(i32),
Ratio(f32),
}
Expand description
Helper enum to represent a size which can be an absolute pixel value or a relative ratio value
Variants§
Pixel(i32)
Size in pixels (ie. 10 means 10 pixels)
Ratio(f32)
Relative size as a ratio between 0 to 1 (ie. 0.5 means 50%)
Implementations§
Source§impl Size
impl Size
Sourcepub fn into_absolute(self, whole: u32) -> i32
pub fn into_absolute(self, whole: u32) -> i32
Turn the size into an absolute value.
A pixel value will be returned as is, a ratio
value will be multiplied by the provided
whole
to calculate the absolute value.
§Hint
A negative ratio value will be converted into an absolute number before being applied.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Size
impl<'de> Deserialize<'de> for Size
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
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
Mutably borrows from an owned value. Read more