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
impl InteractionState
Sourcepub fn take_repaint_request(&mut self) -> bool
pub fn take_repaint_request(&mut self) -> bool
Read and clear the explicit repaint flag set by event handlers.
Sourcepub fn build_regions(&mut self, layout: &PluginLayout)
pub fn build_regions(&mut self, layout: &PluginLayout)
Rebuild hit regions from the layout. Call after render.
Sourcepub fn hit_test(&self, mx: f32, my: f32) -> Option<usize>
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.
Sourcepub fn widget_type_at(&self, idx: usize) -> Option<WidgetType>
pub fn widget_type_at(&self, idx: usize) -> Option<WidgetType>
Get the widget type by region index.
Sourcepub fn region_at(&self, idx: usize) -> Option<&WidgetRegion>
pub fn region_at(&self, idx: usize) -> Option<&WidgetRegion>
Get the region by index.
Sourcepub fn begin_drag(
&mut self,
pointer_id: u64,
idx: usize,
current_normalized: f64,
mouse_y: f32,
) -> Option<DragState>
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.
Sourcepub fn drag_for(&self, pointer_id: u64) -> Option<&DragState>
pub fn drag_for(&self, pointer_id: u64) -> Option<&DragState>
Find the drag for a pointer (read-only).
Sourcepub fn update_drag(&self, pointer_id: u64, mouse_y: f32) -> Option<(u32, f64)>
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.
Sourcepub fn update_slider_drag(
&self,
pointer_id: u64,
mouse_x: f32,
) -> Option<(u32, f64)>
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.
Sourcepub fn end_drag(&mut self, pointer_id: u64) -> Option<DragState>
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.
Sourcepub fn dropdown_popup_hit(&self, mx: f32, my: f32) -> Option<usize>
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.
Sourcepub fn dropdown_update_hover(&mut self, mx: f32, my: f32)
pub fn dropdown_update_hover(&mut self, mx: f32, my: f32)
Update the hovered option in the open dropdown popup.
Sourcepub fn dropdown_is_open(&self) -> bool
pub fn dropdown_is_open(&self) -> bool
Whether a dropdown popup is currently open.
Sourcepub fn dropdown_close(&mut self) -> Option<usize>
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.
Sourcepub fn dropdown_scroll(&mut self, delta: i32)
pub fn dropdown_scroll(&mut self, delta: i32)
Scroll the dropdown popup by delta items (positive = down, negative = up).
Sourcepub fn build_regions_any(&mut self, layout: &Layout)
pub fn build_regions_any(&mut self, layout: &Layout)
Rebuild hit regions from either layout variant.
Sourcepub fn build_regions_grid(&mut self, layout: &GridLayout)
pub fn build_regions_grid(&mut self, layout: &GridLayout)
Rebuild hit regions from a grid layout.