Viewport: Only zoom in/out at vertical wheel events
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Sun, 16 Dec 2012 01:16:32 +0000 (19:16 -0600)
committerUwe Hermann <uwe@hermann-uwe.de>
Fri, 21 Dec 2012 16:50:17 +0000 (17:50 +0100)
Viewport always zoomed the signals in and out on a wheel event. Moving the
scroll wheel up or down caused the intended effect of zooming in or zooming out,
respectively. This works flawlessly on mice with only a vertical wheel.

On mice with a horizontal or tilting wheel, horizontal scrolling or tilting was
still treated as zooming in and out. This created a non-intuitive experience,
as the user expects the signals to scroll left or right with this gesture.

Check to make sure the wheel event is a vertical one, and only then zoom in/out.
Do nothing if the wheel event is not vertical.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
pv/view/viewport.cpp

index 6ce52abc28c4a362cf798fac507e4187c311cef7..2b03b76723147852cede33b727fa6e549785d21d 100644 (file)
@@ -115,7 +115,11 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
 void Viewport::wheelEvent(QWheelEvent *event)
 {
        assert(event);
-       _view.zoom(event->delta() / 120, event->x());
+
+       if (event->orientation() == Qt::Vertical) {
+               // Vertical scrolling is interpreted as zooming in/out
+               _view.zoom(event->delta() / 120, event->x());
+       }
 }
 
 void Viewport::draw_cursors_background(QPainter &p)