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) -> Self
pub fn new<O, KF, B, W>(axis: Axis, items: O, key_for: KF, build: B) -> Self
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) -> Self
pub fn horizontal<O, KF, B, W>(items: O, key_for: KF, build: B) -> Self
pub fn gap(self, gap: f32) -> Self
Sourcepub fn alignment(self, alignment: Alignment) -> Self
pub fn alignment(self, alignment: Alignment) -> Self
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) -> Self
pub fn transition(self, transition: PresenceTransition) -> Self
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) -> Self
pub fn stagger(self, stagger: Stagger) -> Self
Delays for items that arrive together; Stagger::NONE brings them
in at once.
Sourcepub fn move_spec(self, spec: Option<AnimationSpec>) -> Self
pub fn move_spec(self, spec: Option<AnimationSpec>) -> Self
How items glide to new places, or None to move them at once.
Sourcepub fn appear(self, appear: bool) -> Self
pub fn appear(self, appear: bool) -> Self
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.