Struct zng::layout::PxConstraints
source · 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() -> PxConstraints
pub fn new_unbounded() -> PxConstraints
New unbounded constrain.
sourcepub fn new_bounded(max: Px) -> PxConstraints
pub fn new_bounded(max: Px) -> PxConstraints
New bounded between zero and max
with no fill.
sourcepub fn new_exact(length: Px) -> PxConstraints
pub fn new_exact(length: Px) -> PxConstraints
New bounded to only allow the length
and fill.
sourcepub fn new_fill(length: Px) -> PxConstraints
pub fn new_fill(length: Px) -> PxConstraints
New bounded to fill the length
.
sourcepub fn new_range(min: Px, max: Px) -> PxConstraints
pub fn new_range(min: Px, max: Px) -> PxConstraints
sourcepub fn with_new_min(self, min: Px) -> PxConstraints
pub fn with_new_min(self, min: Px) -> PxConstraints
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) -> PxConstraints
pub fn with_min(self, min: Px) -> PxConstraints
Returns a copy with_new_min
if min
is greater then the current minimum.
sourcepub fn with_new_max(self, max: Px) -> PxConstraints
pub fn with_new_max(self, max: Px) -> PxConstraints
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) -> PxConstraints
pub fn with_max(self, max: Px) -> PxConstraints
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) -> PxConstraints
pub fn with_new_exact(self, len: Px) -> PxConstraints
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) -> PxConstraints
pub fn with_exact(self, len: Px) -> PxConstraints
Returns a copy with_new_exact
if the new length clamped by the current constraints.
sourcepub fn with_fill(self, fill: bool) -> PxConstraints
pub fn with_fill(self, fill: bool) -> PxConstraints
Returns a copy of the current constraints that sets the fill
preference.
sourcepub fn with_fill_and(self, fill: bool) -> PxConstraints
pub fn with_fill_and(self, fill: bool) -> PxConstraints
Returns a copy of the current constraints that sets the fill preference to self.fill && fill
.
sourcepub fn with_unbounded(self) -> PxConstraints
pub fn with_unbounded(self) -> PxConstraints
Returns a copy of the current constraints without upper bound.
sourcepub fn with_less(self, sub: Px) -> PxConstraints
pub fn with_less(self, sub: Px) -> PxConstraints
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) -> PxConstraints
pub fn with_more(self, add: Px) -> PxConstraints
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§fn default() -> PxConstraints
fn default() -> PxConstraints
source§impl<'de> Deserialize<'de> for PxConstraints
impl<'de> Deserialize<'de> for PxConstraints
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PxConstraints, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PxConstraints, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<Px> for PxConstraints
impl From<Px> for PxConstraints
source§fn from(length: Px) -> PxConstraints
fn from(length: Px) -> PxConstraints
New exact.
source§impl Hash for PxConstraints
impl Hash for PxConstraints
source§impl IntoVar<PxConstraints> for Px
impl IntoVar<PxConstraints> for Px
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl PartialEq for PxConstraints
impl PartialEq for PxConstraints
source§impl Serialize for PxConstraints
impl Serialize for PxConstraints
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl Transitionable for PxConstraints
impl Transitionable for PxConstraints
source§fn lerp(self, to: &PxConstraints, step: Factor) -> PxConstraints
fn lerp(self, to: &PxConstraints, step: Factor) -> PxConstraints
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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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.source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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> 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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.