Add kinetic panning to hand-drag scrolling#250
Conversation
Add inertial hand-drag scrolling to PlotView and expose it as a persisted Kinetic panning checkbox in the controls dock. The view now tracks drag velocity, continues panning after release with deceleration, and stops kinetic motion when the user presses, wheels, opens a context menu, or hits scrollbar limits. The controls wiring persists the toggle in QSettings and defaults new users to enabled. PlotView state touched during startup is also initialized explicitly to keep the startup path clean under valgrind. Verification: - cmake --build build -j4 - QT_QPA_PLATFORM=offscreen valgrind --error-exitcode=1 --quiet build/src/inspectrum --help
|
This sounds like a handy feature, but I'm curious why you implemented it manually rather than using QScroller? |
|
Mostly for risk and control. The current view already has a fairly custom mouse pipeline:
Given that, the manual implementation let me add fling behavior only to the existing background ScrollHandDrag path in src/plotview.cpp:83, without reworking gesture ownership or risking conflicts with cursor/tuner drags. It also made the stop conditions explicit: kill kinetic motion on press, wheel, context menu, or scrollbar clamp in src/plotview.cpp:312 and src/plotview.cpp:697. QScroller would have been a reasonable alternative, but it usually wants to own more of the gesture model. In this app, that was the bigger integration risk than the inertial math itself. The manual path was the smaller, more predictable change. My expectation is that it may need extra work to avoid fighting the existing left-drag interactions and the current “hand drag vs cursor drag” split. |
Add inertial hand-drag scrolling to PlotView and expose it as a persisted Kinetic panning checkbox in the controls dock.
The view now tracks drag velocity, continues panning after release with deceleration, and stops kinetic motion when the user presses, wheels, opens a context menu, or hits scrollbar limits. The controls wiring persists the toggle in QSettings and defaults new users to enabled. PlotView state touched during startup is also initialized explicitly to keep the startup path clean under valgrind.
out.webm