diff --git a/include/app.hpp b/include/app.hpp index 419459f9..59a1b0d1 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -145,6 +145,7 @@ struct RackWidget : OpaqueWidget { WireContainer *wireContainer; std::string lastPath; Vec lastMousePos; + bool lockModules = false; RackWidget(); ~RackWidget(); diff --git a/res/icons/LICENSE.md b/res/icons/LICENSE.md index 704a7f4b..e20f4863 100644 --- a/res/icons/LICENSE.md +++ b/res/icons/LICENSE.md @@ -9,3 +9,4 @@ Cat by Nabilauzwa from the Noun Project Stopwatch by Arthur Shlain from the Noun Project Sound by Gregor Cresnar from the Noun Project Refresh by un·delivered from the Noun Project +Lock by Andres Gleixner from the Noun Project diff --git a/res/icons/noun_468341_cc.svg b/res/icons/noun_468341_cc.svg new file mode 100644 index 00000000..340ff335 --- /dev/null +++ b/res/icons/noun_468341_cc.svg @@ -0,0 +1,56 @@ + +image/svg+xml \ No newline at end of file diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index d27f8a2a..b53f6219 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -301,9 +301,11 @@ void ModuleWidget::onDragEnd(EventDragEnd &e) { } void ModuleWidget::onDragMove(EventDragMove &e) { - Rect newBox = box; - newBox.pos = gRackWidget->lastMousePos.minus(dragPos); - gRackWidget->requestModuleBoxNearest(this, newBox); + if (!gRackWidget->lockModules) { + Rect newBox = box; + newBox.pos = gRackWidget->lastMousePos.minus(dragPos); + gRackWidget->requestModuleBoxNearest(this, newBox); + } } diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index c4d45e98..4b414ad7 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -140,6 +140,15 @@ struct SampleRateButton : TooltipIconButton { } }; +struct RackLockButton : TooltipIconButton { + RackLockButton() { + setSVG(SVG::load(assetGlobal("res/icons/noun_468341_cc.svg"))); + tooltipText = "Lock modules"; + } + void onAction(EventAction &e) override { + gRackWidget->lockModules ^= true; + } +}; Toolbar::Toolbar() { @@ -176,6 +185,7 @@ Toolbar::Toolbar() { layout->addChild(new SampleRateButton()); layout->addChild(new PowerMeterButton()); + layout->addChild(new RackLockButton()); struct ZoomSlider : Slider { void onAction(EventAction &e) override {