diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 8105eb47..fa9949a8 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -21,6 +21,9 @@ RackScrollWidget::RackScrollWidget() { } void RackScrollWidget::step() { + // Clamp zoom + settings::zoom = math::clamp(settings::zoom, 0.25f, 2.f); + // Round zoom to nearest percent float zoom = std::round(settings::zoom / 0.01) * 0.01; if (zoom != zoomWidget->zoom) { // Set offset based on zoomPos @@ -102,7 +105,6 @@ void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) { if (settings::invertZoom) zoomDelta *= -1; settings::zoom *= std::pow(2, zoomDelta); - settings::zoom = math::clamp(settings::zoom, 0.25f, 2.f); zoomPos = e.pos; e.consume(this); return; diff --git a/src/app/Scene.cpp b/src/app/Scene.cpp index 35caf3ae..81aaa074 100644 --- a/src/app/Scene.cpp +++ b/src/app/Scene.cpp @@ -120,6 +120,24 @@ void Scene::onHoverKey(const event::HoverKey &e) { e.consume(this); } } break; + case GLFW_KEY_MINUS: { + if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { + float z = std::log2(settings::zoom); + z *= 2; + z = std::ceil(z - 0.01) - 1; + z /= 2; + settings::zoom = std::pow(2, z); + } + } break; + case GLFW_KEY_EQUAL: { + if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { + float z = std::log2(settings::zoom); + z *= 2; + z = std::floor(z + 0.01) + 1; + z /= 2; + settings::zoom = std::pow(2, z); + } + } break; case GLFW_KEY_ENTER: case GLFW_KEY_KP_ENTER: { moduleBrowser->show();