Skip to main content

InteractionState

Struct InteractionState 

Source
pub struct InteractionState {
    pub knob_regions: Vec<WidgetRegion>,
    pub drags: Vec<DragState>,
    pub hover_idx: Option<usize>,
    pub dropdown: Option<DropdownState>,
    pub popup_drag: Option<PopupDrag>,
    /* private fields */
}
Expand description

Tracks the current mouse / touch interaction state.

Fields§

§knob_regions: Vec<WidgetRegion>§drags: Vec<DragState>

One entry per active pointer (mouse: at most 1; touch: up to one per finger). Keyed by DragState::pointer_id. Linear scan - N is bounded by the device’s reported max touches (≤10 in practice).

§hover_idx: Option<usize>

Region index under the cursor (for hover highlight).

§dropdown: Option<DropdownState>

Currently open dropdown popup (at most one at a time).

§popup_drag: Option<PopupDrag>

Active touch-drag on the open dropdown popup - set on MouseDown inside the popup, updated on MouseMove (mapping vertical motion to scroll_offset change), cleared on MouseUp. iOS pattern: tap to select, swipe to scroll. Desktop scroll-wheel handling stays through the Scroll event.

Implementations§

Source§

impl InteractionState

Source

pub fn take_repaint_request(&mut self) -> bool

Read and clear the explicit repaint flag set by event handlers.

Source

pub fn build_regions(&mut self, layout: &PluginLayout)

Rebuild hit regions from the layout. Call after render.

Source

pub fn hit_test(&self, mx: f32, my: f32) -> Option<usize>

Check if a mouse position hits a widget. Returns the region index if so.

Source

pub fn widget_type_at(&self, idx: usize) -> Option<WidgetType>

Get the widget type by region index.

Source

pub fn region_at(&self, idx: usize) -> Option<&WidgetRegion>

Get the region by index.

Source

pub fn begin_drag( &mut self, pointer_id: u64, idx: usize, current_normalized: f64, mouse_y: f32, ) -> Option<DragState>

Begin a drag on a widget by region index. Returns any prior drag for the same pointer_id so the caller can emit a matching ParamEdit::End for it - without this, hosts that model gestures as a Begin/End stack (VST3, CLAP, AU on iOS) see a stranded Begin and report the param as permanently “being touched”. iOS reliably triggers this when a system gesture recognizer (Control Center swipe, multitasking gesture) steals a touch without firing touchesCancelled:; the next touchesBegan: may reuse the same UITouch* pointer for a different finger.

Source

pub fn drag_for(&self, pointer_id: u64) -> Option<&DragState>

Find the drag for a pointer (read-only).

Source

pub fn update_drag(&self, pointer_id: u64, mouse_y: f32) -> Option<(u32, f64)>

Update a single drag’s knob value (vertical-drag widgets). Returns the new (param_id, normalized value) for the drag matching pointer_id, or None if no such drag is active.

Source

pub fn update_slider_drag( &self, pointer_id: u64, mouse_x: f32, ) -> Option<(u32, f64)>

Update a single horizontal-slider drag. Same shape as InteractionState::update_drag but maps x rather than y.

Source

pub fn end_drag(&mut self, pointer_id: u64) -> Option<DragState>

End the drag for pointer_id. Returns the popped state so callers can emit the ParamEdit::End (and the y-axis End on XY pads) without re-searching the vec.

Source

pub fn dropdown_popup_hit(&self, mx: f32, my: f32) -> Option<usize>

Test if a point is inside the open dropdown popup. Returns the absolute option index (accounting for scroll) if hit, or None.

Source

pub fn dropdown_update_hover(&mut self, mx: f32, my: f32)

Update the hovered option in the open dropdown popup.

Source

pub fn dropdown_is_open(&self) -> bool

Whether a dropdown popup is currently open.

Source

pub fn dropdown_close(&mut self) -> Option<usize>

Close the dropdown popup. Returns the region index of the dropdown that was open, so the caller can suppress an immediate-reopen click landing on the same button without having to read self.dropdown before closing.

Source

pub fn dropdown_scroll(&mut self, delta: i32)

Scroll the dropdown popup by delta items (positive = down, negative = up).

Source

pub fn build_regions_any(&mut self, layout: &Layout)

Rebuild hit regions from either layout variant.

Source

pub fn build_regions_grid(&mut self, layout: &GridLayout)

Rebuild hit regions from a grid layout.

Trait Implementations§

Source§

impl Default for InteractionState

Source§

fn default() -> InteractionState

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.