Skip to content

Add kinetic panning to hand-drag scrolling#250

Open
rthomp10 wants to merge 1 commit into
miek:mainfrom
rthomp10:main
Open

Add kinetic panning to hand-drag scrolling#250
rthomp10 wants to merge 1 commit into
miek:mainfrom
rthomp10:main

Conversation

@rthomp10

Copy link
Copy Markdown

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

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
@miek

miek commented Mar 22, 2026

Copy link
Copy Markdown
Owner

This sounds like a handy feature, but I'm curious why you implemented it manually rather than using QScroller?

@rthomp10

rthomp10 commented Apr 7, 2026

Copy link
Copy Markdown
Author

Mostly for risk and control. The current view already has a fairly custom mouse pipeline:

  • PlotView forwards raw mouse events to plots and cursors first in src/plotview.cpp:348.
  • Cursor-range dragging consumes left-drag events in src/cursors.cpp:67.
  • The tuner also consumes its own cursor drags in src/tuner.cpp:66.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants