pub struct Constraints {
pub min_width: f32,
pub max_width: f32,
pub min_height: f32,
pub max_height: f32,
}Expand description
Layout constraints that specify minimum and maximum sizes.
§Examples
use presentar_core::{Constraints, Size};
// Tight constraints allow only one size
let tight = Constraints::tight(Size::new(100.0, 50.0));
assert_eq!(tight.min_width, 100.0);
assert_eq!(tight.max_width, 100.0);
// Loose constraints allow any size up to maximum
let loose = Constraints::loose(Size::new(400.0, 300.0));
assert_eq!(loose.min_width, 0.0);
assert_eq!(loose.max_width, 400.0);Fields§
§min_width: f32Minimum width
max_width: f32Maximum width
min_height: f32Minimum height
max_height: f32Maximum height
Implementations§
Source§impl Constraints
impl Constraints
Sourcepub const fn new(
min_width: f32,
max_width: f32,
min_height: f32,
max_height: f32,
) -> Self
pub const fn new( min_width: f32, max_width: f32, min_height: f32, max_height: f32, ) -> Self
Create new constraints.
Sourcepub const fn tight(size: Size) -> Self
pub const fn tight(size: Size) -> Self
Create tight constraints that allow only the exact size.
Sourcepub const fn loose(size: Size) -> Self
pub const fn loose(size: Size) -> Self
Create loose constraints that allow any size up to the given maximum.
Sourcepub fn has_bounded_width(&self) -> bool
pub fn has_bounded_width(&self) -> bool
Check if width is bounded (not infinite).
Sourcepub fn has_bounded_height(&self) -> bool
pub fn has_bounded_height(&self) -> bool
Check if height is bounded (not infinite).
Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Check if both dimensions are bounded.
Sourcepub const fn with_min_width(&self, min_width: f32) -> Self
pub const fn with_min_width(&self, min_width: f32) -> Self
Create constraints with a different minimum width.
Sourcepub const fn with_max_width(&self, max_width: f32) -> Self
pub const fn with_max_width(&self, max_width: f32) -> Self
Create constraints with a different maximum width.
Sourcepub const fn with_min_height(&self, min_height: f32) -> Self
pub const fn with_min_height(&self, min_height: f32) -> Self
Create constraints with a different minimum height.
Sourcepub const fn with_max_height(&self, max_height: f32) -> Self
pub const fn with_max_height(&self, max_height: f32) -> Self
Create constraints with a different maximum height.
Trait Implementations§
Source§impl Clone for Constraints
impl Clone for Constraints
Source§fn clone(&self) -> Constraints
fn clone(&self) -> Constraints
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Constraints
impl Debug for Constraints
Source§impl Default for Constraints
impl Default for Constraints
Source§impl<'de> Deserialize<'de> for Constraints
impl<'de> Deserialize<'de> for Constraints
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
Source§impl PartialEq for Constraints
impl PartialEq for Constraints
Source§impl Serialize for Constraints
impl Serialize for Constraints
impl Copy for Constraints
impl StructuralPartialEq for Constraints
Auto Trait Implementations§
impl Freeze for Constraints
impl RefUnwindSafe for Constraints
impl Send for Constraints
impl Sync for Constraints
impl Unpin for Constraints
impl UnwindSafe for Constraints
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreSource§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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().