pub struct Stack { /* private fields */ }Expand description
A collection of static views. See stack and stack_from_iter.
The children of a stack can still get reactive updates.
Implementations§
Source§impl Stack
impl Stack
Sourcepub fn new(children: impl IntoViewIter) -> Self
pub fn new(children: impl IntoViewIter) -> Self
Creates a new stack from any type that implements IntoViewIter.
This accepts arrays, tuples, vectors, slices, and iterators of views.
§Example
use floem::views::*;
// From array
Stack::new([text("child 1"), text("child 2")]);
// From tuple (heterogeneous types)
Stack::new((text("label"), button("click")));
// From vec
Stack::new(vec![text("a"), text("b"), text("c")]);
// From iterator
Stack::new((0..5).map(|i| text(i)).collect::<Vec<_>>());Sourcepub fn with_id(id: ViewId, children: impl IntoViewIter) -> Self
pub fn with_id(id: ViewId, children: impl IntoViewIter) -> Self
Creates a new stack with a specific ViewId from a tuple of views.
This is useful for lazy view construction where the ViewId is created
before the view itself.
§Example
use floem::{ViewId, views::Stack};
let id = ViewId::new();
Stack::with_id(id, ("child 1", "child 2"));Sourcepub fn from_iter<V: IntoView + 'static>(
children: impl IntoIterator<Item = V>,
) -> Self
pub fn from_iter<V: IntoView + 'static>( children: impl IntoIterator<Item = V>, ) -> Self
Creates a new stack from an iterator of views.
§Example
use floem::views::*;
Stack::from_iter((0..5).map(|i| text(i)));Sourcepub fn from_iter_with_id<V: IntoView + 'static>(
id: ViewId,
children: impl IntoIterator<Item = V>,
direction: Option<FlexDirection>,
) -> Self
pub fn from_iter_with_id<V: IntoView + 'static>( id: ViewId, children: impl IntoIterator<Item = V>, direction: Option<FlexDirection>, ) -> Self
Creates a new stack with a specific ViewId from an iterator of views.
This is useful for lazy view construction where the ViewId is created
before the view itself. Unlike with_id, this method pre-converts all
views before setting children, avoiding potential RefCell borrow conflicts.
§Example
use floem::{ViewId, views::*};
let id = ViewId::new();
Stack::from_iter_with_id(id, (0..5).map(|i| text(i)), None);Sourcepub fn horizontal(children: impl IntoViewIter) -> Self
pub fn horizontal(children: impl IntoViewIter) -> Self
Creates a new horizontal stack (row direction).
§Example
use floem::views::*;
Stack::horizontal((text("left"), text("right")));Sourcepub fn vertical(children: impl IntoViewIter) -> Self
pub fn vertical(children: impl IntoViewIter) -> Self
Creates a new vertical stack (column direction).
§Example
use floem::views::*;
Stack::vertical((text("top"), text("bottom")));Sourcepub fn horizontal_from_iter<V: IntoView + 'static>(
children: impl IntoIterator<Item = V>,
) -> Self
pub fn horizontal_from_iter<V: IntoView + 'static>( children: impl IntoIterator<Item = V>, ) -> Self
Creates a new horizontal stack from an iterator of views.
§Example
use floem::views::*;
Stack::horizontal_from_iter((0..5).map(|i| text(i)));Sourcepub fn vertical_from_iter<V: IntoView + 'static>(
children: impl IntoIterator<Item = V>,
) -> Self
pub fn vertical_from_iter<V: IntoView + 'static>( children: impl IntoIterator<Item = V>, ) -> Self
Creates a new vertical stack from an iterator of views.
§Example
use floem::views::*;
Stack::vertical_from_iter((0..5).map(|i| text(i)));pub fn add_class_by_idx(self, class: impl Fn(usize) -> StyleClassRef) -> Self
Trait Implementations§
Source§impl View for Stack
impl View for Stack
fn id(&self) -> ViewId
fn view_style(&self) -> Option<Style>
fn debug_name(&self) -> Cow<'static, str>
Source§fn update(&mut self, _cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
fn update(&mut self, _cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
View’s Id handle Read morefn view_class(&self) -> Option<StyleClassRef>
Source§fn style_pass(&mut self, cx: &mut StyleCx<'_>)
fn style_pass(&mut self, cx: &mut StyleCx<'_>)
Source§fn layout(&mut self, cx: &mut LayoutCx<'_>) -> NodeId
fn layout(&mut self, cx: &mut LayoutCx<'_>) -> NodeId
LayoutCx::layout_node. Read moreSource§fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>
fn compute_layout(&mut self, cx: &mut ComputeLayoutCx<'_>) -> Option<Rect>
fn event_before_children( &mut self, cx: &mut EventCx<'_>, event: &Event, ) -> EventPropagation
fn event_after_children( &mut self, cx: &mut EventCx<'_>, event: &Event, ) -> EventPropagation
Source§fn paint(&mut self, cx: &mut PaintCx<'_>)
fn paint(&mut self, cx: &mut PaintCx<'_>)
View-specific implementation. Will be called in PaintCx::paint_view.
Usually you’ll call paint_view for every child view. But you might also draw text, adjust the offset, clip
or draw text.Auto Trait Implementations§
impl Freeze for Stack
impl RefUnwindSafe for Stack
impl Send for Stack
impl Sync for Stack
impl Unpin for Stack
impl UnwindSafe for Stack
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
Source§impl<T> ContainerExt for Twhere
T: IntoView + 'static,
impl<T> ContainerExt for Twhere
T: IntoView + 'static,
Source§impl<T> Decorators for Twhere
T: IntoView,
impl<T> Decorators for Twhere
T: IntoView,
Source§fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::Intermediate
fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::Intermediate
Source§fn debug_name(self, name: impl Into<String>) -> Self::Intermediate
fn debug_name(self, name: impl Into<String>) -> Self::Intermediate
Source§fn debug_name_if<S: Into<String>>(
self,
apply: impl Fn() -> bool + 'static,
name: impl Fn() -> S + 'static,
) -> Self::Intermediate
fn debug_name_if<S: Into<String>>( self, apply: impl Fn() -> bool + 'static, name: impl Fn() -> S + 'static, ) -> Self::Intermediate
Source§fn dragging_style(
self,
style: impl Fn(Style) -> Style + 'static,
) -> Self::Intermediate
fn dragging_style( self, style: impl Fn(Style) -> Style + 'static, ) -> Self::Intermediate
Source§fn class<C: StyleClass>(self, _class: C) -> Self::Intermediate
fn class<C: StyleClass>(self, _class: C) -> Self::Intermediate
Source§fn class_if<C: StyleClass>(
self,
apply: impl Fn() -> bool + 'static,
_class: C,
) -> Self::Intermediate
fn class_if<C: StyleClass>( self, apply: impl Fn() -> bool + 'static, _class: C, ) -> Self::Intermediate
Source§fn remove_class<C: StyleClass>(self, _class: C) -> Self::Intermediate
fn remove_class<C: StyleClass>(self, _class: C) -> Self::Intermediate
Style::focusable insteadSource§fn disable_default_event(
self,
disable: impl Fn() -> (EventListener, bool) + 'static,
) -> Self::Intermediate
fn disable_default_event( self, disable: impl Fn() -> (EventListener, bool) + 'static, ) -> Self::Intermediate
Source§fn draggable(self) -> Self::Intermediate
fn draggable(self) -> Self::Intermediate
Style::draggable directly insteadSource§fn disabled(
self,
disabled_fn: impl Fn() -> bool + 'static,
) -> Self::Intermediate
fn disabled( self, disabled_fn: impl Fn() -> bool + 'static, ) -> Self::Intermediate
Style::set_disabled directly insteadSource§fn on_event(
self,
listener: EventListener,
action: impl FnMut(&Event) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_event( self, listener: EventListener, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener.Source§fn on_key_down(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_key_down( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
Source§fn on_key_up(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_key_up( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
Source§fn on_event_cont(
self,
listener: EventListener,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_event_cont( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_event_stop(
self,
listener: EventListener,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_event_stop( self, listener: EventListener, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will stop propagating.Source§fn on_click(
self,
action: impl FnMut(&Event) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_click( self, action: impl FnMut(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener::Click.Source§fn on_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::Intermediate
fn on_click_cont(self, action: impl Fn(&Event) + 'static) -> Self::Intermediate
EventListener::Click. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_click_stop(
self,
action: impl FnMut(&Event) + 'static,
) -> Self::Intermediate
fn on_click_stop( self, action: impl FnMut(&Event) + 'static, ) -> Self::Intermediate
EventListener::Click. This event will be handled with
the given handler and the event will stop propagating.Source§fn action(self, action: impl FnMut() + 'static) -> Self::Intermediate
fn action(self, action: impl FnMut() + 'static) -> Self::Intermediate
Source§fn on_double_click(
self,
action: impl Fn(&Event) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_double_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener::DoubleClickSource§fn on_double_click_cont(
self,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_double_click_cont( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener::DoubleClick. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_double_click_stop(
self,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_double_click_stop( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener::DoubleClick. This event will be handled with
the given handler and the event will stop propagating.Source§fn on_secondary_click(
self,
action: impl Fn(&Event) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_secondary_click( self, action: impl Fn(&Event) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener::SecondaryClick. This is most often the “Right” click.Source§fn on_secondary_click_cont(
self,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_secondary_click_cont( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will continue propagating.Source§fn on_secondary_click_stop(
self,
action: impl Fn(&Event) + 'static,
) -> Self::Intermediate
fn on_secondary_click_stop( self, action: impl Fn(&Event) + 'static, ) -> Self::Intermediate
EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will stop propagating.Source§fn on_resize(self, action: impl Fn(Rect) + 'static) -> Self::Intermediate
fn on_resize(self, action: impl Fn(Rect) + 'static) -> Self::Intermediate
Source§fn on_move(self, action: impl Fn(Point) + 'static) -> Self::Intermediate
fn on_move(self, action: impl Fn(Point) + 'static) -> Self::Intermediate
Source§fn on_cleanup(self, action: impl Fn() + 'static) -> Self::Intermediate
fn on_cleanup(self, action: impl Fn() + 'static) -> Self::Intermediate
Source§fn animation(
self,
animation: impl Fn(Animation) -> Animation + 'static,
) -> Self::Intermediate
fn animation( self, animation: impl Fn(Animation) -> Animation + 'static, ) -> Self::Intermediate
Source§fn clear_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
fn clear_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
Source§fn request_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
fn request_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
Source§fn window_scale(
self,
scale_fn: impl Fn() -> f64 + 'static,
) -> Self::Intermediate
fn window_scale( self, scale_fn: impl Fn() -> f64 + 'static, ) -> Self::Intermediate
Source§fn window_title(
self,
title_fn: impl Fn() -> String + 'static,
) -> Self::Intermediate
fn window_title( self, title_fn: impl Fn() -> String + 'static, ) -> Self::Intermediate
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