pub struct KeyedStack<K, T> { /* private fields */ }Expand description
A row or column of children kept in step with a list of keyed items.
Each item’s widget is built once and kept while its key stays in the list,
updating through the Signal it was built with. New items animate in,
one after another with a Stagger; removed items animate out while the
gap they leave closes; items that change places glide to their new
positions. An item added back while it is still leaving turns around and
comes back.
Implementations§
Source§impl<K, T> KeyedStack<K, T>
impl<K, T> KeyedStack<K, T>
Sourcepub fn new<O, KF, B, W>(
axis: Axis,
items: O,
key_for: KF,
build: B,
) -> KeyedStack<K, T>
pub fn new<O, KF, B, W>( axis: Axis, items: O, key_for: KF, build: B, ) -> KeyedStack<K, T>
A stack along axis of the items in items, identified by
key_for and built by build.
pub fn vertical<O, KF, B, W>( items: O, key_for: KF, build: B, ) -> KeyedStack<K, T>
pub fn horizontal<O, KF, B, W>( items: O, key_for: KF, build: B, ) -> KeyedStack<K, T>
pub fn gap(self, gap: f32) -> KeyedStack<K, T>
Sourcepub fn alignment(self, alignment: Alignment) -> KeyedStack<K, T>
pub fn alignment(self, alignment: Alignment) -> KeyedStack<K, T>
How items line up across the stack. Stretch, the default, makes
them all as wide (or tall) as the stack.
Sourcepub fn transition(self, transition: PresenceTransition) -> KeyedStack<K, T>
pub fn transition(self, transition: PresenceTransition) -> KeyedStack<K, T>
How items enter and leave. The stack collapses the space of leaving
items unless the transition turns collapse off.
Sourcepub fn stagger(self, stagger: Stagger) -> KeyedStack<K, T>
pub fn stagger(self, stagger: Stagger) -> KeyedStack<K, T>
Delays for items that arrive together; Stagger::NONE brings them
in at once.
Sourcepub fn move_spec(self, spec: Option<AnimationSpec>) -> KeyedStack<K, T>
pub fn move_spec(self, spec: Option<AnimationSpec>) -> KeyedStack<K, T>
How items glide to new places, or None to move them at once.
Sourcepub fn appear(self, appear: bool) -> KeyedStack<K, T>
pub fn appear(self, appear: bool) -> KeyedStack<K, T>
Animate the first items in too, instead of showing them at once.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<K, T> Widget for KeyedStack<K, T>
impl<K, T> Widget for KeyedStack<K, T>
fn measure(&mut self, ctx: &mut MeasureCtx, constraints: Constraints) -> Size
fn arrange(&mut self, ctx: &mut ArrangeCtx, bounds: Rect)
fn paint(&self, ctx: &mut PaintCtx)
fn semantics(&self, ctx: &mut SemanticsCtx)
Source§fn visit_children(&self, visitor: &mut dyn WidgetPodVisitor)
fn visit_children(&self, visitor: &mut dyn WidgetPodVisitor)
Source§fn visit_children_mut(&mut self, visitor: &mut dyn WidgetPodMutVisitor)
fn visit_children_mut(&mut self, visitor: &mut dyn WidgetPodMutVisitor)
fn event(&mut self, _ctx: &mut EventCtx, _event: &Event)
Source§fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
fn debug_name(&self) -> &'static str
Source§fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
Source§fn measure_size(
&mut self,
ctx: &mut MeasureCtx,
constraints: Constraints,
) -> Size
fn measure_size( &mut self, ctx: &mut MeasureCtx, constraints: Constraints, ) -> Size
measure; it may mutate state.
Child measure calls still commit state. Use child size probes explicitly
when only their scalar results are needed.
Results must match measure for the same content and constraints.
A final measure is still required before arrangement after a probe miss.Source§fn measure_axis(
&mut self,
ctx: &mut MeasureCtx,
constraints: Constraints,
axis: Axis,
) -> f32
fn measure_axis( &mut self, ctx: &mut MeasureCtx, constraints: Constraints, axis: Axis, ) -> f32
measure_size under exactly the same constraints.
Overrides may avoid computing the other component, but must return the
same extent. Like size probes, this does not replace final measurement.Source§fn intrinsic_size(
&mut self,
ctx: &mut MeasureCtx,
axis: Axis,
available_cross: f32,
) -> IntrinsicSize
fn intrinsic_size( &mut self, ctx: &mut MeasureCtx, axis: Axis, available_cross: f32, ) -> IntrinsicSize
Source§fn supports_output_reuse(&self) -> bool
fn supports_output_reuse(&self) -> bool
fn layer_options(&self) -> LayerOptions
fn layer_properties(&self) -> LayerProperties
Source§fn layer_properties_at(&self, frame_time: f64) -> LayerProperties
fn layer_properties_at(&self, frame_time: f64) -> LayerProperties
frame_time. Override this
instead of Widget::layer_properties when they come from Motion
values; the runtime refreshes them without repainting when the motion
invalidates Transform or Effect.fn stack_host_options(&self) -> Option<StackHostOptions>
fn stack_surface_options(&self) -> Option<StackSurfaceOptions>
Source§fn overlay_options(&self) -> Option<OverlayOptions>
fn overlay_options(&self) -> Option<OverlayOptions>
fn accepts_focus(&self) -> bool
Source§fn hit_test_self(&self) -> bool
fn hit_test_self(&self) -> bool
false so those points reach what is behind
them.fn focus_changed(&mut self, _ctx: &mut EventCtx, _focused: bool)
Auto Trait Implementations§
impl<K, T> !RefUnwindSafe for KeyedStack<K, T>
impl<K, T> !Send for KeyedStack<K, T>
impl<K, T> !Sync for KeyedStack<K, T>
impl<K, T> !UnwindSafe for KeyedStack<K, T>
impl<K, T> Forget for KeyedStack<K, T>
impl<K, T> Freeze for KeyedStack<K, T>
impl<K, T> Move for KeyedStack<K, T>
impl<K, T> Unpin for KeyedStack<K, T>
impl<K, T> UnsafeUnpin for KeyedStack<K, T>where
Arc<dyn Observable<Vec<T>>>: UnsafeUnpin,
Box<dyn Fn(&T) -> K>: UnsafeUnpin,
Box<dyn Fn(&K, Signal<T>) -> Box<dyn Widget>>: UnsafeUnpin,
Vec<StackEntry<K, T>>: UnsafeUnpin,
Option<Vec<T>>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.