diff --git a/helper.py b/helper.py index e67fa54f..f6287a80 100755 --- a/helper.py +++ b/helper.py @@ -117,7 +117,7 @@ Plugin *pluginInstance; void init(Plugin *p) { pluginInstance = p; - // Add modules here, e.g. + // Add modules here // p->addModel(modelMyModule); // Any other plugin initialization may go here. @@ -397,6 +397,7 @@ struct {identifier} : Module {{""" source += f""" + struct {identifier}Widget : ModuleWidget {{ {identifier}Widget({identifier} *module) {{ setModule(module); diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 26b3558a..4762cf60 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -176,16 +176,16 @@ struct EditButton : MenuButton { struct ZoomQuantity : Quantity { void setValue(float value) override { - settings::zoom = math::clamp(value, getMinValue(), getMaxValue()); + settings::zoom = value; } float getValue() override { return settings::zoom; } - float getMinValue() override {return 0.25;} + float getMinValue() override {return -2.0;} float getMaxValue() override {return 2.0;} - float getDefaultValue() override {return 1.0;} - float getDisplayValue() override {return std::round(getValue() * 100);} - void setDisplayValue(float displayValue) override {setValue(displayValue / 100);} + float getDefaultValue() override {return 0.0;} + float getDisplayValue() override {return std::round(std::pow(2.f, getValue()) * 100);} + void setDisplayValue(float displayValue) override {setValue(std::log2(displayValue / 100));} std::string getLabel() override {return "Zoom";} std::string getUnit() override {return "%";} }; diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index cc7808cd..cab32d84 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -22,9 +22,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; + settings::zoom = math::clamp(settings::zoom, -2.f, 2.f); + // Compute zoom from exponential zoom + float zoom = std::pow(2.f, settings::zoom); if (zoom != zoomWidget->zoom) { // Set offset based on zoomPos offset = offset.plus(zoomPos).div(zoomWidget->zoom).mult(zoom).minus(zoomPos); @@ -123,7 +123,7 @@ void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) { float zoomDelta = e.scrollDelta.y / 50 / 4; if (settings::invertZoom) zoomDelta *= -1; - settings::zoom *= std::pow(2, zoomDelta); + settings::zoom += zoomDelta; zoomPos = e.pos; e.consume(this); return; diff --git a/src/app/Scene.cpp b/src/app/Scene.cpp index 4ba81c25..379c4523 100644 --- a/src/app/Scene.cpp +++ b/src/app/Scene.cpp @@ -122,21 +122,21 @@ void Scene::onHoverKey(const event::HoverKey &e) { } break; case GLFW_KEY_MINUS: { if ((e.mods & RACK_MOD_MASK) == RACK_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); + float zoom = settings::zoom; + zoom *= 2; + zoom = std::ceil(zoom - 0.01) - 1; + zoom /= 2; + settings::zoom = zoom; e.consume(this); } } break; case GLFW_KEY_EQUAL: { if ((e.mods & RACK_MOD_MASK) == RACK_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); + float zoom = settings::zoom; + zoom *= 2; + zoom = std::floor(zoom + 0.01) + 1; + zoom /= 2; + settings::zoom = zoom; e.consume(this); } } break;