Struct zng::stack::StackDirection
source · pub struct StackDirection {
pub place: Point,
pub origin: Point,
pub is_rtl_aware: bool,
}
Expand description
Defines a placement point in the previous item and the origin point of the next.
Defining stack direction like this allows expressing the traditional stack directions along an axis, as well as intermediary for transition animations or diagonal directions.
Note that collapsed items (layout size zero) are skipped, so the previous and next items are both non-empty in layout.
§Alignment & Spacing
The direction type can express non-fill alignment and spacing by it self, but prefer using the stack::children_align
and
stack::spacing
properties as they are more readable and include fill alignment.
The Stack!
widget implements alignment along the axis that does not change, so if the computed layout vector
is zero in a dimension the items can fill in that dimension.
The Stack!
widget adds the spacing along non-zero axis for each item offset after the first, so the spacing is not
added for a perfect straight column or row, but it is added even for a single pixel shift diagonal stack.
Fields§
§place: Point
Point on the previous item where the next item is placed.
origin: Point
Point on the next item that is offset to match place
.
is_rtl_aware: bool
If place.x
and origin.x
are swapped in LayoutDirection::RTL
contexts.
Implementations§
source§impl StackDirection
impl StackDirection
sourcepub fn new<P, O>(place: P, origin: O, is_rtl_aware: bool) -> StackDirection
pub fn new<P, O>(place: P, origin: O, is_rtl_aware: bool) -> StackDirection
New custom direction.
sourcepub fn left_to_right() -> StackDirection
pub fn left_to_right() -> StackDirection
((100.pct(), 0), (0, 0))
, items are placed in a row from left to right.
Alignment works on the y
direction because it is not affected.
sourcepub fn right_to_left() -> StackDirection
pub fn right_to_left() -> StackDirection
((0, 0), (100.pct(), 0))
, items are placed in a row from right to left.
Alignment works on the y
direction because it is not affected.
sourcepub fn start_to_end() -> StackDirection
pub fn start_to_end() -> StackDirection
((100.pct(), 0), (0, 0), true)
, items are placed in a row from left to right or from right to left in RTL contexts.
In LayoutDirection::RTL
contexts the place.x
and origin.x
values are swapped before they are computed.
Alignment works on the y
direction because it is not affected.
sourcepub fn end_to_start() -> StackDirection
pub fn end_to_start() -> StackDirection
((0, 0), (100.pct(), 0)), true)
, items are placed in a row from right to left or from left to right in RTL contexts.
In LayoutDirection::RTL
contexts the place.x
and origin.x
values are swapped before they are computed.
Alignment works on the y
direction because it is not affected.
sourcepub fn top_to_bottom() -> StackDirection
pub fn top_to_bottom() -> StackDirection
((0, 100.pct()), (0, 0))
, items are placed in a column from top to bottom.
Alignment works on the x
direction because it is not affected.
sourcepub fn bottom_to_top() -> StackDirection
pub fn bottom_to_top() -> StackDirection
(0, 0), (0, 100.pct())
, items are placed in a column from bottom to top.
Alignment works on the x
direction because it is not affected.
sourcepub fn none() -> StackDirection
pub fn none() -> StackDirection
(0, 0)
, items are just stacked in the Z order.
Fill alignment works in both dimensions because they don’t change.
Note that items are always rendered in the order defined by the z_index
property.
sourcepub fn layout(
&self,
prev_item: Rect<Px, Px>,
next_item: Size2D<Px, Px>,
) -> Vector2D<Px, Px>
pub fn layout( &self, prev_item: Rect<Px, Px>, next_item: Size2D<Px, Px>, ) -> Vector2D<Px, Px>
Compute offset of the next item in the current LAYOUT
context.
sourcepub fn direction_factor(&self, direction: LayoutDirection) -> Factor2d
pub fn direction_factor(&self, direction: LayoutDirection) -> Factor2d
Factor that defines the proportional direction.
Values are in the range of -1.0..=1.0
.
sourcepub fn direction_scale(&self) -> Factor2d
pub fn direction_scale(&self) -> Factor2d
Scale proportional to how one dimensional the direction is.
Values are in the 0.0..=1.0
range where 0 is 20º or more from a single direction and 1 is 0º or 90º.
sourcepub fn affect_mask(&self) -> LayoutMask
pub fn affect_mask(&self) -> LayoutMask
Compute a LayoutMask
that flags all contextual values that affect the result of layout
.
sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Returns true
if all values are Length::Default
.
Trait Implementations§
source§impl Add for StackDirection
impl Add for StackDirection
source§type Output = StackDirection
type Output = StackDirection
+
operator.source§fn add(self, rhs: StackDirection) -> StackDirection
fn add(self, rhs: StackDirection) -> StackDirection
+
operation. Read moresource§impl AddAssign for StackDirection
impl AddAssign for StackDirection
source§fn add_assign(&mut self, rhs: StackDirection)
fn add_assign(&mut self, rhs: StackDirection)
+=
operation. Read moresource§impl Clone for StackDirection
impl Clone for StackDirection
source§fn clone(&self) -> StackDirection
fn clone(&self) -> StackDirection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StackDirection
impl Debug for StackDirection
source§impl Default for StackDirection
impl Default for StackDirection
source§fn default() -> StackDirection
fn default() -> StackDirection
source§impl<'de> Deserialize<'de> for StackDirection
impl<'de> Deserialize<'de> for StackDirection
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StackDirection, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StackDirection, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Display for StackDirection
impl Display for StackDirection
source§impl<'a, S> Div<S> for &'a StackDirection
impl<'a, S> Div<S> for &'a StackDirection
source§impl<S> Div<S> for StackDirection
impl<S> Div<S> for StackDirection
source§type Output = StackDirection
type Output = StackDirection
/
operator.source§fn div(self, rhs: S) -> StackDirection
fn div(self, rhs: S) -> StackDirection
/
operation. Read moresource§impl<S> DivAssign<S> for StackDirection
impl<S> DivAssign<S> for StackDirection
source§fn div_assign(&mut self, rhs: S)
fn div_assign(&mut self, rhs: S)
/=
operation. Read moresource§impl<P, O> From<(P, O)> for StackDirection
impl<P, O> From<(P, O)> for StackDirection
source§fn from(_: (P, O)) -> StackDirection
fn from(_: (P, O)) -> StackDirection
New from place and origin, not RTL aware.
source§impl<P, O> From<(P, O, bool)> for StackDirection
impl<P, O> From<(P, O, bool)> for StackDirection
source§fn from(_: (P, O, bool)) -> StackDirection
fn from(_: (P, O, bool)) -> StackDirection
New from place, origin, and RTL aware flag.
source§impl<P, O> IntoVar<StackDirection> for (P, O)
impl<P, O> IntoVar<StackDirection> for (P, O)
source§fn into_var(self) -> <(P, O) as IntoVar<StackDirection>>::Var
fn into_var(self) -> <(P, O) as IntoVar<StackDirection>>::Var
New from place and origin, not RTL aware.
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<P, O> IntoVar<StackDirection> for (P, O, bool)
impl<P, O> IntoVar<StackDirection> for (P, O, bool)
source§fn into_var(self) -> <(P, O, bool) as IntoVar<StackDirection>>::Var
fn into_var(self) -> <(P, O, bool) as IntoVar<StackDirection>>::Var
New from place, origin, and RTL aware flag.
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<'a, S> Mul<S> for &'a StackDirection
impl<'a, S> Mul<S> for &'a StackDirection
source§impl<S> Mul<S> for StackDirection
impl<S> Mul<S> for StackDirection
source§type Output = StackDirection
type Output = StackDirection
*
operator.source§fn mul(self, rhs: S) -> StackDirection
fn mul(self, rhs: S) -> StackDirection
*
operation. Read moresource§impl<S> MulAssign<S> for StackDirection
impl<S> MulAssign<S> for StackDirection
source§fn mul_assign(&mut self, rhs: S)
fn mul_assign(&mut self, rhs: S)
*=
operation. Read moresource§impl PartialEq for StackDirection
impl PartialEq for StackDirection
source§impl Serialize for StackDirection
impl Serialize for StackDirection
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 Sub for StackDirection
impl Sub for StackDirection
source§type Output = StackDirection
type Output = StackDirection
-
operator.source§fn sub(self, rhs: StackDirection) -> StackDirection
fn sub(self, rhs: StackDirection) -> StackDirection
-
operation. Read moresource§impl SubAssign for StackDirection
impl SubAssign for StackDirection
source§fn sub_assign(&mut self, rhs: StackDirection)
fn sub_assign(&mut self, rhs: StackDirection)
-=
operation. Read moresource§impl Transitionable for StackDirection
impl Transitionable for StackDirection
source§fn lerp(self, to: &StackDirection, step: Factor) -> StackDirection
fn lerp(self, to: &StackDirection, step: Factor) -> StackDirection
self
-> to
by step
.impl<P, O> IntoValue<StackDirection> for (P, O)
impl<P, O> IntoValue<StackDirection> for (P, O, bool)
impl StructuralPartialEq for StackDirection
Auto Trait Implementations§
impl Freeze for StackDirection
impl RefUnwindSafe for StackDirection
impl Send for StackDirection
impl Sync for StackDirection
impl Unpin for StackDirection
impl UnwindSafe for StackDirection
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
)source§impl<T> DataNoteValue for T
impl<T> DataNoteValue for T
§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
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()
.