Skip to content

Commit

Permalink
Zoom timeline with Ctrl+mouse wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Nov 10, 2017
1 parent c13f627 commit 0d6a432
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/app/ui/timeline/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,22 +1204,39 @@ bool Timeline::onProcessMessage(Message* msg)
case kMouseWheelMessage:
if (m_document) {
gfx::Point delta = static_cast<MouseMessage*>(msg)->wheelDelta();
if (!static_cast<MouseMessage*>(msg)->preciseWheel()) {
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);
const bool precise = static_cast<MouseMessage*>(msg)->preciseWheel();

// 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;

Expand Down

0 comments on commit 0d6a432

Please sign in to comment.