From: Alexandru Gagniuc Date: Sun, 16 Dec 2012 01:16:32 +0000 (-0600) Subject: Viewport: Only zoom in/out at vertical wheel events X-Git-Tag: pulseview-0.1.0~190 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ffd5cd208c277b148d0e3a85d49330149f02f0c8;p=pulseview.git Viewport: Only zoom in/out at vertical wheel events 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 --- diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 6ce52abc..2b03b767 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -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)