From 489e7da6ec84a8e43c90cdec8cd4a93393af9dd6 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 23 Nov 2016 14:09:42 -0300 Subject: [PATCH] Support smooth scroll in timeline --- src/app/ui/timeline.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/ui/timeline.cpp b/src/app/ui/timeline.cpp index bb6d3332b..baec1cbb5 100644 --- a/src/app/ui/timeline.cpp +++ b/src/app/ui/timeline.cpp @@ -872,23 +872,23 @@ bool Timeline::onProcessMessage(Message* msg) case kMouseWheelMessage: if (m_document) { - int dz = static_cast(msg)->wheelDelta().y; - int dx = 0; - int dy = 0; + gfx::Point delta = static_cast(msg)->wheelDelta(); + if (!static_cast(msg)->preciseWheel()) { + delta.x *= FRMSIZE; + delta.y *= LAYSIZE; - dx += static_cast(msg)->wheelDelta().x; + if (msg->shiftPressed()) { + // On macOS shift already changes the wheel axis + if (std::fabs(delta.y) > delta.x) + std::swap(delta.x, delta.y); + } - if (msg->ctrlPressed()) - dx = dz * FRMSIZE; - else - dy = dz * LAYSIZE; - - if (msg->shiftPressed()) { - dx *= 3; - dy *= 3; + if (msg->altPressed()) { + delta.x *= 3; + delta.y *= 3; + } } - - setViewScroll(viewScroll() + gfx::Point(dx, dy)); + setViewScroll(viewScroll() + delta); } break;