Added button (icon TODO) in toolbar to save the current patch into template.vcv (instead of having to know that we must save it with this name)pull/1081/head
@@ -170,6 +170,7 @@ struct RackWidget : OpaqueWidget { | |||||
/** Disconnects all wires */ | /** Disconnects all wires */ | ||||
void disconnect(); | void disconnect(); | ||||
void save(std::string filename); | void save(std::string filename); | ||||
void setAsDefaultPatch(); | |||||
void load(std::string filename); | void load(std::string filename); | ||||
json_t *toJson(); | json_t *toJson(); | ||||
void fromJson(json_t *rootJ); | void fromJson(json_t *rootJ); | ||||
@@ -95,6 +95,12 @@ void RackScene::onHoverKey(EventHoverKey &e) { | |||||
e.consumed = true; | e.consumed = true; | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_D: { | |||||
if (windowIsModPressed() && windowIsShiftPressed()) { | |||||
gRackWidget->setAsDefaultPatch(); | |||||
e.consumed = true; | |||||
} | |||||
} break; | |||||
case GLFW_KEY_V: { | case GLFW_KEY_V: { | ||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | if (windowIsModPressed() && !windowIsShiftPressed()) { | ||||
gRackWidget->pastePresetClipboard(); | gRackWidget->pastePresetClipboard(); | ||||
@@ -139,6 +139,11 @@ void RackWidget::save(std::string filename) { | |||||
json_decref(rootJ); | json_decref(rootJ); | ||||
} | } | ||||
void RackWidget::setAsDefaultPatch() { | |||||
info("Saving current patch as default one in 'tempalte.vcv'"); | |||||
save(assetLocal("template.vcv")); | |||||
} | |||||
void RackWidget::load(std::string filename) { | void RackWidget::load(std::string filename) { | ||||
info("Loading patch %s", filename.c_str()); | info("Loading patch %s", filename.c_str()); | ||||
FILE *file = fopen(filename.c_str(), "r"); | FILE *file = fopen(filename.c_str(), "r"); | ||||
@@ -69,6 +69,16 @@ struct SaveAsButton : TooltipIconButton { | |||||
} | } | ||||
}; | }; | ||||
struct SetAsDefaultPatchButton : TooltipIconButton { | |||||
SetAsDefaultPatchButton() { | |||||
setSVG(SVG::load(assetGlobal("res/icons/noun_1343811_cc.svg"))); | |||||
tooltipText = "Set patch as default (" WINDOW_MOD_KEY_NAME "+Shift+D)"; | |||||
} | |||||
void onAction(EventAction &e) override { | |||||
gRackWidget->setAsDefaultPatch(); | |||||
} | |||||
}; | |||||
struct RevertButton : TooltipIconButton { | struct RevertButton : TooltipIconButton { | ||||
RevertButton() { | RevertButton() { | ||||
setSVG(SVG::load(assetGlobal("res/icons/noun_1084369_cc.svg"))); | setSVG(SVG::load(assetGlobal("res/icons/noun_1084369_cc.svg"))); | ||||
@@ -170,6 +180,7 @@ Toolbar::Toolbar() { | |||||
layout->addChild(new OpenButton()); | layout->addChild(new OpenButton()); | ||||
layout->addChild(new SaveButton()); | layout->addChild(new SaveButton()); | ||||
layout->addChild(new SaveAsButton()); | layout->addChild(new SaveAsButton()); | ||||
layout->addChild(new SetAsDefaultPatchButton()); | |||||
layout->addChild(new RevertButton()); | layout->addChild(new RevertButton()); | ||||
layout->addChild(new DisconnectCablesButton()); | layout->addChild(new DisconnectCablesButton()); | ||||