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: PointPoint on the previous item where the next item is placed.
origin: PointPoint on the next item that is offset to match place.
is_rtl_aware: boolIf 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<S> Div<S> for &StackDirection
impl<S> Div<S> for &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) -> Var<StackDirection>
fn into_var(self) -> Var<StackDirection>
New from place and origin, not RTL aware.
Source§impl<P, O> IntoVar<StackDirection> for (P, O, bool)
impl<P, O> IntoVar<StackDirection> for (P, O, bool)
Source§fn into_var(self) -> Var<StackDirection>
fn into_var(self) -> Var<StackDirection>
New from place, origin, and RTL aware flag.
Source§impl<S> Mul<S> for &StackDirection
impl<S> Mul<S> for &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 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<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> 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().Source§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy. Read more