Skip to main content

InteractionTracker

Struct InteractionTracker 

Source
pub struct InteractionTracker { /* private fields */ }
Expand description

Reusable stateful interaction tracker (see the module docs).

Implementations§

Source§

impl InteractionTracker

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn clear_drag_over_slice(&mut self) -> &[NodeId]

Clears :drag-over on every node (zero-alloc steady state).

Source

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

Source

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.

Source

pub fn focus_anchor(&self) -> &FocusAnchor

Source

pub fn focus_anchor_mut(&mut self) -> &mut FocusAnchor

Source

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

pub fn set_focus( &mut self, target: Option<NodeId>, modality: FocusModality, ) -> &[NodeId]

Moves focus to target under modality (zero-alloc steady state). Attempting to focus a disabled node is ignored without disturbing existing focus.

Source

pub fn blur(&mut self) -> &[NodeId]

Clears focus from the currently focused node.

Source§

impl InteractionTracker

Source

pub fn new() -> Self

Source

pub fn hovered(&self) -> Option<NodeId>

Source

pub fn active(&self) -> Option<NodeId>

Source

pub fn hovered_chain(&self) -> &[NodeId]

Source

pub fn active_chain(&self) -> &[NodeId]

Source

pub fn active_key(&self) -> Option<PointerKey>

The primary pointer whose press owns :active.

Source

pub fn drag_over(&self) -> Option<NodeId>

Source

pub fn drag_over_chain(&self) -> &[NodeId]

Source

pub fn drag_entered(&self) -> &[NodeId]

Top-down (root -> leaf) nodes that entered :drag-over on the latest drag-over update.

Source

pub fn drag_exited(&self) -> &[NodeId]

Bottom-up (leaf -> root) nodes that exited :drag-over on the latest drag-over update.

Source

pub fn pointers(&self) -> &PointerTable

The active pointers.

Source

pub fn pointers_mut(&mut self) -> &mut PointerTable

Mutable active pointers (capture requests, settings-imposed capacity).

Source

pub fn captured(&self) -> Option<(PointerKey, NodeId)>

(pointer, capture target) of the primary pointer, when it is captured.

Source

pub fn captured_node(&self) -> Option<NodeId>

The primary pointer’s capture target.

Source

pub fn focused(&self) -> Option<NodeId>

Source

pub fn focus_modality(&self) -> FocusModality

Source

pub fn last_input_modality(&self) -> FocusModality

Source

pub fn is_disabled(&self, id: NodeId) -> bool

Source

pub fn entered(&self) -> &[NodeId]

Top-down (root -> leaf) nodes that entered hover during the latest pointer transition.

Source

pub fn exited(&self) -> &[NodeId]

Bottom-up (leaf -> root) nodes that exited hover during the latest pointer transition.

Source

pub fn last_dirty(&self) -> &[NodeId]

Sorted, deduplicated dirty NodeIds from the latest transition.

Source

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.

Source

pub fn state(&self, id: NodeId) -> InteractionState

Computes the exact active InteractionState flags for id (O(chains); pointer slots never feed the cascade).

Source

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.

Source

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).

Source

pub fn remove_node_slice(&mut self, id: NodeId) -> &[NodeId]

Removes id from all tracked chains, captures, focus, and disabled state (zero-alloc).

Source

pub fn clear(&mut self)

Resets all tracked interaction state (retaining scratch capacity).

Trait Implementations§

Source§

impl Clone for InteractionTracker

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InteractionTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InteractionTracker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.