fix(input): refuse non-finite region bounds, keep narrow regions movable, republish hot handles

This commit is contained in:
Martino Ferrari committed 2026-09-28 14:08:11 +02:00
1 parent 4681d7015b
commit 7cc06f07f5
7 files changed
+263 -19

No files matched your search

+11
View File
@@ -161,6 +161,12 @@ class Plot {
/// onto the sample grid as it is added -- exactly as `add_cursor()` places a
/// snapping cursor -- so a region handed to a plot that already holds samples is on
/// the grid from its first frame.
///
/// A region whose bounds are not both finite is *refused*: nothing is added, and the
/// returned id names no region (`region()` reads a default for it and `region_count()`
/// does not count it). Storing one would be worse than useless, because a `Free` region
/// holding a bound that is not a number could never be dragged back -- every motion
/// re-derives both bounds from the stored ones.
u32 add_region(const Region& region);
// --- accessors --------------------------------------------------------
@@ -340,6 +346,11 @@ class Plot {
/// bounds under the pointer and put them on the sample grid once, on release,
/// instead of both ends sticking as the pointer moves. Also drops the region's
/// cached statistics.
///
/// A pair of bounds that is not both finite is *refused*: `std::min`/`std::max` would
/// propagate a NaN through both stored bounds and a finite partner would be lost with
/// it, so a rejected call changes nothing at all -- the interval stays as it was, and
/// so do the statistics cached for it.
void set_region(u32 id, f64 x0, f64 x1);
/// Pulls a snapping region's bounds onto the sample grid: onto the nearest sample
+5 -3
View File
@@ -20,9 +20,11 @@ enum class RegionSnap {
/// The bounds are **ordered**: `Plot::set_region()` stores their min and max, so
/// `x0 > x1` cannot be held however the bounds arrived -- which is what keeps a
/// drag that crosses one bound over the other a *swap* (the region stays draggable
/// and never turns inside out) rather than a degenerate interval. The interval is
/// inclusive of both ends: the samples a region covers are those whose x is at or
/// after `x0` and at or before `x1`.
/// and never turns inside out) rather than a degenerate interval. A pair that is not
/// both finite is not a pair of bounds and is refused rather than stored (see
/// `Plot::set_region()`); the bounds below are finite once the region is in a plot.
/// The interval is inclusive of both ends: the samples a region covers are those whose x
/// is at or after `x0` and at or before `x1`.
///
/// A region names no x axis, unlike a cursor: it shades an interval of the plot's
/// data area as a whole -- the rect `PlotLayout::axes` and the grid are built from