pub struct Constraints {
pub min: Vec2,
pub max: Vec2,
}Expand description
Defines box constraints used for layout.
Fields§
§min: Vec2The minimum size that is allowed by these constraints.
max: Vec2The maximum size that is allowed by these constraints.
Implementations§
Source§impl Constraints
impl Constraints
Sourcepub fn loose(max: Vec2) -> Self
pub fn loose(max: Vec2) -> Self
Create a new Constraints with a minimum size of zero and the given
maximum.
Sourcepub fn tight(value: Vec2) -> Self
pub fn tight(value: Vec2) -> Self
Create a new Constraints whose minimum and maximum constraints are the
given value.
Sourcepub fn none() -> Self
pub fn none() -> Self
Create a new Constraints whose minimum size is zero and whose maximum
is infinite.
Sourcepub fn constrain_min(&self, base: Vec2) -> Vec2
pub fn constrain_min(&self, base: Vec2) -> Vec2
Returns the size closest to the given size that satisfies the minimun constraints.
Sourcepub fn constrain(&self, base: Vec2) -> Vec2
pub fn constrain(&self, base: Vec2) -> Vec2
Returns the size closest to the given size that fits the constraints.
Sourcepub fn constrain_width(&self, width: f32) -> f32
pub fn constrain_width(&self, width: f32) -> f32
Returns the width closest to the given width that fits the constraints.
Sourcepub fn constrain_height(&self, height: f32) -> f32
pub fn constrain_height(&self, height: f32) -> f32
Returns the height closest to the given height that fits the constraints.
Sourcepub fn is_tight(&self) -> bool
pub fn is_tight(&self) -> bool
Constraints are tight if the minimum size and maximum size are the same. This means that there is exactly only size that satisfies the constraints.
Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Constraints are bounded if the maximum size on both axes is finite.
Sourcepub fn is_unbounded(&self) -> bool
pub fn is_unbounded(&self) -> bool
Constraints are unbounded if the maximum size on either axis is infinite.
Trait Implementations§
Source§impl Clone for Constraints
impl Clone for Constraints
Source§fn clone(&self) -> Constraints
fn clone(&self) -> Constraints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more