diff --git a/include/app.hpp b/include/app.hpp index 66cd3a9b..1e63ac83 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -50,7 +50,9 @@ struct ModuleWidget : OpaqueWidget { /** Resets the parameters of the module and calls the Module's randomize(). Called when the user clicks Initialize in the context menu. */ - virtual void initialize(); + virtual void reset(); + /** Deprecated */ + virtual void initialize() final {} /** Randomizes the parameters of the module and calls the Module's randomize(). Called when the user clicks Randomize in the context menu. */ @@ -113,8 +115,10 @@ struct RackWidget : OpaqueWidget { RackWidget(); ~RackWidget(); + /** Completely clear the rack's modules and wires */ void clear(); - void initialize(); + /** Clears the rack and loads the template patch */ + void reset(); void openDialog(); void saveDialog(); void saveAsDialog(); diff --git a/include/engine.hpp b/include/engine.hpp index 93a89ccb..b2f897b3 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -56,8 +56,10 @@ struct Module { virtual void fromJson(json_t *root) {} /** Override these to implement spacial behavior when user clicks Initialize and Randomize */ - virtual void initialize() {} + virtual void reset() {} virtual void randomize() {} + /** Deprecated */ + virtual void initialize() final {} }; struct Wire { diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index f9a19314..1d768575 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -103,12 +103,12 @@ void ModuleWidget::disconnect() { } } -void ModuleWidget::initialize() { +void ModuleWidget::reset() { for (ParamWidget *param : params) { param->setValue(param->defaultValue); } if (module) { - module->initialize(); + module->reset(); } } @@ -170,7 +170,7 @@ Widget *ModuleWidget::onHoverKey(Vec pos, int key) { switch (key) { case GLFW_KEY_I: if (guiIsModPressed() && !guiIsShiftPressed()) { - initialize(); + reset(); return this; } break; @@ -211,10 +211,10 @@ struct DisconnectMenuItem : MenuItem { } }; -struct InitializeMenuItem : MenuItem { +struct ResetMenuItem : MenuItem { ModuleWidget *moduleWidget; void onAction() override { - moduleWidget->initialize(); + moduleWidget->reset(); } }; @@ -248,7 +248,7 @@ Menu *ModuleWidget::createContextMenu() { menuLabel->text = model->plugin->name + ": " + model->name; menu->pushChild(menuLabel); - InitializeMenuItem *resetItem = new InitializeMenuItem(); + ResetMenuItem *resetItem = new ResetMenuItem(); resetItem->text = "Initialize"; resetItem->rightText = GUI_MOD_KEY_NAME "+I"; resetItem->moduleWidget = this; diff --git a/src/app/RackScene.cpp b/src/app/RackScene.cpp index 077136bb..a4c8bd81 100644 --- a/src/app/RackScene.cpp +++ b/src/app/RackScene.cpp @@ -86,7 +86,7 @@ Widget *RackScene::onHoverKey(Vec pos, int key) { switch (key) { case GLFW_KEY_N: if (guiIsModPressed() && !guiIsShiftPressed()) { - gRackWidget->initialize(); + gRackWidget->reset(); return this; } break; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index e00e3c08..74143770 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -38,7 +38,7 @@ void RackWidget::clear() { lastPath = ""; } -void RackWidget::initialize() { +void RackWidget::reset() { clear(); loadPatch(assetLocal("template.vcv")); } diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index d6681788..d0def913 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -8,7 +8,7 @@ namespace rack { struct NewItem : MenuItem { void onAction() override { - gRackWidget->initialize(); + gRackWidget->reset(); } }; diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index fde48012..69a28caa 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -118,7 +118,7 @@ struct AudioInterface : Module { } } - void initialize() override { + void reset() override { closeDevice(); } }; diff --git a/src/core/MidiInterface.cpp b/src/core/MidiInterface.cpp index e3b945c3..a07b127a 100644 --- a/src/core/MidiInterface.cpp +++ b/src/core/MidiInterface.cpp @@ -259,7 +259,7 @@ struct MIDIToCVInterface : MidiIO, Module { baseFromJson(rootJ); } - virtual void initialize() { + virtual void reset() { setPortId(-1); } @@ -534,7 +534,7 @@ struct MIDICCToCVInterface : MidiIO, Module { } } - virtual void initialize() { + virtual void reset() { setPortId(-1); }