feat(plot): crosshair with an interpolated per-signal hover readout

This commit is contained in:
Martino Ferrari committed 2026-09-28 18:57:33 +02:00
1 parent a153b73ead
commit fd0c471430
11 files changed
+809 -22

No files matched your search

+22
View File
@@ -124,6 +124,18 @@ using plot::RegionGrab;
/// the same answer for a host that wants it directly -- a resize cursor, a tooltip,
/// a status line.
///
/// ## The crosshair (spec §15)
///
/// A pointer over the data area places the plot's crosshair at the data coordinates under
/// it (`Plot::set_crosshair()`), and a pointer that leaves `axes` clears it
/// (`Plot::clear_crosshair()`). That is a *hover*, not a gesture: no button is involved, and
/// a press, a wheel notch or a key stroke that moves the data under the pointer re-anchors
/// the crosshair to the same pointer position rather than clearing it -- it follows the
/// pointer, so anything the pointer did not move leaves it where the pointer is. The
/// per-signal values a readout shows are the plot's (`PlotLayout::crosshair`), not this
/// layer's: the controller says where the pointer is and nothing about what a crosshair
/// means.
///
/// ## Zoom and pan on a live x axis (spec §12)
///
/// An x axis armed with `XFollow::Live` keeps following through every gesture
@@ -262,6 +274,16 @@ class Controller {
/// leave alone, the bounds and the grabbed data x a body move needs to preserve
/// the width -- so a changed pointer motion never accumulates error.
bool begin_handle_drag(const PointerEvent& e);
/// Places the plot's crosshair under the pointer, or clears it when the pointer is not
/// over the data area (spec §15). Called after every event that can move the pointer *or*
/// the data under it -- a pointer event, a wheel notch, a key stroke, a viewport change --
/// so the crosshair is where the pointer is and reads the data the frame will draw, and
/// never at a coordinate a zoom has already moved out from under it.
///
/// A press does not clear it: the crosshair follows the pointer, and a pointer that is
/// still over the axes is still pointing at whatever gesture just started. The pointer is
/// the only thing that clears it, by leaving `axes`.
void update_crosshair(f32 px, f32 py);
/// Publishes what the pointer is on to the plot, for the renderer to highlight
/// (see HotHandles). Called after every event that can move the geometry under the
/// pointer -- a pointer event, a wheel notch, a key stroke -- so hover and grab are