pub struct SizingDimensions {
pub min: PositiveFinite,
pub preferred: PreferredSize,
pub max: Positive,
}Expand description
Represents the sizing information for a UI element used while calculating layout.
Fields§
§min: PositiveFinite§preferred: PreferredSize§max: PositiveImplementations§
Source§impl SizingDimensions
impl SizingDimensions
Sourcepub fn is_fixed(&self) -> bool
pub fn is_fixed(&self) -> bool
True if the sizing is fixed and layout calculations will not change it.
Sourcepub fn is_growable(&self) -> bool
pub fn is_growable(&self) -> bool
True if the sizing is growable and can expand to fill available space.
Sourcepub fn is_shrinkable(&self) -> bool
pub fn is_shrinkable(&self) -> bool
True if the sizing is shrinkable and can be reduced in size when overflowing its container.
Sourcepub fn get_grow_factor(&self) -> f64
pub fn get_grow_factor(&self) -> f64
Returns the growth factor for the dimension.
Sourcepub fn clamped(&self, value: f64) -> f64
pub fn clamped(&self, value: f64) -> f64
Returns the dimension value clamped between min and max.
let sized = SizingDimensions {
min: PositiveFinite::new(100.0).unwrap(),
preferred: PreferredSize::Fixed(PositiveFinite::new(200.0).unwrap()),
max: Positive::new(300.0).unwrap(),
};
assert_eq!(sized.clamped(250.0), 250.0);
assert_eq!(sized.clamped(50.0), 100.0);
assert_eq!(sized.clamped(350.0), 300.0);
assert_eq!(sized.clamped(f64::NAN), 100.0); // NaN defaults to min
assert_eq!(sized.clamped(f64::INFINITY), 300.0);
assert_eq!(sized.clamped(f64::NEG_INFINITY), 100.0);pub fn max(&self) -> f64
pub fn min(&self) -> f64
Trait Implementations§
Source§impl Clone for SizingDimensions
impl Clone for SizingDimensions
Source§fn clone(&self) -> SizingDimensions
fn clone(&self) -> SizingDimensions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SizingDimensions
Source§impl Debug for SizingDimensions
impl Debug for SizingDimensions
Source§impl Default for SizingDimensions
impl Default for SizingDimensions
Auto Trait Implementations§
impl Freeze for SizingDimensions
impl RefUnwindSafe for SizingDimensions
impl Send for SizingDimensions
impl Sync for SizingDimensions
impl Unpin for SizingDimensions
impl UnsafeUnpin for SizingDimensions
impl UnwindSafe for SizingDimensions
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