Browse Source

Add Ctrl-- and Ctrl-= for zooming in and out.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
98bd228c17
2 changed files with 21 additions and 1 deletions
  1. +3
    -1
      src/app/RackScrollWidget.cpp
  2. +18
    -0
      src/app/Scene.cpp

+ 3
- 1
src/app/RackScrollWidget.cpp View File

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


+ 18
- 0
src/app/Scene.cpp View File

@@ -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();


Loading…
Cancel
Save