pub struct Constraints {
pub min_width: f32,
pub max_width: f32,
pub min_height: f32,
pub max_height: f32,
}Expand description
Re-export the UI crate so applications can depend on a single crate. 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 moreSource§impl Debug for Constraints
impl Debug for Constraints
Source§impl PartialEq for Constraints
impl PartialEq 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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.