| @@ -17,11 +17,12 @@ struct RackScrollWidget : ui::ScrollWidget { | |||
| math::Vec oldOffset; | |||
| RackScrollWidget(); | |||
| void reset(); | |||
| void step() override; | |||
| void draw(const DrawArgs& args) override; | |||
| void onHoverKey(const event::HoverKey& e) override; | |||
| void onHoverScroll(const event::HoverScroll& e) override; | |||
| void reset(); | |||
| void onHover(const event::Hover& e) override; | |||
| }; | |||
| @@ -32,8 +32,6 @@ struct Scene : widget::OpaqueWidget { | |||
| void onDragHover(const event::DragHover& e) override; | |||
| void onHoverKey(const event::HoverKey& e) override; | |||
| void onPathDrop(const event::PathDrop& e) override; | |||
| void runCheckVersion(); | |||
| }; | |||
| @@ -46,7 +46,7 @@ extern bool tooltips; | |||
| extern bool cpuMeter; | |||
| extern bool lockModules; | |||
| extern int frameSwapInterval; | |||
| extern float autosavePeriod; | |||
| extern float autosaveInterval; | |||
| extern bool skipLoadOnLaunch; | |||
| extern std::string patchPath; | |||
| extern std::list<std::string> recentPatchPaths; | |||
| @@ -5,9 +5,6 @@ | |||
| #include <app/MenuBar.hpp> | |||
| #include <widget/OpaqueWidget.hpp> | |||
| #include <window.hpp> | |||
| #include <engine/Engine.hpp> | |||
| #include <asset.hpp> | |||
| #include <ui/Button.hpp> | |||
| #include <ui/MenuItem.hpp> | |||
| #include <ui/MenuSeparator.hpp> | |||
| @@ -16,6 +13,9 @@ | |||
| #include <ui/TextField.hpp> | |||
| #include <ui/PasswordField.hpp> | |||
| #include <ui/ProgressBar.hpp> | |||
| #include <engine/Engine.hpp> | |||
| #include <window.hpp> | |||
| #include <asset.hpp> | |||
| #include <context.hpp> | |||
| #include <settings.hpp> | |||
| #include <helpers.hpp> | |||
| @@ -20,6 +20,13 @@ RackScrollWidget::RackScrollWidget() { | |||
| reset(); | |||
| } | |||
| void RackScrollWidget::reset() { | |||
| offset = RACK_OFFSET.mult(zoomWidget->zoom); | |||
| offset = offset.minus(math::Vec(30, 30)); | |||
| } | |||
| void RackScrollWidget::step() { | |||
| // Clamp zoom | |||
| settings::zoom = math::clamp(settings::zoom, -2.f, 2.f); | |||
| @@ -78,10 +85,12 @@ void RackScrollWidget::step() { | |||
| oldOffset = offset; | |||
| } | |||
| void RackScrollWidget::draw(const DrawArgs& args) { | |||
| ScrollWidget::draw(args); | |||
| } | |||
| void RackScrollWidget::onHoverKey(const event::HoverKey& e) { | |||
| ScrollWidget::onHoverKey(e); | |||
| if (e.isConsumed()) | |||
| @@ -116,6 +125,7 @@ void RackScrollWidget::onHoverKey(const event::HoverKey& e) { | |||
| } | |||
| } | |||
| void RackScrollWidget::onHoverScroll(const event::HoverScroll& e) { | |||
| if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| // Increase zoom | |||
| @@ -131,9 +141,14 @@ void RackScrollWidget::onHoverScroll(const event::HoverScroll& e) { | |||
| ScrollWidget::onHoverScroll(e); | |||
| } | |||
| void RackScrollWidget::reset() { | |||
| offset = RACK_OFFSET.mult(zoomWidget->zoom); | |||
| offset = offset.minus(math::Vec(30, 30)); | |||
| void RackScrollWidget::onHover(const event::Hover& e) { | |||
| ScrollWidget::onHover(e); | |||
| // Hide menu bar if fullscreen and moving mouse over the RackScrollWidget | |||
| if (APP->window->isFullScreen()) { | |||
| APP->scene->menuBar->hide(); | |||
| } | |||
| } | |||
| @@ -56,9 +56,16 @@ Scene::~Scene() { | |||
| } | |||
| void Scene::step() { | |||
| bool fullscreen = APP->window->isFullScreen(); | |||
| menuBar->visible = !fullscreen; | |||
| rackScroll->box.pos.y = menuBar->visible ? menuBar->box.size.y : 0; | |||
| if (APP->window->isFullScreen()) { | |||
| // Expand RackScrollWidget to cover entire screen if fullscreen | |||
| rackScroll->box.pos.y = 0; | |||
| } | |||
| else { | |||
| // Always show MenuBar if not fullscreen | |||
| menuBar->show(); | |||
| rackScroll->box.pos.y = menuBar->box.size.y; | |||
| } | |||
| frameRateWidget->box.pos.x = box.size.x - frameRateWidget->box.size.x; | |||
| // Resize owned descendants | |||
| @@ -66,9 +73,9 @@ void Scene::step() { | |||
| rackScroll->box.size = box.size.minus(rackScroll->box.pos); | |||
| // Autosave periodically | |||
| if (settings::autosavePeriod > 0.0) { | |||
| if (settings::autosaveInterval > 0.0) { | |||
| double time = glfwGetTime(); | |||
| if (time - lastAutosaveTime >= settings::autosavePeriod) { | |||
| if (time - lastAutosaveTime >= settings::autosaveInterval) { | |||
| lastAutosaveTime = time; | |||
| APP->patch->saveAutosave(); | |||
| settings::save(asset::settingsPath); | |||
| @@ -84,6 +91,9 @@ void Scene::draw(const DrawArgs& args) { | |||
| void Scene::onHover(const event::Hover& e) { | |||
| mousePos = e.pos; | |||
| if (mousePos.y < menuBar->box.size.y) { | |||
| menuBar->show(); | |||
| } | |||
| OpaqueWidget::onHover(e); | |||
| } | |||
| @@ -169,6 +179,8 @@ void Scene::onHoverKey(const event::HoverKey& e) { | |||
| } | |||
| if (e.key == GLFW_KEY_F11 && (e.mods & RACK_MOD_MASK) == 0) { | |||
| APP->window->setFullScreen(!APP->window->isFullScreen()); | |||
| // The MenuBar will be hidden when the mouse moves over the RackScrollWidget. | |||
| // menuBar->hide(); | |||
| e.consume(this); | |||
| } | |||
| // Alternate key command for exiting fullscreen, since F11 doesn't work reliably on Mac due to "Show desktop" OS binding. | |||
| @@ -37,7 +37,7 @@ bool lockModules = false; | |||
| #else | |||
| int frameSwapInterval = 1; | |||
| #endif | |||
| float autosavePeriod = 15.0; | |||
| float autosaveInterval = 15.0; | |||
| bool skipLoadOnLaunch = false; | |||
| std::string patchPath; | |||
| std::list<std::string> recentPatchPaths; | |||
| @@ -90,7 +90,7 @@ json_t* toJson() { | |||
| json_object_set_new(rootJ, "frameSwapInterval", json_integer(frameSwapInterval)); | |||
| json_object_set_new(rootJ, "autosavePeriod", json_real(autosavePeriod)); | |||
| json_object_set_new(rootJ, "autosaveInterval", json_real(autosaveInterval)); | |||
| if (skipLoadOnLaunch) | |||
| json_object_set_new(rootJ, "skipLoadOnLaunch", json_boolean(true)); | |||
| @@ -196,9 +196,9 @@ void fromJson(json_t* rootJ) { | |||
| if (frameSwapIntervalJ) | |||
| frameSwapInterval = json_integer_value(frameSwapIntervalJ); | |||
| json_t* autosavePeriodJ = json_object_get(rootJ, "autosavePeriod"); | |||
| if (autosavePeriodJ) | |||
| autosavePeriod = json_number_value(autosavePeriodJ); | |||
| json_t* autosaveIntervalJ = json_object_get(rootJ, "autosaveInterval"); | |||
| if (autosaveIntervalJ) | |||
| autosaveInterval = json_number_value(autosaveIntervalJ); | |||
| json_t* skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch"); | |||
| if (skipLoadOnLaunchJ) | |||