pub struct VisualView<S: Spec> { /* private fields */ }Expand description
Read-only per-window truth of this frame, built at the start of the compose phase (design §5.2, read path a).
Owned, not borrowed: the compose phase mutates the input engine
(registrations) while hooks hold the view, so the engine views cannot
be lent out; the copied state is exactly what the engines reported at
phase start, which is the same-tick truth the design asks the view to
be. Clicks are the last evaluated frame’s (a release is evaluated by
the EndFrame of the compose that saw it and read back from the next
compose on — one frame of latency, like every retained-registration
immediate-mode UI).
Implementations§
Source§impl<S: Spec> VisualView<S>
impl<S: Spec> VisualView<S>
Sourcepub fn is_hovered(&self, id: &WidgetId) -> bool
pub fn is_hovered(&self, id: &WidgetId) -> bool
id is under the pointer.
Sourcepub fn hover_path(&self) -> &[WidgetId]
pub fn hover_path(&self) -> &[WidgetId]
The hovered widget and its register_child ancestors, root first:
everything CSS :hover matches.
Sourcepub fn is_hover_within(&self, id: &WidgetId) -> bool
pub fn is_hover_within(&self, id: &WidgetId) -> bool
id is hovered or contains the hovered widget (:hover on a
parent).
Sourcepub fn hover_changes(&self) -> (Vec<WidgetId>, Vec<WidgetId>)
pub fn hover_changes(&self) -> (Vec<WidgetId>, Vec<WidgetId>)
The mouseleave / mouseenter sets since the last compose: left
deepest first, entered outermost first; common ancestors get
neither (they do not bubble).
Sourcepub fn focus_path(&self) -> &[WidgetId]
pub fn focus_path(&self) -> &[WidgetId]
The focused widget and its ancestors, root first (empty when nothing
is focused): everything CSS :focus-within matches.
Sourcepub fn is_focus_within(&self, id: &WidgetId) -> bool
pub fn is_focus_within(&self, id: &WidgetId) -> bool
id is focused or contains the focused widget (:focus-within).
Sourcepub fn dispatch_focus(&self, handler: impl FnMut(FocusEvent, &mut EventCx<'_>))
pub fn dispatch_focus(&self, handler: impl FnMut(FocusEvent, &mut EventCx<'_>))
Dispatch the focus move since the last compose DOM-style: blur
and focusout (bubbling) on the old focus path, then focus and
focusin (bubbling) on the new one. Nothing fires without a move.
Sourcepub fn dispatch_clicks(&self, handler: impl FnMut(&mut EventCx<'_>, u8))
pub fn dispatch_clicks(&self, handler: impl FnMut(&mut EventCx<'_>, u8))
Dispatch last frame’s clicks DOM-style: per click a capture leg
root → parent, the target, a bubble leg parent → root, honouring
stop_propagation / prevent_default. The handler also gets the
click count.
Sourcepub fn is_pressed(&self, id: &WidgetId) -> bool
pub fn is_pressed(&self, id: &WidgetId) -> bool
id is being pressed.
Sourcepub fn focus_visible(&self) -> bool
pub fn focus_visible(&self) -> bool
:focus-visible: the focus came from the keyboard. Paint focus
rings only when this is true (text fields show focus regardless).
Sourcepub fn is_focused(&self, id: &WidgetId) -> bool
pub fn is_focused(&self, id: &WidgetId) -> bool
id has keyboard focus.
Sourcepub fn clicked(&self, id: &WidgetId) -> bool
pub fn clicked(&self, id: &WidgetId) -> bool
id was clicked in the last evaluated frame (single, double or
triple — see VisualView::click_count).
Sourcepub fn click_count(&self, id: &WidgetId) -> u8
pub fn click_count(&self, id: &WidgetId) -> u8
The click count id was last clicked with (0 = not clicked,
1 single, 2 double, 3 triple).
Sourcepub fn clicks(&self) -> &[(WidgetId, u8)]
pub fn clicks(&self) -> &[(WidgetId, u8)]
Every widget clicked in the last evaluated frame, with counts.
Sourcepub fn scroll_precise(&self) -> bool
pub fn scroll_precise(&self) -> bool
The frame’s scroll came from pixel deltas (trackpad / smooth wheel).
Sourcepub fn pointer(&self) -> Option<(f64, f64)>
👎Deprecated: ignores z-order; use pointer_over(id), or raw_pointer() when the raw position is really meant
pub fn pointer(&self) -> Option<(f64, f64)>
ignores z-order; use pointer_over(id), or raw_pointer() when the raw position is really meant
Last pointer position in window coordinates, if known.
Raw position: it ignores z-order, so hover drawn from it shows
through drawers, popups and modals painted on top. Prefer
Self::pointer_over; opt in with Self::raw_pointer.
Sourcepub fn raw_pointer(&self) -> Option<(f64, f64)>
pub fn raw_pointer(&self) -> Option<(f64, f64)>
The raw pointer position, whatever lies on top of it (opt-in, not
z-order safe: never draw hover from it; ask Self::pointer_over).
Sourcepub fn pointer_over(&self, id: &WidgetId) -> Option<(f64, f64)>
pub fn pointer_over(&self, id: &WidgetId) -> Option<(f64, f64)>
The pointer position when id is the one topmost hit target under
it (or one of its register_child ancestors), or holds the press of
a drag (pointer capture). None when anything — a drawer, popup or
modal on a higher layer, an occluder — covers id there. Custom-drawn
areas (terminals, canvases) register one widget and ask this before
showing hover, hit-testing their content or taking a press.
Sourcepub fn scroll_over(&self, id: &WidgetId) -> (f64, f64)
pub fn scroll_over(&self, id: &WidgetId) -> (f64, f64)
This frame’s wheel delta (lines) when id is the topmost target
under the pointer, else zero. See Self::pointer_over.
Sourcepub fn context_click(&self) -> Option<(f64, f64)>
pub fn context_click(&self) -> Option<(f64, f64)>
Secondary-button (context menu) release in this frame, window coords.
A pointer button is held.
Sourcepub fn press_origin(&self) -> Option<(f64, f64)>
pub fn press_origin(&self) -> Option<(f64, f64)>
Where the held press went down (window coords), while a button is held on a widget. Drags anchor here so the grabbed point stays under the pointer: the first frame that sees the press may already see the pointer a few pixels further.
// Grab offset inside the card, fixed for the whole drag.
let (px, py) = view.pressed_at(id)?;
let grab = (px - card.0, py - card.1);
let (x, y) = view.raw_pointer()?;
Some((x - grab.0, y - grab.1)) // the card's new originSourcepub fn pressed_at(&self, id: &WidgetId) -> Option<(f64, f64)>
pub fn pressed_at(&self, id: &WidgetId) -> Option<(f64, f64)>
Self::press_origin when id holds the press.
Sourcepub fn selection(&self, id: &WidgetId) -> Option<TextSelection>
pub fn selection(&self, id: &WidgetId) -> Option<TextSelection>
The plain-text selection of a selectable widget (reported through
Widgets::selectables), to paint its highlight.
Sourcepub fn overlay_open(&self, id: S::Overlay) -> bool
pub fn overlay_open(&self, id: S::Overlay) -> bool
This overlay is open in the window.
Sourcepub fn open_overlays(&self) -> &[S::Overlay]
pub fn open_overlays(&self) -> &[S::Overlay]
Every open overlay of the window, bottom to top.