pub struct Stack<Msg: Clone> {
pub children: Vec<(Element<Msg>, HAlign, VAlign, f32, f32, f32)>,
pub fit_content: bool,
}Expand description
A layout that draws all its children stacked on top of each other.
Each child can be positioned within the Stack rect via HAlign/VAlign.
Useful for overlaying a foreground widget on top of a background image:
stack()
.push( img_widget( bg_rgba, w, h ) )
.push_aligned( column().push( text( "Bottom right" ) ), HAlign::End, VAlign::Bottom )
.into()Fields§
§children: Vec<(Element<Msg>, HAlign, VAlign, f32, f32, f32)>Children with their alignment, margin, and extra (x, y) translation
applied after alignment. Drawn in order — last child is on top.
fit_content: boolWhen true, preferred_size reports the max of
children’s intrinsic widths and heights instead of (max_width, tallest).
Implementations§
Source§impl<Msg: Clone> Stack<Msg>
impl<Msg: Clone> Stack<Msg>
Sourcepub fn fit_content(self) -> Self
pub fn fit_content(self) -> Self
Enable Self::fit_content.
Sourcepub fn push(self, e: impl Into<Element<Msg>>) -> Self
pub fn push(self, e: impl Into<Element<Msg>>) -> Self
Append a child that fills the entire Stack rect (Android FrameLayout default).
Sourcepub fn push_aligned(
self,
e: impl Into<Element<Msg>>,
h_align: HAlign,
v_align: VAlign,
) -> Self
pub fn push_aligned( self, e: impl Into<Element<Msg>>, h_align: HAlign, v_align: VAlign, ) -> Self
Append a child with explicit horizontal and vertical alignment.
Sourcepub fn push_aligned_margin(
self,
e: impl Into<Element<Msg>>,
h_align: HAlign,
v_align: VAlign,
margin: f32,
) -> Self
pub fn push_aligned_margin( self, e: impl Into<Element<Msg>>, h_align: HAlign, v_align: VAlign, margin: f32, ) -> Self
Append a child with alignment and a uniform margin (inset from the Stack edges).
Sourcepub fn push_translated(
self,
e: impl Into<Element<Msg>>,
h_align: HAlign,
v_align: VAlign,
offset_x: f32,
offset_y: f32,
) -> Self
pub fn push_translated( self, e: impl Into<Element<Msg>>, h_align: HAlign, v_align: VAlign, offset_x: f32, offset_y: f32, ) -> Self
Append a child with alignment plus an extra (x, y) translation in
logical pixels. Useful when a child needs to shift outside the normal
alignment grid without giving up the margin or alignment shorthand.
Positive x / y move the child right / down.
pub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for Stack<Msg>
impl<Msg> !RefUnwindSafe for Stack<Msg>
impl<Msg> !Send for Stack<Msg>
impl<Msg> !Sync for Stack<Msg>
impl<Msg> Unpin for Stack<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Stack<Msg>
Blanket Implementations§
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
§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> 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