From 0d6a432ef510d6a3b4a855acd4ab85815e502b36 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 10 Nov 2017 18:24:06 -0300 Subject: [PATCH] Zoom timeline with Ctrl+mouse wheel --- src/app/ui/timeline/timeline.cpp | 41 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/app/ui/timeline/timeline.cpp b/src/app/ui/timeline/timeline.cpp index bfeb1f893..193bfadcf 100644 --- a/src/app/ui/timeline/timeline.cpp +++ b/src/app/ui/timeline/timeline.cpp @@ -1204,22 +1204,39 @@ bool Timeline::onProcessMessage(Message* msg) case kMouseWheelMessage: if (m_document) { gfx::Point delta = static_cast(msg)->wheelDelta(); - if (!static_cast(msg)->preciseWheel()) { - delta.x *= frameBoxWidth(); - delta.y *= layerBoxHeight(); + const bool precise = static_cast(msg)->preciseWheel(); - if (delta.x == 0 && // On macOS shift already changes the wheel axis - msg->shiftPressed()) { - if (std::fabs(delta.y) > delta.x) - std::swap(delta.x, delta.y); + // Zoom timeline + if (msg->ctrlPressed() || // TODO configurable + msg->cmdPressed()) { + double dz = delta.x + delta.y; + + if (precise) { + dz /= 1.5; + if (dz < -1.0) dz = -1.0; + else if (dz > 1.0) dz = 1.0; } - if (msg->altPressed()) { - delta.x *= 3; - delta.y *= 3; - } + setZoomAndUpdate(m_zoom - dz); + } + else { + if (!precise) { + delta.x *= frameBoxWidth(); + delta.y *= layerBoxHeight(); + + if (delta.x == 0 && // On macOS shift already changes the wheel axis + msg->shiftPressed()) { + if (std::fabs(delta.y) > delta.x) + std::swap(delta.x, delta.y); + } + + if (msg->altPressed()) { + delta.x *= 3; + delta.y *= 3; + } + } + setViewScroll(viewScroll() + delta); } - setViewScroll(viewScroll() + delta); } break;