pub struct Constraints {
pub min_width: f32,
pub max_width: f32,
pub min_height: f32,
pub max_height: f32,
}Expand description
Constraints used during layout measurement.
Fields§
§min_width: f32§max_width: f32§min_height: f32§max_height: f32Implementations§
Source§impl Constraints
impl Constraints
Sourcepub fn tight(width: f32, height: f32) -> Constraints
pub fn tight(width: f32, height: f32) -> Constraints
Creates constraints with exact width and height.
Sourcepub fn loose(max_width: f32, max_height: f32) -> Constraints
pub fn loose(max_width: f32, max_height: f32) -> Constraints
Creates constraints with loose bounds (min = 0, max = given values).
Sourcepub fn is_tight(&self) -> bool
pub fn is_tight(&self) -> bool
Returns true if these constraints have a single size that satisfies them.
Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Returns true if all bounds are finite.
Sourcepub fn constrain(&self, width: f32, height: f32) -> (f32, f32)
pub fn constrain(&self, width: f32, height: f32) -> (f32, f32)
Constrains the provided width and height to fit within these constraints.
Sourcepub fn has_bounded_width(&self) -> bool
pub fn has_bounded_width(&self) -> bool
Returns true if the width is bounded (max_width is finite).
Sourcepub fn has_bounded_height(&self) -> bool
pub fn has_bounded_height(&self) -> bool
Returns true if the height is bounded (max_height is finite).
Sourcepub fn has_tight_width(&self) -> bool
pub fn has_tight_width(&self) -> bool
Returns true if both width and height are tight (min == max for both).
Sourcepub fn has_tight_height(&self) -> bool
pub fn has_tight_height(&self) -> bool
Returns true if the height is tight (min == max).
Sourcepub fn tighten_width(self, width: f32) -> Constraints
pub fn tighten_width(self, width: f32) -> Constraints
Creates new constraints with tightened width (min = max = given width).
Sourcepub fn tighten_height(self, height: f32) -> Constraints
pub fn tighten_height(self, height: f32) -> Constraints
Creates new constraints with tightened height (min = max = given height).
Sourcepub fn copy_with_width(self, min_width: f32, max_width: f32) -> Constraints
pub fn copy_with_width(self, min_width: f32, max_width: f32) -> Constraints
Creates new constraints with the given width bounds.
Sourcepub fn copy_with_height(self, min_height: f32, max_height: f32) -> Constraints
pub fn copy_with_height(self, min_height: f32, max_height: f32) -> Constraints
Creates new constraints with the given height bounds.
Sourcepub fn deflate(self, horizontal: f32, vertical: f32) -> Constraints
pub fn deflate(self, horizontal: f32, vertical: f32) -> Constraints
Deflates constraints by the given amount on all sides. This is useful for applying padding before measuring children.
Sourcepub fn loosen(self) -> Constraints
pub fn loosen(self) -> Constraints
Creates new constraints with loosened minimums (min = 0).
Sourcepub fn enforce(self, width: f32, height: f32) -> Constraints
pub fn enforce(self, width: f32, height: f32) -> Constraints
Creates constraints that enforce the given size.
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