pub struct PxConstraints { /* private fields */ }Expand description
Pixel length constraints.
These constraints can express lower and upper bounds, unbounded upper and preference of fill length.
See also the PxConstraints2d.
Implementations§
Source§impl PxConstraints
impl PxConstraints
Sourcepub fn new_unbounded() -> Self
pub fn new_unbounded() -> Self
New unbounded constrain.
Sourcepub fn new_bounded(max: Px) -> Self
pub fn new_bounded(max: Px) -> Self
New bounded between zero and max with no fill.
Sourcepub fn with_new_min(self, min: Px) -> Self
pub fn with_new_min(self, min: Px) -> Self
Returns a copy of the current constraints that has min as the lower bound and max adjusted to be >= min.
Sourcepub fn with_min(self, min: Px) -> Self
pub fn with_min(self, min: Px) -> Self
Returns a copy with_new_min if min is greater then the current minimum.
Sourcepub fn with_new_max(self, max: Px) -> Self
pub fn with_new_max(self, max: Px) -> Self
Returns a copy of the current constraints that has max as the upper bound and min adjusted to be <= max.
Sourcepub fn with_max(self, max: Px) -> Self
pub fn with_max(self, max: Px) -> Self
Returns a copy with_new_max if max is less then the current maximum or the current maximum is unbounded.
Sourcepub fn with_new_exact(self, len: Px) -> Self
pub fn with_new_exact(self, len: Px) -> Self
Returns a copy of the current constraints that has max and min set to len and fill enabled.
Sourcepub fn with_exact(self, len: Px) -> Self
pub fn with_exact(self, len: Px) -> Self
Returns a copy with_new_exact if the new length clamped by the current constraints.
Sourcepub fn with_fill(self, fill: bool) -> Self
pub fn with_fill(self, fill: bool) -> Self
Returns a copy of the current constraints that sets the is_fill preference.
Sourcepub fn with_inner(self, inner: bool) -> Self
pub fn with_inner(self, inner: bool) -> Self
Returns a copy of the current constraints that sets the is_inner preference.
Sourcepub fn with_fill_and(self, fill: bool) -> Self
pub fn with_fill_and(self, fill: bool) -> Self
Returns a copy of the current constraints that sets the fill preference to “current & fill”.
Sourcepub fn with_unbounded(self) -> Self
pub fn with_unbounded(self) -> Self
Returns a copy of the current constraints without upper bound.
Sourcepub fn with_less(self, sub: Px) -> Self
pub fn with_less(self, sub: Px) -> Self
Returns a copy of the current constraints with sub subtracted from the min and max bounds.
The subtraction is saturating, does not subtract max if unbounded.
Sourcepub fn with_more(self, add: Px) -> Self
pub fn with_more(self, add: Px) -> Self
Returns a copy of the current constraints with add added to the maximum bounds.
Does a saturation addition, this can potentially unbound the constraints if Px::MAX is reached.
Sourcepub fn is_bounded(self) -> bool
pub fn is_bounded(self) -> bool
Gets if the constraints have an upper bound.
Sourcepub fn is_unbounded(self) -> bool
pub fn is_unbounded(self) -> bool
Gets if the constraints have no upper bound.
Sourcepub fn is_fill(self) -> bool
pub fn is_fill(self) -> bool
Gets if the context prefers the maximum length over the minimum.
Note that if the constraints are unbounded there is not maximum length, in this case the fill length is the minimum.
Sourcepub fn is_fill_max(self) -> bool
pub fn is_fill_max(self) -> bool
Gets if the context prefers the maximum length and there is a maximum length.
Sourcepub fn is_inner(self) -> bool
pub fn is_inner(self) -> bool
Gets if the context wants the best inner bounds layout the target can provide, without fill padding or overflow clamping.
Widgets have an inner and outer bounds, during normal measure/layout the widget outer is suppose to always fulfill the constraints, and the inner is the actual best approximation to the given constraints. This flag indicates that the panel the child widget to skip this final pad/clamp and just return its best size for the given constraints.
Sourcepub fn exact(self) -> Option<Px>
pub fn exact(self) -> Option<Px>
Gets the fixed length if the constraints only allow one length.
Sourcepub fn max(self) -> Option<Px>
pub fn max(self) -> Option<Px>
Gets the maximum allowed length, or None if is unbounded.
The maximum is inclusive.
Sourcepub fn max_bounded(self) -> Px
pub fn max_bounded(self) -> Px
Gets the maximum length if it is bounded, or the minimum if not.
Sourcepub fn fill(self) -> Px
pub fn fill(self) -> Px
Gets the fill length, if is_fill this is the maximum length, otherwise it is the minimum length.
Sourcepub fn fill_or(self, length: Px) -> Px
pub fn fill_or(self, length: Px) -> Px
Gets the maximum if fill is preferred and max is bounded, or length clamped by the constraints.
Sourcepub fn fill_or_exact(self) -> Option<Px>
pub fn fill_or_exact(self) -> Option<Px>
Gets the max size if is fill and has max bounds, or gets the exact size if min equals max.
Sourcepub fn max_or(self, length: Px) -> Px
pub fn max_or(self, length: Px) -> Px
Gets the maximum length if bounded or length clamped by the constraints.
Trait Implementations§
Source§impl Clone for PxConstraints
impl Clone for PxConstraints
Source§fn clone(&self) -> PxConstraints
fn clone(&self) -> PxConstraints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PxConstraints
impl Debug for PxConstraints
Source§impl Default for PxConstraints
impl Default for PxConstraints
Source§impl<'de> Deserialize<'de> for PxConstraints
impl<'de> Deserialize<'de> for PxConstraints
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for PxConstraints
impl Hash for PxConstraints
Source§impl IntoVar<PxConstraints> for Px
impl IntoVar<PxConstraints> for Px
Source§fn into_var(self) -> Var<PxConstraints>
fn into_var(self) -> Var<PxConstraints>
New exact.
Source§impl PartialEq for PxConstraints
impl PartialEq for PxConstraints
Source§impl Serialize for PxConstraints
impl Serialize for PxConstraints
Source§impl Transitionable for PxConstraints
impl Transitionable for PxConstraints
Source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
self -> to by step.impl Copy for PxConstraints
impl Eq for PxConstraints
impl IntoValue<PxConstraints> for Px
impl StructuralPartialEq for PxConstraints
Auto Trait Implementations§
impl Freeze for PxConstraints
impl RefUnwindSafe for PxConstraints
impl Send for PxConstraints
impl Sync for PxConstraints
impl Unpin for PxConstraints
impl UnwindSafe for PxConstraints
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more