pub struct BoxConstraints {
pub min_width: f64,
pub max_width: f64,
pub min_height: f64,
pub max_height: f64,
}Expand description
Immutable layout constraints for RenderBox layout.
A Size respects a BoxConstraints if, and only if, all of the following
relations hold:
min_width<=Size::width<=max_widthmin_height<=Size::height<=max_height
Fields§
§min_width: f64The minimum width that satisfies the constraints.
max_width: f64The maximum width that satisfies the constraints.
Might be f64::INFINITY.
min_height: f64The minimum height that satisfies the constraints.
max_height: f64The maximum height that satisfies the constraints.
Might be f64::INFINITY.
Implementations§
Source§impl BoxConstraints
impl BoxConstraints
Sourcepub const fn new() -> BoxConstraints
pub const fn new() -> BoxConstraints
Creates box constraints with the given constraints.
Sourcepub const fn min_width(self, value: f64) -> BoxConstraints
pub const fn min_width(self, value: f64) -> BoxConstraints
Sets min_width.
Sourcepub const fn max_width(self, value: f64) -> BoxConstraints
pub const fn max_width(self, value: f64) -> BoxConstraints
Sets max_width.
Sourcepub const fn min_height(self, value: f64) -> BoxConstraints
pub const fn min_height(self, value: f64) -> BoxConstraints
Sets min_height.
Sourcepub const fn max_height(self, value: f64) -> BoxConstraints
pub const fn max_height(self, value: f64) -> BoxConstraints
Sets max_height.
Sourcepub fn tight(size: Size) -> BoxConstraints
pub fn tight(size: Size) -> BoxConstraints
Creates box constraints that is respected only by the given size.
Sourcepub const fn tight_for(
width: Option<f64>,
height: Option<f64>,
) -> BoxConstraints
pub const fn tight_for( width: Option<f64>, height: Option<f64>, ) -> BoxConstraints
Creates box constraints that require the given width or height.
Sourcepub const fn tight_for_finite(width: f64, height: f64) -> BoxConstraints
pub const fn tight_for_finite(width: f64, height: f64) -> BoxConstraints
Creates box constraints that require the given width or height, except if they are infinite.
Sourcepub fn loose(size: Size) -> BoxConstraints
pub fn loose(size: Size) -> BoxConstraints
Creates box constraints that forbid sizes larger than the given size.
Sourcepub const fn expand(width: Option<f64>, height: Option<f64>) -> BoxConstraints
pub const fn expand(width: Option<f64>, height: Option<f64>) -> BoxConstraints
Creates box constraints that expand to fill another box constraints.
Sourcepub const fn from_view_constraints(
constraints: ViewConstraints,
) -> BoxConstraints
pub const fn from_view_constraints( constraints: ViewConstraints, ) -> BoxConstraints
Creates box constraints that match the given view constraints.
Sourcepub const fn copy_with(self) -> BoxConstraints
pub const fn copy_with(self) -> BoxConstraints
Creates a copy of this box constraints. Chain field replacements.
Sourcepub fn deflate(self, edges: EdgeInsetsGeometry) -> BoxConstraints
pub fn deflate(self, edges: EdgeInsetsGeometry) -> BoxConstraints
Returns new box constraints that are smaller by the given edge dimensions.
Sourcepub fn loosen(self) -> BoxConstraints
pub fn loosen(self) -> BoxConstraints
Returns new box constraints that remove the minimum width and height requirements.
Sourcepub fn enforce(self, constraints: BoxConstraints) -> BoxConstraints
pub fn enforce(self, constraints: BoxConstraints) -> BoxConstraints
Returns new box constraints that respect the given constraints while being as close as possible to the original constraints.
Sourcepub fn tighten(self, width: Option<f64>, height: Option<f64>) -> BoxConstraints
pub fn tighten(self, width: Option<f64>, height: Option<f64>) -> BoxConstraints
Returns new box constraints with a tight width and/or height as close to the given width and height as possible while still respecting the original box constraints.
Sourcepub const fn flipped(self) -> BoxConstraints
pub const fn flipped(self) -> BoxConstraints
A box constraints with the width and height constraints flipped.
Sourcepub const fn width_constraints(self) -> BoxConstraints
pub const fn width_constraints(self) -> BoxConstraints
Returns box constraints with the same width constraints but with unconstrained height.
Sourcepub const fn height_constraints(self) -> BoxConstraints
pub const fn height_constraints(self) -> BoxConstraints
Returns box constraints with the same height constraints but with unconstrained width.
Sourcepub fn constrain_width(self, width: f64) -> f64
pub fn constrain_width(self, width: f64) -> f64
Returns the width that both satisfies the constraints and is as close as possible to the given width.
Sourcepub fn constrain_height(self, height: f64) -> f64
pub fn constrain_height(self, height: f64) -> f64
Returns the height that both satisfies the constraints and is as close as possible to the given height.
Sourcepub fn constrain(self, size: Size) -> Size
pub fn constrain(self, size: Size) -> Size
Returns the size that both satisfies the constraints and is as close as possible to the given size.
Sourcepub fn constrain_dimensions(self, width: f64, height: f64) -> Size
pub fn constrain_dimensions(self, width: f64, height: f64) -> Size
Returns the size that both satisfies the constraints and is as close as possible to the given width and height.
Sourcepub fn constrain_size_and_attempt_to_preserve_aspect_ratio(
self,
size: Size,
) -> Size
pub fn constrain_size_and_attempt_to_preserve_aspect_ratio( self, size: Size, ) -> Size
Returns a size that attempts to meet the following conditions, in order:
- The size must satisfy these constraints.
- The aspect ratio of the returned size matches the aspect ratio of the given size.
- The returned size is as big as possible while still being equal to or smaller than the given size.
Sourcepub fn has_tight_width(self) -> bool
pub fn has_tight_width(self) -> bool
Whether there is exactly one width value that satisfies the constraints.
Sourcepub fn has_tight_height(self) -> bool
pub fn has_tight_height(self) -> bool
Whether there is exactly one height value that satisfies the constraints.
Sourcepub fn has_bounded_width(self) -> bool
pub fn has_bounded_width(self) -> bool
Whether there is an upper bound on the maximum width.
Sourcepub fn has_bounded_height(self) -> bool
pub fn has_bounded_height(self) -> bool
Whether there is an upper bound on the maximum height.
Sourcepub fn has_infinite_width(self) -> bool
pub fn has_infinite_width(self) -> bool
Whether the width constraint is infinite.
Sourcepub fn has_infinite_height(self) -> bool
pub fn has_infinite_height(self) -> bool
Whether the height constraint is infinite.
Sourcepub fn is_satisfied_by(self, size: Size) -> bool
pub fn is_satisfied_by(self, size: Size) -> bool
Whether the given size satisfies the constraints.
Sourcepub fn truncating_div(self, factor: f64) -> BoxConstraints
pub fn truncating_div(self, factor: f64) -> BoxConstraints
Scales each constraint parameter by the inverse of the given factor,
rounded toward zero (Dart ~/).
Sourcepub fn lerp(
a: Option<BoxConstraints>,
b: Option<BoxConstraints>,
t: f64,
) -> Option<BoxConstraints>
pub fn lerp( a: Option<BoxConstraints>, b: Option<BoxConstraints>, t: f64, ) -> Option<BoxConstraints>
Linearly interpolate between two box constraints.
If either is none, this function interpolates from a BoxConstraints
object whose fields are all set to 0.0.
Sourcepub fn normalize(self) -> BoxConstraints
pub fn normalize(self) -> BoxConstraints
Returns a box constraints that is_normalized.
Trait Implementations§
Source§impl Clone for BoxConstraints
impl Clone for BoxConstraints
Source§impl Constraints for BoxConstraints
impl Constraints for BoxConstraints
impl Copy for BoxConstraints
Source§impl Debug for BoxConstraints
impl Debug for BoxConstraints
Source§impl Default for BoxConstraints
impl Default for BoxConstraints
Source§fn default() -> BoxConstraints
fn default() -> BoxConstraints
Source§impl Display for BoxConstraints
impl Display for BoxConstraints
Source§impl Div<f64> for BoxConstraints
impl Div<f64> for BoxConstraints
Source§type Output = BoxConstraints
type Output = BoxConstraints
/ operator.impl Eq for BoxConstraints
Source§impl Hash for BoxConstraints
impl Hash for BoxConstraints
Source§impl Mul<f64> for BoxConstraints
impl Mul<f64> for BoxConstraints
Source§type Output = BoxConstraints
type Output = BoxConstraints
* operator.Source§impl PartialEq for BoxConstraints
impl PartialEq for BoxConstraints
Source§impl Rem<f64> for BoxConstraints
impl Rem<f64> for BoxConstraints
Source§type Output = BoxConstraints
type Output = BoxConstraints
% operator.Auto Trait Implementations§
impl Freeze for BoxConstraints
impl RefUnwindSafe for BoxConstraints
impl Send for BoxConstraints
impl Sync for BoxConstraints
impl Unpin for BoxConstraints
impl UnsafeUnpin for BoxConstraints
impl UnwindSafe for BoxConstraints
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.