Struct zng_wgt_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: Into<Point>, O: Into<Point>>(
place: P,
origin: O,
is_rtl_aware: bool,
) -> Self
pub fn new<P: Into<Point>, O: Into<Point>>( place: P, origin: O, is_rtl_aware: bool, ) -> Self
New custom direction.
sourcepub fn left_to_right() -> Self
pub fn left_to_right() -> Self
((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() -> Self
pub fn right_to_left() -> Self
((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() -> Self
pub fn start_to_end() -> Self
((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() -> Self
pub fn end_to_start() -> Self
((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() -> Self
pub fn top_to_bottom() -> Self
((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() -> Self
pub fn bottom_to_top() -> Self
(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() -> Self
pub fn none() -> Self
(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: PxRect, next_item: PxSize) -> PxVector
pub fn layout(&self, prev_item: PxRect, next_item: PxSize) -> PxVector
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§impl AddAssign for StackDirection
impl AddAssign for StackDirection
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for StackDirection
impl Display for StackDirection
source§impl<S: Into<Factor2d>> DivAssign<S> for StackDirection
impl<S: Into<Factor2d>> DivAssign<S> for StackDirection
source§fn div_assign(&mut self, rhs: S)
fn div_assign(&mut self, rhs: S)
/=
operation. Read moresource§impl<S: Into<Factor2d>> MulAssign<S> for StackDirection
impl<S: Into<Factor2d>> 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§impl Sub for StackDirection
impl Sub for StackDirection
source§impl SubAssign for StackDirection
impl SubAssign for StackDirection
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moresource§impl Transitionable for StackDirection
impl Transitionable for StackDirection
source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
self
-> to
by step
.impl<P: Into<Point>, O: Into<Point>> IntoValue<StackDirection> for (P, O)
impl<P: Into<Point>, O: Into<Point>> 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§
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> 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