pub struct InteractionTracker { /* private fields */ }Expand description
Reusable stateful interaction tracker (see the module docs).
Implementations§
Source§impl InteractionTracker
impl InteractionTracker
Sourcepub fn pointer_move_with(
&mut self,
key: PointerKey,
target: Option<NodeId>,
parent_of: impl Fn(NodeId) -> Option<NodeId>,
) -> &[NodeId]
pub fn pointer_move_with( &mut self, key: PointerKey, target: Option<NodeId>, parent_of: impl Fn(NodeId) -> Option<NodeId>, ) -> &[NodeId]
Moves key to target (zero-alloc steady state).
Only the primary hover-capable pointer, while not captured, updates :hover
(Self::exited bottom-up, Self::entered top-down); when it owns an uncaptured press
it also cancels :active on ancestors no longer hovered (press-cancel on drag-off).
Sourcepub fn pointer_leave_slice(&mut self) -> &[NodeId]
pub fn pointer_leave_slice(&mut self) -> &[NodeId]
Clears hover when the pointer exits the surface/window (zero-alloc steady state).
Preserves :active and every capture while the press owning :active is captured, so
captured drags survive CursorLeft.
Sourcepub fn pointer_down_with(
&mut self,
key: PointerKey,
at: [f32; 2],
ts: TimestampUs,
target: Option<NodeId>,
parent_of: impl Fn(NodeId) -> Option<NodeId>,
) -> Result<bool, PointerOverflow>
pub fn pointer_down_with( &mut self, key: PointerKey, at: [f32; 2], ts: TimestampUs, target: Option<NodeId>, parent_of: impl Fn(NodeId) -> Option<NodeId>, ) -> Result<bool, PointerOverflow>
Activates key on target at at (zero-alloc steady state), returning whether it is the
primary pointer. The primary pointer’s chain (minus disabled nodes) becomes :active;
a hover-capable primary also moves :hover. Secondary pointers change no pseudo-state.
A full table refuses the contact.
Sourcepub fn pointer_up_with(
&mut self,
key: PointerKey,
target: Option<NodeId>,
parent_of: impl Fn(NodeId) -> Option<NodeId>,
) -> PointerEnd
pub fn pointer_up_with( &mut self, key: PointerKey, target: Option<NodeId>, parent_of: impl Fn(NodeId) -> Option<NodeId>, ) -> PointerEnd
Ends key on release over target (zero-alloc steady state), releasing only its own
capture. A primary pointer clears :active and reports the click target; a hover-capable
primary moves :hover to target.
Sourcepub fn pointer_cancel(&mut self, key: PointerKey) -> PointerEnd
pub fn pointer_cancel(&mut self, key: PointerKey) -> PointerEnd
Cancels key (zero-alloc steady state), releasing only its own capture: a primary pointer
drops :active, and a hover-capable primary also drops :hover.
Sourcepub fn pointer_cancel_all(&mut self) -> &[NodeId]
pub fn pointer_cancel_all(&mut self) -> &[NodeId]
Cancels every pointer interaction (window blur): ends every pointer and clears :hover,
:active and :drag-over (zero-alloc steady state).
Sourcepub fn set_drag_over_with(
&mut self,
target: Option<NodeId>,
parent_of: impl Fn(NodeId) -> Option<NodeId>,
) -> &[NodeId]
pub fn set_drag_over_with( &mut self, target: Option<NodeId>, parent_of: impl Fn(NodeId) -> Option<NodeId>, ) -> &[NodeId]
Updates :drag-over ancestor chain to target with zero steady-state heap allocations.
Populates Self::drag_exited (bottom-up) and Self::drag_entered (top-down) so
hosts can emit non-flickering DragLeave/DragEnter transitions without recomposition.
Sourcepub fn clear_drag_over_slice(&mut self) -> &[NodeId]
pub fn clear_drag_over_slice(&mut self) -> &[NodeId]
Clears :drag-over on every node (zero-alloc steady state).
Sourcepub fn clear_active_slice(&mut self) -> &[NodeId]
pub fn clear_active_slice(&mut self) -> &[NodeId]
Clears :active without disturbing hover (a press promoted into a drag, so the release
never synthesizes a stray Press).
Source§impl InteractionTracker
impl InteractionTracker
Sourcepub fn record_input_modality(&mut self, modality: FocusModality)
pub fn record_input_modality(&mut self, modality: FocusModality)
Records the most recent user-initiated input modality (Pointer or Keyboard),
which drives :focus-visible for subsequent programmatic focus transitions.
pub fn focus_anchor(&self) -> &FocusAnchor
pub fn focus_anchor_mut(&mut self) -> &mut FocusAnchor
Sourcepub fn set_focus_ex(
&mut self,
target: Option<NodeId>,
modality: FocusModality,
is_text_entry: bool,
) -> &[NodeId]
pub fn set_focus_ex( &mut self, target: Option<NodeId>, modality: FocusModality, is_text_entry: bool, ) -> &[NodeId]
Moves focus to target under modality with explicit is_text_entry classification
(zero-alloc steady state). Attempting to focus a disabled node is ignored.
Source§impl InteractionTracker
impl InteractionTracker
pub fn new() -> Self
pub fn hovered(&self) -> Option<NodeId>
pub fn active(&self) -> Option<NodeId>
pub fn hovered_chain(&self) -> &[NodeId]
pub fn active_chain(&self) -> &[NodeId]
Sourcepub fn active_key(&self) -> Option<PointerKey>
pub fn active_key(&self) -> Option<PointerKey>
The primary pointer whose press owns :active.
pub fn drag_over(&self) -> Option<NodeId>
pub fn drag_over_chain(&self) -> &[NodeId]
Sourcepub fn drag_entered(&self) -> &[NodeId]
pub fn drag_entered(&self) -> &[NodeId]
Top-down (root -> leaf) nodes that entered :drag-over on the latest drag-over update.
Sourcepub fn drag_exited(&self) -> &[NodeId]
pub fn drag_exited(&self) -> &[NodeId]
Bottom-up (leaf -> root) nodes that exited :drag-over on the latest drag-over update.
Sourcepub fn pointers(&self) -> &PointerTable
pub fn pointers(&self) -> &PointerTable
The active pointers.
Sourcepub fn pointers_mut(&mut self) -> &mut PointerTable
pub fn pointers_mut(&mut self) -> &mut PointerTable
Mutable active pointers (capture requests, settings-imposed capacity).
Sourcepub fn captured(&self) -> Option<(PointerKey, NodeId)>
pub fn captured(&self) -> Option<(PointerKey, NodeId)>
(pointer, capture target) of the primary pointer, when it is captured.
Sourcepub fn captured_node(&self) -> Option<NodeId>
pub fn captured_node(&self) -> Option<NodeId>
The primary pointer’s capture target.
pub fn focused(&self) -> Option<NodeId>
pub fn focus_modality(&self) -> FocusModality
pub fn last_input_modality(&self) -> FocusModality
pub fn is_disabled(&self, id: NodeId) -> bool
Sourcepub fn entered(&self) -> &[NodeId]
pub fn entered(&self) -> &[NodeId]
Top-down (root -> leaf) nodes that entered hover during the latest pointer transition.
Sourcepub fn exited(&self) -> &[NodeId]
pub fn exited(&self) -> &[NodeId]
Bottom-up (leaf -> root) nodes that exited hover during the latest pointer transition.
Sourcepub fn last_dirty(&self) -> &[NodeId]
pub fn last_dirty(&self) -> &[NodeId]
Sorted, deduplicated dirty NodeIds from the latest transition.
Sourcepub fn active_cursor_node(&self) -> Option<NodeId>
pub fn active_cursor_node(&self) -> Option<NodeId>
Returns the node that currently governs the window pointer cursor:
prefers the primary capture, then active, falling back to hovered.
Sourcepub fn state(&self, id: NodeId) -> InteractionState
pub fn state(&self, id: NodeId) -> InteractionState
Computes the exact active InteractionState flags for id (O(chains); pointer slots
never feed the cascade).
Sourcepub fn set_disabled_slice(&mut self, id: NodeId, disabled: bool) -> &[NodeId]
pub fn set_disabled_slice(&mut self, id: NodeId, disabled: bool) -> &[NodeId]
Marks id disabled or enabled (zero-alloc when disabled set already has capacity).
Disabling clears active, focused, and every pointer capture on id.
Sourcepub fn prune_disconnected(&mut self, keep: impl FnMut(NodeId) -> bool) -> bool
pub fn prune_disconnected(&mut self, keep: impl FnMut(NodeId) -> bool) -> bool
Prunes nodes where keep(id) is false from hover, active, drag-over, and every pointer
capture (0-alloc).
Sourcepub fn remove_node_slice(&mut self, id: NodeId) -> &[NodeId]
pub fn remove_node_slice(&mut self, id: NodeId) -> &[NodeId]
Removes id from all tracked chains, captures, focus, and disabled state (zero-alloc).