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,
) -> Constraints
pub const fn new( min_width: f32, max_width: f32, min_height: f32, max_height: f32, ) -> Constraints
Create new constraints.
Sourcepub const fn tight(size: Size) -> Constraints
pub const fn tight(size: Size) -> Constraints
Create tight constraints that allow only the exact size.
Sourcepub const fn loose(size: Size) -> Constraints
pub const fn loose(size: Size) -> Constraints
Create loose constraints that allow any size up to the given maximum.
Sourcepub const fn unbounded() -> Constraints
pub const fn unbounded() -> Constraints
Create unbounded constraints.
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) -> Constraints
pub const fn with_min_width(&self, min_width: f32) -> Constraints
Create constraints with a different minimum width.
Sourcepub const fn with_max_width(&self, max_width: f32) -> Constraints
pub const fn with_max_width(&self, max_width: f32) -> Constraints
Create constraints with a different maximum width.
Sourcepub const fn with_min_height(&self, min_height: f32) -> Constraints
pub const fn with_min_height(&self, min_height: f32) -> Constraints
Create constraints with a different minimum height.
Sourcepub const fn with_max_height(&self, max_height: f32) -> Constraints
pub const fn with_max_height(&self, max_height: f32) -> Constraints
Create constraints with a different maximum height.
Sourcepub fn deflate(&self, horizontal: f32, vertical: f32) -> Constraints
pub fn deflate(&self, horizontal: f32, vertical: f32) -> Constraints
Deflate constraints by padding.
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 (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 Constraints
Source§impl Debug for Constraints
impl Debug for Constraints
Source§impl Default for Constraints
impl Default for Constraints
Source§fn default() -> Constraints
fn default() -> Constraints
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Constraints
impl<'de> Deserialize<'de> for Constraints
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Constraints, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Constraints, <__D as Deserializer<'de>>::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§fn eq(&self, other: &Constraints) -> bool
fn eq(&self, other: &Constraints) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for Constraints
impl Serialize for Constraints
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 UnsafeUnpin 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