pub struct PxConstraints {
pub fill: bool,
/* 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
.
Fields§
§fill: bool
Fill preference, when this is true
and the constraints have a maximum bound the fill length is the maximum bounds,
otherwise the fill length is the minimum bounds.
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 fill
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 self.fill && 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_pref(self) -> bool
pub fn is_fill_pref(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 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 fill is true
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.
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§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 Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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