pub struct Constraints {
pub min_width: u16,
pub min_height: u16,
/* private fields */
}Expand description
Constraints are used to ensure that a widget doesn’t size it self outside of a set of given bounds.
A constraint can be tight, meaning then minimum and maximum width / height are the same.
Fields§
§min_width: u16Minimum width.
min_height: u16Minimum height.
Implementations§
Source§impl Constraints
impl Constraints
pub const MAX: Self
pub const ZERO: Self
pub fn max_height(&self) -> u16
pub fn max_width(&self) -> u16
Sourcepub fn sub_max_width(&mut self, width: u16)
pub fn sub_max_width(&mut self, width: u16)
Subtract width from the max width, as long
as the width isn’t unbounded.
Sourcepub fn sub_max_height(&mut self, height: u16)
pub fn sub_max_height(&mut self, height: u16)
Subtract height from the max height, as long
as the height isn’t unbounded.
Sourcepub fn new(
max_width: impl Into<Option<u16>>,
max_height: impl Into<Option<u16>>,
) -> Self
pub fn new( max_width: impl Into<Option<u16>>, max_height: impl Into<Option<u16>>, ) -> Self
Create a set of constraints with a given max width / height.
If None is passed for either max_width and / or max_height then this is qualified as
“unbounded” constraints.
The min_width and min_height are zero by default.
If the min_width and the max_width are the same the constraints are considered “tight”.
Sourcepub fn unbound_height(&mut self)
pub fn unbound_height(&mut self)
Create unbounded height
Sourcepub fn unbound_width(&mut self)
pub fn unbound_width(&mut self)
Create unbounded width
Sourcepub fn is_unbounded(&self) -> bool
pub fn is_unbounded(&self) -> bool
Returns true if the width and height is unbounded.
Sourcepub fn is_width_unbounded(&self) -> bool
pub fn is_width_unbounded(&self) -> bool
Returns true if the width is unbounded.
Sourcepub fn is_height_unbounded(&self) -> bool
pub fn is_height_unbounded(&self) -> bool
Returns true if the height is unbounded.
Sourcepub fn is_width_tight(&self) -> bool
pub fn is_width_tight(&self) -> bool
Returns true if the min_width and max_width are the same.
Sourcepub fn is_height_tight(&self) -> bool
pub fn is_height_tight(&self) -> bool
Returns true if the min_height and max_height are the same.
Sourcepub fn make_width_tight(&mut self, width: u16)
pub fn make_width_tight(&mut self, width: u16)
Make the width constraint tight.
let mut constraints = Constraints::new(10, 10);
constraints.make_width_tight(constraints.max_width());Sourcepub fn make_height_tight(&mut self, height: u16)
pub fn make_height_tight(&mut self, height: u16)
Make the height constraint tight.
let mut constraints = Constraints::new(10, 10);
constraints.make_height_tight(constraints.max_height());pub fn expand_horz(&mut self, size: Size) -> Size
pub fn expand_vert(&mut self, size: Size) -> Size
pub fn expand_all(&mut self, size: Size) -> Size
Sourcepub fn set_max_width(&mut self, width: u16)
pub fn set_max_width(&mut self, width: u16)
This function does not verify anything, but simply sets the max width. There is no check to see if the max width is smaller than the min width here.
Sourcepub fn set_max_height(&mut self, height: u16)
pub fn set_max_height(&mut self, height: u16)
This function does not verify anything, but simply sets the max height. There is no check to see if the max height is smaller than the min height here.
pub fn div_assign_max_width(self, count: u16, overflow: u16) -> Self
pub fn div_assign_max_height(self, count: u16, overflow: u16) -> Self
Sourcepub fn has_zero_dimension(&self) -> bool
pub fn has_zero_dimension(&self) -> bool
If either the max width or max height are zero then nothing can be laid out within the given constraint.
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