From c362112e89d1e74f3ca5bf55bdb5ebb52304adb8 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 17 Sep 2017 02:15:06 -0400 Subject: [PATCH] Command line open patches, Ctrl+N for New Patch, Ctrl+Q for quit --- include/app.hpp | 1 + src/app/RackScene.cpp | 20 ++++++++++++++++++++ src/main.cpp | 7 +++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/app.hpp b/include/app.hpp index 07862c9c..8112e136 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -305,6 +305,7 @@ struct RackScene : Scene { RackScene(); void step(); void draw(NVGcontext *vg); + Widget *onHoverKey(Vec pos, int key); }; //////////////////// diff --git a/src/app/RackScene.cpp b/src/app/RackScene.cpp index a8dc8401..304c17d7 100644 --- a/src/app/RackScene.cpp +++ b/src/app/RackScene.cpp @@ -29,5 +29,25 @@ void RackScene::draw(NVGcontext *vg) { Scene::draw(vg); } +Widget *RackScene::onHoverKey(Vec pos, int key) { + switch (key) { + case GLFW_KEY_N: + if (guiIsModPressed()) { + gRackWidget->clear(); + return this; + } + break; + case GLFW_KEY_Q: + if (guiIsModPressed()) { + glfwSetWindowShouldClose(gWindow, GLFW_TRUE); + return this; + } + break; + } + + return Widget::onHoverKey(pos, key); +} + + } // namespace rack diff --git a/src/main.cpp b/src/main.cpp index 39846603..be4f1072 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,7 @@ void fixCwd() { using namespace rack; -int main() { +int main(int argc, char* argv[]) { #if ARCH_MAC fixCwd(); #endif @@ -98,7 +98,10 @@ int main() { guiInit(); sceneInit(); settingsLoad("settings.json"); - gRackWidget->loadPatch("autosave.json"); + if (argc >= 2) + gRackWidget->loadPatch(argv[1]); + else + gRackWidget->loadPatch("autosave.json"); engineStart(); guiRun();