fix(input): refuse a non-finite wheel amount instead of zeroing it

Zeroing an unusable wheel amount turned it into a zero-notch zoom: the factor was
exactly one, the range did not change, but the zoom body still ran through
set_x_range/set_y_range, which clear auto_scale unconditionally. One garbage wheel
therefore disarmed auto-fit on every axis. on_wheel now rejects an unusable amount
before the event can mutate anything, keeping the position fallback.

The tests that should have caught it are strengthened: the wheel case now asserts
auto scale is still armed (it was passing either way), and the invalid-position
case checks a pan measured from the last real position with the drag alive, rather
than a range nothing could have moved.
This commit is contained in:
Martino Ferrari committed 2026-09-28 01:03:07 +02:00
1 parent b5b9b42be1
commit dc0a977c86
4 files changed
+41 -6

No files matched your search

+5
View File
@@ -66,6 +66,11 @@ class Controller {
/// user can neither pan nor zoom back. The buttons in the same event are still
/// acted on, so a drag whose release arrives with a bad position still ends.
void on_pointer(const PointerEvent& e);
/// Same, and a wheel amount that is not a number is *refused* rather than
/// zeroed: a zero-notch zoom changes no range but still goes through the range
/// setters, which clear auto scale -- so a sanitised amount would quietly disarm
/// auto-fit. An unusable amount leaves the plot exactly as it was; an unusable
/// *position* only loses its anchor, falling back to the last known one.
void on_wheel(const WheelEvent& e);
void on_key(const KeyEvent& e);