| @@ -50,7 +50,9 @@ struct ModuleWidget : OpaqueWidget { | |||||
| /** Resets the parameters of the module and calls the Module's randomize(). | /** Resets the parameters of the module and calls the Module's randomize(). | ||||
| Called when the user clicks Initialize in the context menu. | 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(). | /** Randomizes the parameters of the module and calls the Module's randomize(). | ||||
| Called when the user clicks Randomize in the context menu. | Called when the user clicks Randomize in the context menu. | ||||
| */ | */ | ||||
| @@ -113,8 +115,10 @@ struct RackWidget : OpaqueWidget { | |||||
| RackWidget(); | RackWidget(); | ||||
| ~RackWidget(); | ~RackWidget(); | ||||
| /** Completely clear the rack's modules and wires */ | |||||
| void clear(); | void clear(); | ||||
| void initialize(); | |||||
| /** Clears the rack and loads the template patch */ | |||||
| void reset(); | |||||
| void openDialog(); | void openDialog(); | ||||
| void saveDialog(); | void saveDialog(); | ||||
| void saveAsDialog(); | void saveAsDialog(); | ||||
| @@ -56,8 +56,10 @@ struct Module { | |||||
| virtual void fromJson(json_t *root) {} | virtual void fromJson(json_t *root) {} | ||||
| /** Override these to implement spacial behavior when user clicks Initialize and Randomize */ | /** Override these to implement spacial behavior when user clicks Initialize and Randomize */ | ||||
| virtual void initialize() {} | |||||
| virtual void reset() {} | |||||
| virtual void randomize() {} | virtual void randomize() {} | ||||
| /** Deprecated */ | |||||
| virtual void initialize() final {} | |||||
| }; | }; | ||||
| struct Wire { | struct Wire { | ||||
| @@ -103,12 +103,12 @@ void ModuleWidget::disconnect() { | |||||
| } | } | ||||
| } | } | ||||
| void ModuleWidget::initialize() { | |||||
| void ModuleWidget::reset() { | |||||
| for (ParamWidget *param : params) { | for (ParamWidget *param : params) { | ||||
| param->setValue(param->defaultValue); | param->setValue(param->defaultValue); | ||||
| } | } | ||||
| if (module) { | if (module) { | ||||
| module->initialize(); | |||||
| module->reset(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -170,7 +170,7 @@ Widget *ModuleWidget::onHoverKey(Vec pos, int key) { | |||||
| switch (key) { | switch (key) { | ||||
| case GLFW_KEY_I: | case GLFW_KEY_I: | ||||
| if (guiIsModPressed() && !guiIsShiftPressed()) { | if (guiIsModPressed() && !guiIsShiftPressed()) { | ||||
| initialize(); | |||||
| reset(); | |||||
| return this; | return this; | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -211,10 +211,10 @@ struct DisconnectMenuItem : MenuItem { | |||||
| } | } | ||||
| }; | }; | ||||
| struct InitializeMenuItem : MenuItem { | |||||
| struct ResetMenuItem : MenuItem { | |||||
| ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
| void onAction() override { | void onAction() override { | ||||
| moduleWidget->initialize(); | |||||
| moduleWidget->reset(); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -248,7 +248,7 @@ Menu *ModuleWidget::createContextMenu() { | |||||
| menuLabel->text = model->plugin->name + ": " + model->name; | menuLabel->text = model->plugin->name + ": " + model->name; | ||||
| menu->pushChild(menuLabel); | menu->pushChild(menuLabel); | ||||
| InitializeMenuItem *resetItem = new InitializeMenuItem(); | |||||
| ResetMenuItem *resetItem = new ResetMenuItem(); | |||||
| resetItem->text = "Initialize"; | resetItem->text = "Initialize"; | ||||
| resetItem->rightText = GUI_MOD_KEY_NAME "+I"; | resetItem->rightText = GUI_MOD_KEY_NAME "+I"; | ||||
| resetItem->moduleWidget = this; | resetItem->moduleWidget = this; | ||||
| @@ -86,7 +86,7 @@ Widget *RackScene::onHoverKey(Vec pos, int key) { | |||||
| switch (key) { | switch (key) { | ||||
| case GLFW_KEY_N: | case GLFW_KEY_N: | ||||
| if (guiIsModPressed() && !guiIsShiftPressed()) { | if (guiIsModPressed() && !guiIsShiftPressed()) { | ||||
| gRackWidget->initialize(); | |||||
| gRackWidget->reset(); | |||||
| return this; | return this; | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -38,7 +38,7 @@ void RackWidget::clear() { | |||||
| lastPath = ""; | lastPath = ""; | ||||
| } | } | ||||
| void RackWidget::initialize() { | |||||
| void RackWidget::reset() { | |||||
| clear(); | clear(); | ||||
| loadPatch(assetLocal("template.vcv")); | loadPatch(assetLocal("template.vcv")); | ||||
| } | } | ||||
| @@ -8,7 +8,7 @@ namespace rack { | |||||
| struct NewItem : MenuItem { | struct NewItem : MenuItem { | ||||
| void onAction() override { | void onAction() override { | ||||
| gRackWidget->initialize(); | |||||
| gRackWidget->reset(); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -118,7 +118,7 @@ struct AudioInterface : Module { | |||||
| } | } | ||||
| } | } | ||||
| void initialize() override { | |||||
| void reset() override { | |||||
| closeDevice(); | closeDevice(); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -259,7 +259,7 @@ struct MIDIToCVInterface : MidiIO, Module { | |||||
| baseFromJson(rootJ); | baseFromJson(rootJ); | ||||
| } | } | ||||
| virtual void initialize() { | |||||
| virtual void reset() { | |||||
| setPortId(-1); | setPortId(-1); | ||||
| } | } | ||||
| @@ -534,7 +534,7 @@ struct MIDICCToCVInterface : MidiIO, Module { | |||||
| } | } | ||||
| } | } | ||||
| virtual void initialize() { | |||||
| virtual void reset() { | |||||
| setPortId(-1); | setPortId(-1); | ||||
| } | } | ||||