| @@ -1,53 +0,0 @@ | |||
| #pragma once | |||
| #include "ui.hpp" | |||
| #include "app/AudioWidget.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| #include "app/common.hpp" | |||
| #include "app/Knob.hpp" | |||
| #include "app/LedDisplay.hpp" | |||
| #include "app/LightWidget.hpp" | |||
| #include "app/MidiWidget.hpp" | |||
| #include "app/ModuleLightWidget.hpp" | |||
| #include "app/ModuleWidget.hpp" | |||
| #include "app/MomentarySwitch.hpp" | |||
| #include "app/MultiLightWidget.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| #include "app/PluginManagerWidget.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "app/RackRail.hpp" | |||
| #include "app/RackScene.hpp" | |||
| #include "app/RackScrollWidget.hpp" | |||
| #include "app/RackWidget.hpp" | |||
| #include "app/SVGButton.hpp" | |||
| #include "app/SVGKnob.hpp" | |||
| #include "app/SVGPanel.hpp" | |||
| #include "app/SVGPort.hpp" | |||
| #include "app/SVGScrew.hpp" | |||
| #include "app/SVGSlider.hpp" | |||
| #include "app/SVGSwitch.hpp" | |||
| #include "app/ToggleSwitch.hpp" | |||
| #include "app/Toolbar.hpp" | |||
| #include "app/WireContainer.hpp" | |||
| #include "app/WireWidget.hpp" | |||
| namespace rack { | |||
| extern std::string gApplicationName; | |||
| extern std::string gApplicationVersion; | |||
| extern std::string gApiHost; | |||
| extern std::string gLatestVersion; | |||
| extern bool gCheckVersion; | |||
| // Easy access to "singleton" widgets | |||
| extern RackScene *gRackScene; | |||
| extern RackWidget *gRackWidget; | |||
| extern Toolbar *gToolbar; | |||
| void appInit(bool devMode); | |||
| void appDestroy(); | |||
| void appModuleBrowserCreate(); | |||
| json_t *appModuleBrowserToJson(); | |||
| void appModuleBrowserFromJson(json_t *rootJ); | |||
| } // namespace rack | |||
| @@ -1,6 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,8 +1,8 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/Widget.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "ui/TextField.hpp" | |||
| #include "app/common.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| namespace rack { | |||
| @@ -0,0 +1,13 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| namespace rack { | |||
| void moduleBrowserCreate(); | |||
| json_t *moduleBrowserToJson(); | |||
| void moduleBrowserFromJson(json_t *rootJ); | |||
| } // namespace rack | |||
| @@ -1,7 +1,7 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "ui/Menu.hpp" | |||
| #include "app/common.hpp" | |||
| #include "app/SVGPanel.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| @@ -1,5 +1,6 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,7 +1,7 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "app/ParamQuantity.hpp" | |||
| #include "app/common.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/Widget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/Widget.hpp" | |||
| namespace rack { | |||
| @@ -1,7 +1,8 @@ | |||
| #pragma once | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "app/MultiLightWidget.hpp" | |||
| #include "engine/Module.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,25 +0,0 @@ | |||
| #pragma once | |||
| #include "ui/Scene.hpp" | |||
| #include "app/common.hpp" | |||
| namespace rack { | |||
| struct ScrollWidget; | |||
| struct ZoomWidget; | |||
| struct RackScene : Scene { | |||
| ScrollWidget *scrollWidget; | |||
| ZoomWidget *zoomWidget; | |||
| RackScene(); | |||
| void step() override; | |||
| void draw(NVGcontext *vg) override; | |||
| void onHoverKey(event::HoverKey &e) override; | |||
| void onPathDrop(event::PathDrop &e) override; | |||
| }; | |||
| } // namespace rack | |||
| @@ -1,6 +1,6 @@ | |||
| #pragma once | |||
| #include "ui/ScrollWidget.hpp" | |||
| #include "app/common.hpp" | |||
| #include "ui/ScrollWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,7 +1,9 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/WireWidget.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "app/WireContainer.hpp" | |||
| #include "app/ModuleWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,5 +1,7 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| namespace rack { | |||
| @@ -12,6 +14,7 @@ struct SVGButton : FramebufferWidget { | |||
| std::shared_ptr<SVG> defaultSVG; | |||
| std::shared_ptr<SVG> activeSVG; | |||
| SVGWidget *sw; | |||
| SVGButton(); | |||
| /** If `activeSVG` is NULL, `defaultSVG` is used as the active state instead. */ | |||
| void setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> activeSVG); | |||
| @@ -1,7 +1,10 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| #include "app/Knob.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/TransformWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| namespace rack { | |||
| @@ -1,5 +1,6 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| @@ -1,6 +1,9 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,8 @@ | |||
| #pragma once | |||
| #include "common.hpp" | |||
| #include "Port.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,5 +1,8 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/Knob.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,5 +1,9 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/Widget.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| namespace rack { | |||
| @@ -0,0 +1,40 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "widgets/ZoomWidget.hpp" | |||
| #include "ui/ScrollWidget.hpp" | |||
| #include "app/RackWidget.hpp" | |||
| #include "app/Toolbar.hpp" | |||
| namespace rack { | |||
| struct Scene : OpaqueWidget { | |||
| ScrollWidget *scrollWidget; | |||
| ZoomWidget *zoomWidget; | |||
| // Convenience variables for accessing important widgets | |||
| RackWidget *rackWidget; | |||
| Toolbar *toolbar; | |||
| bool devMode = false; | |||
| // Version checking | |||
| bool checkVersion = true; | |||
| bool checkedVersion = false; | |||
| std::string latestVersion; | |||
| Scene(); | |||
| void step() override; | |||
| void draw(NVGcontext *vg) override; | |||
| void onHoverKey(event::HoverKey &e) override; | |||
| void onPathDrop(event::PathDrop &e) override; | |||
| void runCheckVersion(); | |||
| }; | |||
| extern Scene *gScene; | |||
| } // namespace rack | |||
| @@ -1,5 +1,6 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,8 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "ui/Slider.hpp" | |||
| #include "ui/RadioButton.hpp" | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,8 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "app/WireWidget.hpp" | |||
| #include "app/Port.hpp" | |||
| namespace rack { | |||
| @@ -1,5 +1,7 @@ | |||
| #pragma once | |||
| #include "app/common.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "engine/Wire.hpp" | |||
| @@ -1,12 +1,16 @@ | |||
| #pragma once | |||
| #include "../common.hpp" | |||
| #include "math.hpp" | |||
| #include <string> | |||
| #include <jansson.h> | |||
| namespace rack { | |||
| extern const std::string APP_NAME; | |||
| extern const std::string APP_VERSION; | |||
| extern const std::string API_HOST; | |||
| static const float SVG_DPI = 75.0; | |||
| static const float MM_PER_IN = 25.4; | |||
| @@ -34,8 +38,8 @@ inline Vec mm2px(Vec mm) { | |||
| static const float RACK_GRID_WIDTH = 15; | |||
| static const float RACK_GRID_HEIGHT = 380; | |||
| static const Vec RACK_GRID_SIZE = Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT); | |||
| static const std::string PRESET_FILTERS = "VCV Rack module preset (.vcvm):vcvm"; | |||
| static const std::string PATCH_FILTERS = "VCV Rack patch (.vcv):vcv"; | |||
| extern const std::string PRESET_FILTERS; | |||
| extern const std::string PATCH_FILTERS; | |||
| } // namespace rack | |||
| @@ -1,6 +1,9 @@ | |||
| #include "plugin.hpp" | |||
| #include "app.hpp" | |||
| #include "event.hpp" | |||
| #include "ui/MenuLabel.hpp" | |||
| #include "ui/MenuItem.hpp" | |||
| #include "ui/Menu.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "engine/Module.hpp" | |||
| @@ -1,4 +1,5 @@ | |||
| #pragma once | |||
| // Include most Rack headers for convenience | |||
| #include "common.hpp" | |||
| #include "math.hpp" | |||
| #include "string.hpp" | |||
| @@ -8,9 +9,71 @@ | |||
| #include "network.hpp" | |||
| #include "asset.hpp" | |||
| #include "plugin.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "window.hpp" | |||
| #include "widgets.hpp" | |||
| #include "app.hpp" | |||
| #include "ui.hpp" | |||
| #include "helpers.hpp" | |||
| #include "widgets/Widget.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "widgets/TransformWidget.hpp" | |||
| #include "widgets/ZoomWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "ui/SequentialLayout.hpp" | |||
| #include "ui/Label.hpp" | |||
| #include "ui/List.hpp" | |||
| #include "ui/MenuOverlay.hpp" | |||
| #include "ui/Tooltip.hpp" | |||
| #include "ui/TextField.hpp" | |||
| #include "ui/PasswordField.hpp" | |||
| #include "ui/ScrollWidget.hpp" | |||
| #include "ui/Slider.hpp" | |||
| #include "ui/Menu.hpp" | |||
| #include "ui/MenuEntry.hpp" | |||
| #include "ui/MenuSeparator.hpp" | |||
| #include "ui/MenuLabel.hpp" | |||
| #include "ui/MenuItem.hpp" | |||
| #include "ui/Button.hpp" | |||
| #include "ui/IconButton.hpp" | |||
| #include "ui/ChoiceButton.hpp" | |||
| #include "ui/RadioButton.hpp" | |||
| #include "ui/WindowWidget.hpp" | |||
| #include "ui/ProgressBar.hpp" | |||
| #include "app/AudioWidget.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| #include "app/Knob.hpp" | |||
| #include "app/LedDisplay.hpp" | |||
| #include "app/LightWidget.hpp" | |||
| #include "app/MidiWidget.hpp" | |||
| #include "app/ModuleLightWidget.hpp" | |||
| #include "app/ModuleWidget.hpp" | |||
| #include "app/MomentarySwitch.hpp" | |||
| #include "app/MultiLightWidget.hpp" | |||
| #include "app/ParamWidget.hpp" | |||
| #include "app/PluginManagerWidget.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "app/RackRail.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "app/RackScrollWidget.hpp" | |||
| #include "app/RackWidget.hpp" | |||
| #include "app/SVGButton.hpp" | |||
| #include "app/SVGKnob.hpp" | |||
| #include "app/SVGPanel.hpp" | |||
| #include "app/SVGPort.hpp" | |||
| #include "app/SVGScrew.hpp" | |||
| #include "app/SVGSlider.hpp" | |||
| #include "app/SVGSwitch.hpp" | |||
| #include "app/ToggleSwitch.hpp" | |||
| #include "app/Toolbar.hpp" | |||
| #include "app/WireContainer.hpp" | |||
| #include "app/WireWidget.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "engine/Input.hpp" | |||
| #include "engine/Light.hpp" | |||
| #include "engine/Module.hpp" | |||
| #include "engine/Output.hpp" | |||
| #include "engine/Param.hpp" | |||
| #include "engine/Wire.hpp" | |||
| @@ -1,24 +0,0 @@ | |||
| #pragma once | |||
| #include "widgets.hpp" | |||
| #include "ui/common.hpp" | |||
| #include "ui/SequentialLayout.hpp" | |||
| #include "ui/Label.hpp" | |||
| #include "ui/List.hpp" | |||
| #include "ui/MenuOverlay.hpp" | |||
| #include "ui/Tooltip.hpp" | |||
| #include "ui/Scene.hpp" | |||
| #include "ui/TextField.hpp" | |||
| #include "ui/PasswordField.hpp" | |||
| #include "ui/ScrollWidget.hpp" | |||
| #include "ui/Slider.hpp" | |||
| #include "ui/Menu.hpp" | |||
| #include "ui/MenuEntry.hpp" | |||
| #include "ui/MenuSeparator.hpp" | |||
| #include "ui/MenuLabel.hpp" | |||
| #include "ui/MenuItem.hpp" | |||
| #include "ui/Button.hpp" | |||
| #include "ui/IconButton.hpp" | |||
| #include "ui/ChoiceButton.hpp" | |||
| #include "ui/RadioButton.hpp" | |||
| #include "ui/WindowWidget.hpp" | |||
| #include "ui/ProgressBar.hpp" | |||
| @@ -1,4 +1,6 @@ | |||
| #pragma once | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "ui/common.hpp" | |||
| #include "ui/Button.hpp" | |||
| @@ -1,6 +1,8 @@ | |||
| #pragma once | |||
| #include "ui/common.hpp" | |||
| #include "ui/Menu.hpp" | |||
| #include "ui/MenuEntry.hpp" | |||
| #include "ui/MenuOverlay.hpp" | |||
| namespace rack { | |||
| @@ -1,13 +0,0 @@ | |||
| #pragma once | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "ui/common.hpp" | |||
| namespace rack { | |||
| struct Scene : OpaqueWidget { | |||
| }; | |||
| } // namespace rack | |||
| @@ -1,4 +1,5 @@ | |||
| #pragma once | |||
| #include "../common.hpp" | |||
| #include "blendish.h" | |||
| #define CHECKMARK_STRING "âś”" | |||
| @@ -1,8 +0,0 @@ | |||
| #pragma once | |||
| #include "widgets/Widget.hpp" | |||
| #include "widgets/TransparentWidget.hpp" | |||
| #include "widgets/OpaqueWidget.hpp" | |||
| #include "widgets/TransformWidget.hpp" | |||
| #include "widgets/ZoomWidget.hpp" | |||
| #include "widgets/SVGWidget.hpp" | |||
| #include "widgets/FramebufferWidget.hpp" | |||
| @@ -17,14 +17,14 @@ struct ModuleResizeHandle : virtual Widget { | |||
| // } | |||
| } | |||
| void onDragStart(event::DragStart &e) override { | |||
| dragX = gRackWidget->lastMousePos.x; | |||
| dragX = gScene->rackWidget->lastMousePos.x; | |||
| ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | |||
| originalBox = m->box; | |||
| } | |||
| void onDragMove(event::DragMove &e) override { | |||
| ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | |||
| float newDragX = gRackWidget->lastMousePos.x; | |||
| float newDragX = gScene->rackWidget->lastMousePos.x; | |||
| float deltaX = newDragX - dragX; | |||
| Rect newBox = originalBox; | |||
| @@ -40,7 +40,7 @@ struct ModuleResizeHandle : virtual Widget { | |||
| newBox.size.x = roundf(newBox.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | |||
| newBox.pos.x = originalBox.pos.x + originalBox.size.x - newBox.size.x; | |||
| } | |||
| gRackWidget->requestModuleBox(m, newBox); | |||
| gScene->rackWidget->requestModuleBox(m, newBox); | |||
| } | |||
| void draw(NVGcontext *vg) override { | |||
| for (float x = 5.0; x <= 10.0; x += 5.0) { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/CircularShadow.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/LedDisplay.hpp" | |||
| #include "asset.hpp" | |||
| #include "window.hpp" | |||
| #include "event.hpp" | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/LightWidget.hpp" | |||
| #include "color.hpp" | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/MidiWidget.hpp" | |||
| #include "midi.hpp" | |||
| #include "helpers.hpp" | |||
| @@ -1,10 +1,16 @@ | |||
| #include "app.hpp" | |||
| #include <set> | |||
| #include <algorithm> | |||
| #include "plugin.hpp" | |||
| #include "window.hpp" | |||
| #include "helpers.hpp" | |||
| #include "event.hpp" | |||
| #include <set> | |||
| #include <algorithm> | |||
| #include "ui/Quantity.hpp" | |||
| #include "ui/RadioButton.hpp" | |||
| #include "ui/Label.hpp" | |||
| #include "app/ModuleBrowser.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "ui/List.hpp" | |||
| #include "ui/TextField.hpp" | |||
| static const float itemMargin = 2.0; | |||
| @@ -151,10 +157,10 @@ struct ModelItem : BrowserListItem { | |||
| ModuleWidget *moduleWidget = model->createModuleWidget(); | |||
| if (!moduleWidget) | |||
| return; | |||
| gRackWidget->addModule(moduleWidget); | |||
| gScene->rackWidget->addModule(moduleWidget); | |||
| // Move module nearest to the mouse position | |||
| moduleWidget->box.pos = gRackWidget->lastMousePos.minus(moduleWidget->box.size.div(2)); | |||
| gRackWidget->requestModuleBoxNearest(moduleWidget, moduleWidget->box); | |||
| moduleWidget->box.pos = gScene->rackWidget->lastMousePos.minus(moduleWidget->box.size.div(2)); | |||
| gScene->rackWidget->requestModuleBoxNearest(moduleWidget, moduleWidget->box); | |||
| } | |||
| }; | |||
| @@ -545,16 +551,16 @@ void SearchModuleField::onSelectKey(event::SelectKey &e) { | |||
| // Global functions | |||
| void appModuleBrowserCreate() { | |||
| void moduleBrowserCreate() { | |||
| MenuOverlay *overlay = new MenuOverlay; | |||
| ModuleBrowser *moduleBrowser = new ModuleBrowser; | |||
| overlay->addChild(moduleBrowser); | |||
| gRackScene->addChild(overlay); | |||
| gScene->addChild(overlay); | |||
| } | |||
| json_t *appModuleBrowserToJson() { | |||
| json_t *moduleBrowserToJson() { | |||
| json_t *rootJ = json_object(); | |||
| json_t *favoritesJ = json_array(); | |||
| @@ -569,7 +575,7 @@ json_t *appModuleBrowserToJson() { | |||
| return rootJ; | |||
| } | |||
| void appModuleBrowserFromJson(json_t *rootJ) { | |||
| void moduleBrowserFromJson(json_t *rootJ) { | |||
| json_t *favoritesJ = json_object_get(rootJ, "favorites"); | |||
| if (favoritesJ) { | |||
| size_t i; | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/ModuleLightWidget.hpp" | |||
| namespace rack { | |||
| @@ -1,6 +1,11 @@ | |||
| #include "osdialog.h" | |||
| #include "app/ModuleWidget.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "rack.hpp" | |||
| #include "logger.hpp" | |||
| #include "system.hpp" | |||
| #include "asset.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "helpers.hpp" | |||
| #include "osdialog.h" | |||
| namespace rack { | |||
| @@ -212,10 +217,10 @@ void ModuleWidget::saveDialog() { | |||
| void ModuleWidget::disconnect() { | |||
| for (Port *input : inputs) { | |||
| gRackWidget->wireContainer->removeAllWires(input); | |||
| gScene->rackWidget->wireContainer->removeAllWires(input); | |||
| } | |||
| for (Port *output : outputs) { | |||
| gRackWidget->wireContainer->removeAllWires(output); | |||
| gScene->rackWidget->wireContainer->removeAllWires(output); | |||
| } | |||
| } | |||
| @@ -292,7 +297,7 @@ void ModuleWidget::onHover(event::Hover &e) { | |||
| // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | |||
| if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { | |||
| if (!windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->deleteModule(this); | |||
| gScene->rackWidget->deleteModule(this); | |||
| delete this; | |||
| // e.target = this; | |||
| return; | |||
| @@ -341,7 +346,7 @@ void ModuleWidget::onHoverKey(event::HoverKey &e) { | |||
| } break; | |||
| case GLFW_KEY_D: { | |||
| if (windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->cloneModule(this); | |||
| gScene->rackWidget->cloneModule(this); | |||
| e.target = this; | |||
| return; | |||
| } | |||
| @@ -359,17 +364,17 @@ void ModuleWidget::onHoverKey(event::HoverKey &e) { | |||
| } | |||
| void ModuleWidget::onDragStart(event::DragStart &e) { | |||
| dragPos = gRackWidget->lastMousePos.minus(box.pos); | |||
| dragPos = gScene->rackWidget->lastMousePos.minus(box.pos); | |||
| } | |||
| void ModuleWidget::onDragEnd(event::DragEnd &e) { | |||
| } | |||
| void ModuleWidget::onDragMove(event::DragMove &e) { | |||
| if (!gRackWidget->lockModules) { | |||
| if (!gScene->rackWidget->lockModules) { | |||
| Rect newBox = box; | |||
| newBox.pos = gRackWidget->lastMousePos.minus(dragPos); | |||
| gRackWidget->requestModuleBoxNearest(this, newBox); | |||
| newBox.pos = gScene->rackWidget->lastMousePos.minus(dragPos); | |||
| gScene->rackWidget->requestModuleBoxNearest(this, newBox); | |||
| } | |||
| } | |||
| @@ -426,14 +431,14 @@ struct ModuleLoadItem : MenuItem { | |||
| struct ModuleCloneItem : MenuItem { | |||
| ModuleWidget *moduleWidget; | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->cloneModule(moduleWidget); | |||
| gScene->rackWidget->cloneModule(moduleWidget); | |||
| } | |||
| }; | |||
| struct ModuleDeleteItem : MenuItem { | |||
| ModuleWidget *moduleWidget; | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->deleteModule(moduleWidget); | |||
| gScene->rackWidget->deleteModule(moduleWidget); | |||
| delete moduleWidget; | |||
| } | |||
| }; | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/MomentarySwitch.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/MultiLightWidget.hpp" | |||
| #include "color.hpp" | |||
| @@ -1,6 +1,12 @@ | |||
| #include <thread> | |||
| #include "system.hpp" | |||
| #include "app.hpp" | |||
| #include "app/PluginManagerWidget.hpp" | |||
| #include "ui/SequentialLayout.hpp" | |||
| #include "ui/Button.hpp" | |||
| #include "ui/ProgressBar.hpp" | |||
| #include "ui/TextField.hpp" | |||
| #include "ui/PasswordField.hpp" | |||
| #include "ui/Label.hpp" | |||
| #include "plugin.hpp" | |||
| #include "window.hpp" | |||
| #include "helpers.hpp" | |||
| @@ -1,4 +1,5 @@ | |||
| #include "app.hpp" | |||
| #include "app/Port.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "window.hpp" | |||
| #include "componentlibrary.hpp" | |||
| @@ -23,7 +24,7 @@ Port::Port() { | |||
| Port::~Port() { | |||
| // plugLight is not a child and is thus owned by the Port, so we need to delete it here | |||
| delete plugLight; | |||
| gRackWidget->wireContainer->removeAllWires(this); | |||
| gScene->rackWidget->wireContainer->removeAllWires(this); | |||
| } | |||
| void Port::step() { | |||
| @@ -40,7 +41,7 @@ void Port::step() { | |||
| } | |||
| void Port::draw(NVGcontext *vg) { | |||
| WireWidget *activeWire = gRackWidget->wireContainer->activeWire; | |||
| WireWidget *activeWire = gScene->rackWidget->wireContainer->activeWire; | |||
| if (activeWire) { | |||
| // Dim the Port if the active wire cannot plug into this Port | |||
| if (type == INPUT ? activeWire->inputPort : activeWire->outputPort) | |||
| @@ -50,7 +51,7 @@ void Port::draw(NVGcontext *vg) { | |||
| void Port::onButton(event::Button &e) { | |||
| if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| gRackWidget->wireContainer->removeTopWire(this); | |||
| gScene->rackWidget->wireContainer->removeTopWire(this); | |||
| // HACK | |||
| // Update hovered*Port of active wire if applicable | |||
| @@ -62,7 +63,7 @@ void Port::onButton(event::Button &e) { | |||
| void Port::onDragStart(event::DragStart &e) { | |||
| // Try to grab wire on top of stack | |||
| WireWidget *wire = gRackWidget->wireContainer->getTopWire(this); | |||
| WireWidget *wire = gScene->rackWidget->wireContainer->getTopWire(this); | |||
| if (type == OUTPUT && windowIsModPressed()) { | |||
| wire = NULL; | |||
| } | |||
| @@ -83,13 +84,13 @@ void Port::onDragStart(event::DragStart &e) { | |||
| else | |||
| wire->outputPort = this; | |||
| } | |||
| gRackWidget->wireContainer->setActiveWire(wire); | |||
| gScene->rackWidget->wireContainer->setActiveWire(wire); | |||
| } | |||
| void Port::onDragEnd(event::DragEnd &e) { | |||
| // FIXME | |||
| // If the source Port is deleted, this will be called, removing the cable | |||
| gRackWidget->wireContainer->commitActiveWire(); | |||
| gScene->rackWidget->wireContainer->commitActiveWire(); | |||
| } | |||
| void Port::onDragDrop(event::DragDrop &e) { | |||
| @@ -98,12 +99,12 @@ void Port::onDragDrop(event::DragDrop &e) { | |||
| void Port::onDragEnter(event::DragEnter &e) { | |||
| // Reject ports if this is an input port and something is already plugged into it | |||
| if (type == INPUT) { | |||
| WireWidget *topWire = gRackWidget->wireContainer->getTopWire(this); | |||
| WireWidget *topWire = gScene->rackWidget->wireContainer->getTopWire(this); | |||
| if (topWire) | |||
| return; | |||
| } | |||
| WireWidget *activeWire = gRackWidget->wireContainer->activeWire; | |||
| WireWidget *activeWire = gScene->rackWidget->wireContainer->activeWire; | |||
| if (activeWire) { | |||
| if (type == INPUT) | |||
| activeWire->hoveredInputPort = this; | |||
| @@ -113,7 +114,7 @@ void Port::onDragEnter(event::DragEnter &e) { | |||
| } | |||
| void Port::onDragLeave(event::DragLeave &e) { | |||
| WireWidget *activeWire = gRackWidget->wireContainer->activeWire; | |||
| WireWidget *activeWire = gScene->rackWidget->wireContainer->activeWire; | |||
| if (activeWire) { | |||
| if (type == INPUT) | |||
| activeWire->hoveredInputPort = NULL; | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/RackRail.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,5 @@ | |||
| #include "app.hpp" | |||
| #include "app/RackScrollWidget.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "window.hpp" | |||
| @@ -9,7 +10,7 @@ void RackScrollWidget::step() { | |||
| Vec pos = gMousePos; | |||
| Rect viewport = getViewport(box.zeroPos()); | |||
| // Scroll rack if dragging cable near the edge of the screen | |||
| if (gRackWidget->wireContainer->activeWire) { | |||
| if (gScene->rackWidget->wireContainer->activeWire) { | |||
| float margin = 20.0; | |||
| float speed = 15.0; | |||
| if (pos.x <= viewport.pos.x + margin) | |||
| @@ -1,8 +1,14 @@ | |||
| #include <map> | |||
| #include <algorithm> | |||
| #include "app/RackWidget.hpp" | |||
| #include "app/RackRail.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "app/ModuleBrowser.hpp" | |||
| #include "osdialog.h" | |||
| #include "rack.hpp" | |||
| #include "settings.hpp" | |||
| #include "asset.hpp" | |||
| #include "system.hpp" | |||
| #include "logger.hpp" | |||
| namespace rack { | |||
| @@ -52,7 +58,7 @@ void RackWidget::clear() { | |||
| wireContainer->clearChildren(); | |||
| moduleContainer->clearChildren(); | |||
| gRackScene->scrollWidget->offset = Vec(0, 0); | |||
| gScene->scrollWidget->offset = Vec(0, 0); | |||
| } | |||
| void RackWidget::reset() { | |||
| @@ -182,7 +188,7 @@ json_t *RackWidget::toJson() { | |||
| json_t *rootJ = json_object(); | |||
| // version | |||
| json_t *versionJ = json_string(gApplicationVersion.c_str()); | |||
| json_t *versionJ = json_string(APP_VERSION.c_str()); | |||
| json_object_set_new(rootJ, "version", versionJ); | |||
| // modules | |||
| @@ -506,7 +512,7 @@ void RackWidget::onButton(event::Button &e) { | |||
| OpaqueWidget::onButton(e); | |||
| if (e.target == this) { | |||
| if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
| appModuleBrowserCreate(); | |||
| moduleBrowserCreate(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGButton.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGKnob.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGPort.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGScrew.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGSlider.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/SVGSwitch.hpp" | |||
| namespace rack { | |||
| @@ -1,68 +1,78 @@ | |||
| #include <thread> | |||
| #include "osdialog.h" | |||
| #include "rack.hpp" | |||
| #include "system.hpp" | |||
| #include "network.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "app/ModuleBrowser.hpp" | |||
| #include "app/RackScrollWidget.hpp" | |||
| namespace rack { | |||
| RackScene::RackScene() { | |||
| Scene::Scene() { | |||
| scrollWidget = new RackScrollWidget; | |||
| { | |||
| zoomWidget = new ZoomWidget; | |||
| { | |||
| assert(!gRackWidget); | |||
| gRackWidget = new RackWidget; | |||
| zoomWidget->addChild(gRackWidget); | |||
| rackWidget = new RackWidget; | |||
| zoomWidget->addChild(rackWidget); | |||
| } | |||
| scrollWidget->container->addChild(zoomWidget); | |||
| } | |||
| addChild(scrollWidget); | |||
| gToolbar = new Toolbar; | |||
| addChild(gToolbar); | |||
| scrollWidget->box.pos.y = gToolbar->box.size.y; | |||
| toolbar = new Toolbar; | |||
| addChild(toolbar); | |||
| scrollWidget->box.pos.y = toolbar->box.size.y; | |||
| } | |||
| void RackScene::step() { | |||
| void Scene::step() { | |||
| // Resize owned descendants | |||
| gToolbar->box.size.x = box.size.x; | |||
| toolbar->box.size.x = box.size.x; | |||
| scrollWidget->box.size = box.size.minus(scrollWidget->box.pos); | |||
| // Resize to be a bit larger than the ScrollWidget viewport | |||
| gRackWidget->box.size = scrollWidget->box.size | |||
| rackWidget->box.size = scrollWidget->box.size | |||
| .minus(scrollWidget->container->box.pos) | |||
| .plus(Vec(500, 500)) | |||
| .div(zoomWidget->zoom); | |||
| Scene::step(); | |||
| OpaqueWidget::step(); | |||
| zoomWidget->box.size = gRackWidget->box.size.mult(zoomWidget->zoom); | |||
| zoomWidget->box.size = rackWidget->box.size.mult(zoomWidget->zoom); | |||
| // Request latest version from server | |||
| if (!devMode && checkVersion && !checkedVersion) { | |||
| std::thread t(&Scene::runCheckVersion, this); | |||
| t.detach(); | |||
| checkedVersion = true; | |||
| } | |||
| // Version popup message | |||
| if (!gLatestVersion.empty()) { | |||
| std::string versionMessage = string::f("Rack %s is available.\n\nYou have Rack %s.\n\nClose Rack and download new version on the website?", gLatestVersion.c_str(), gApplicationVersion.c_str()); | |||
| if (!latestVersion.empty()) { | |||
| std::string versionMessage = string::f("Rack %s is available.\n\nYou have Rack %s.\n\nClose Rack and download new version on the website?", latestVersion.c_str(), APP_VERSION.c_str()); | |||
| if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, versionMessage.c_str())) { | |||
| std::thread t(system::openBrowser, "https://vcvrack.com/"); | |||
| t.detach(); | |||
| windowClose(); | |||
| } | |||
| gLatestVersion = ""; | |||
| latestVersion = ""; | |||
| } | |||
| } | |||
| void RackScene::draw(NVGcontext *vg) { | |||
| Scene::draw(vg); | |||
| void Scene::draw(NVGcontext *vg) { | |||
| OpaqueWidget::draw(vg); | |||
| } | |||
| void RackScene::onHoverKey(event::HoverKey &e) { | |||
| Scene::onHoverKey(e); | |||
| void Scene::onHoverKey(event::HoverKey &e) { | |||
| OpaqueWidget::onHoverKey(e); | |||
| if (!e.target) { | |||
| switch (e.key) { | |||
| case GLFW_KEY_N: { | |||
| if (windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->reset(); | |||
| rackWidget->reset(); | |||
| e.target = this; | |||
| } | |||
| } break; | |||
| @@ -74,33 +84,33 @@ void RackScene::onHoverKey(event::HoverKey &e) { | |||
| } break; | |||
| case GLFW_KEY_O: { | |||
| if (windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->loadDialog(); | |||
| rackWidget->loadDialog(); | |||
| e.target = this; | |||
| } | |||
| if (windowIsModPressed() && windowIsShiftPressed()) { | |||
| gRackWidget->revert(); | |||
| rackWidget->revert(); | |||
| e.target = this; | |||
| } | |||
| } break; | |||
| case GLFW_KEY_S: { | |||
| if (windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->saveDialog(); | |||
| rackWidget->saveDialog(); | |||
| e.target = this; | |||
| } | |||
| if (windowIsModPressed() && windowIsShiftPressed()) { | |||
| gRackWidget->saveAsDialog(); | |||
| rackWidget->saveAsDialog(); | |||
| e.target = this; | |||
| } | |||
| } break; | |||
| case GLFW_KEY_V: { | |||
| if (windowIsModPressed() && !windowIsShiftPressed()) { | |||
| gRackWidget->pastePresetClipboard(); | |||
| rackWidget->pastePresetClipboard(); | |||
| e.target = this; | |||
| } | |||
| } break; | |||
| case GLFW_KEY_ENTER: | |||
| case GLFW_KEY_KP_ENTER: { | |||
| appModuleBrowserCreate(); | |||
| moduleBrowserCreate(); | |||
| e.target = this; | |||
| } break; | |||
| case GLFW_KEY_F11: { | |||
| @@ -110,18 +120,36 @@ void RackScene::onHoverKey(event::HoverKey &e) { | |||
| } | |||
| } | |||
| void RackScene::onPathDrop(event::PathDrop &e) { | |||
| void Scene::onPathDrop(event::PathDrop &e) { | |||
| if (e.paths.size() >= 1) { | |||
| const std::string &path = e.paths[0]; | |||
| if (string::extension(path) == "vcv") { | |||
| gRackWidget->load(path); | |||
| rackWidget->load(path); | |||
| e.target = this; | |||
| } | |||
| } | |||
| if (!e.target) | |||
| Scene::onPathDrop(e); | |||
| OpaqueWidget::onPathDrop(e); | |||
| } | |||
| void Scene::runCheckVersion() { | |||
| json_t *resJ = network::requestJson(network::METHOD_GET, API_HOST + "/version", NULL); | |||
| if (resJ) { | |||
| json_t *versionJ = json_object_get(resJ, "version"); | |||
| if (versionJ) { | |||
| std::string version = json_string_value(versionJ); | |||
| if (version != APP_VERSION) { | |||
| latestVersion = version; | |||
| } | |||
| } | |||
| json_decref(resJ); | |||
| } | |||
| } | |||
| Scene *gScene = NULL; | |||
| } // namespace rack | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/ToggleSwitch.hpp" | |||
| namespace rack { | |||
| @@ -1,7 +1,13 @@ | |||
| #include "app.hpp" | |||
| #include "app/Toolbar.hpp" | |||
| #include "window.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "asset.hpp" | |||
| #include "ui/Tooltip.hpp" | |||
| #include "ui/IconButton.hpp" | |||
| #include "ui/SequentialLayout.hpp" | |||
| #include "ui/Slider.hpp" | |||
| #include "app/PluginManagerWidget.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "helpers.hpp" | |||
| @@ -15,13 +21,13 @@ struct TooltipIconButton : IconButton { | |||
| tooltip = new Tooltip; | |||
| tooltip->box.pos = getAbsoluteOffset(Vec(0, BND_WIDGET_HEIGHT)); | |||
| tooltip->text = getTooltipText(); | |||
| gRackScene->addChild(tooltip); | |||
| gScene->addChild(tooltip); | |||
| } | |||
| IconButton::onEnter(e); | |||
| } | |||
| void onLeave(event::Leave &e) override { | |||
| if (tooltip) { | |||
| gRackScene->removeChild(tooltip); | |||
| gScene->removeChild(tooltip); | |||
| delete tooltip; | |||
| tooltip = NULL; | |||
| } | |||
| @@ -36,7 +42,7 @@ struct NewButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "New patch (" WINDOW_MOD_KEY_NAME "+N)";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->reset(); | |||
| gScene->rackWidget->reset(); | |||
| } | |||
| }; | |||
| @@ -46,7 +52,7 @@ struct OpenButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Open patch (" WINDOW_MOD_KEY_NAME "+O)";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->loadDialog(); | |||
| gScene->rackWidget->loadDialog(); | |||
| } | |||
| }; | |||
| @@ -56,7 +62,7 @@ struct SaveButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Save patch (" WINDOW_MOD_KEY_NAME "+S)";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->saveDialog(); | |||
| gScene->rackWidget->saveDialog(); | |||
| } | |||
| }; | |||
| @@ -66,7 +72,7 @@ struct SaveAsButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Save patch as (" WINDOW_MOD_KEY_NAME "+Shift+S)";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->saveAsDialog(); | |||
| gScene->rackWidget->saveAsDialog(); | |||
| } | |||
| }; | |||
| @@ -76,7 +82,7 @@ struct RevertButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Revert patch";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->revert(); | |||
| gScene->rackWidget->revert(); | |||
| } | |||
| }; | |||
| @@ -86,7 +92,7 @@ struct DisconnectCablesButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Disconnect cables";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->disconnect(); | |||
| gScene->rackWidget->disconnect(); | |||
| } | |||
| }; | |||
| @@ -147,7 +153,7 @@ struct RackLockButton : TooltipIconButton { | |||
| } | |||
| std::string getTooltipText() override {return "Lock modules";} | |||
| void onAction(event::Action &e) override { | |||
| gRackWidget->lockModules ^= true; | |||
| gScene->rackWidget->lockModules ^= true; | |||
| } | |||
| }; | |||
| @@ -179,10 +185,10 @@ struct WireTensionQuantity : Quantity { | |||
| struct ZoomQuantity : Quantity { | |||
| void setValue(float value) override { | |||
| gRackScene->zoomWidget->setZoom(std::round(value) / 100); | |||
| gScene->zoomWidget->setZoom(std::round(value) / 100); | |||
| } | |||
| float getValue() override { | |||
| return gRackScene->zoomWidget->zoom * 100; | |||
| return gScene->zoomWidget->zoom * 100; | |||
| } | |||
| float getMinValue() override {return 25;} | |||
| float getMaxValue() override {return 200;} | |||
| @@ -1,4 +1,4 @@ | |||
| #include "app.hpp" | |||
| #include "app/WireContainer.hpp" | |||
| namespace rack { | |||
| @@ -1,4 +1,5 @@ | |||
| #include "app.hpp" | |||
| #include "app/WireWidget.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "componentlibrary.hpp" | |||
| #include "window.hpp" | |||
| @@ -121,25 +122,25 @@ void WireWidget::updateWire() { | |||
| Vec WireWidget::getOutputPos() { | |||
| if (outputPort) { | |||
| return outputPort->getRelativeOffset(outputPort->box.zeroPos().getCenter(), gRackWidget); | |||
| return outputPort->getRelativeOffset(outputPort->box.zeroPos().getCenter(), gScene->rackWidget); | |||
| } | |||
| else if (hoveredOutputPort) { | |||
| return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), gRackWidget); | |||
| return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), gScene->rackWidget); | |||
| } | |||
| else { | |||
| return gRackWidget->lastMousePos; | |||
| return gScene->rackWidget->lastMousePos; | |||
| } | |||
| } | |||
| Vec WireWidget::getInputPos() { | |||
| if (inputPort) { | |||
| return inputPort->getRelativeOffset(inputPort->box.zeroPos().getCenter(), gRackWidget); | |||
| return inputPort->getRelativeOffset(inputPort->box.zeroPos().getCenter(), gScene->rackWidget); | |||
| } | |||
| else if (hoveredInputPort) { | |||
| return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), gRackWidget); | |||
| return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), gScene->rackWidget); | |||
| } | |||
| else { | |||
| return gRackWidget->lastMousePos; | |||
| return gScene->rackWidget->lastMousePos; | |||
| } | |||
| } | |||
| @@ -165,7 +166,7 @@ void WireWidget::draw(NVGcontext *vg) { | |||
| float opacity = 0.5; | |||
| float tension = 0.5; | |||
| WireWidget *activeWire = gRackWidget->wireContainer->activeWire; | |||
| WireWidget *activeWire = gScene->rackWidget->wireContainer->activeWire; | |||
| if (activeWire) { | |||
| // Draw as opaque if the wire is active | |||
| if (activeWire == this) | |||
| @@ -1,80 +0,0 @@ | |||
| #include "app.hpp" | |||
| #include "network.hpp" | |||
| #include <thread> | |||
| namespace rack { | |||
| std::string gApplicationName = "VCV Rack"; | |||
| std::string gApplicationVersion = TOSTRING(VERSION); | |||
| std::string gApiHost = "https://api.vcvrack.com"; | |||
| // std::string gApiHost = "http://localhost:8081"; | |||
| std::string gLatestVersion; | |||
| bool gCheckVersion = true; | |||
| RackWidget *gRackWidget = NULL; | |||
| Toolbar *gToolbar = NULL; | |||
| RackScene *gRackScene = NULL; | |||
| static void checkVersion() { | |||
| json_t *resJ = network::requestJson(network::METHOD_GET, gApiHost + "/version", NULL); | |||
| if (resJ) { | |||
| json_t *versionJ = json_object_get(resJ, "version"); | |||
| if (versionJ) { | |||
| const char *version = json_string_value(versionJ); | |||
| if (version && version != gApplicationVersion) { | |||
| gLatestVersion = version; | |||
| } | |||
| } | |||
| json_decref(resJ); | |||
| } | |||
| } | |||
| void appInit(bool devMode) { | |||
| gRackScene = new RackScene; | |||
| event::gContext = new event::Context; | |||
| event::gContext->rootWidget = gRackScene; | |||
| // Request latest version from server | |||
| if (!devMode && gCheckVersion) { | |||
| std::thread t(checkVersion); | |||
| t.detach(); | |||
| } | |||
| } | |||
| void appDestroy() { | |||
| delete gRackScene; | |||
| gRackScene = NULL; | |||
| delete event::gContext; | |||
| event::gContext = NULL; | |||
| } | |||
| json_t *colorToJson(NVGcolor color) { | |||
| json_t *colorJ = json_object(); | |||
| json_object_set_new(colorJ, "r", json_real(color.r)); | |||
| json_object_set_new(colorJ, "g", json_real(color.g)); | |||
| json_object_set_new(colorJ, "b", json_real(color.b)); | |||
| json_object_set_new(colorJ, "a", json_real(color.a)); | |||
| return colorJ; | |||
| } | |||
| NVGcolor jsonToColor(json_t *colorJ) { | |||
| NVGcolor color; | |||
| color.r = json_number_value(json_object_get(colorJ, "r")); | |||
| color.g = json_number_value(json_object_get(colorJ, "g")); | |||
| color.b = json_number_value(json_object_get(colorJ, "b")); | |||
| color.a = json_number_value(json_object_get(colorJ, "a")); | |||
| return color; | |||
| } | |||
| } // namespace rack | |||
| @@ -0,0 +1,15 @@ | |||
| #include "app/common.hpp" | |||
| namespace rack { | |||
| const std::string APP_NAME = "VCV Rack"; | |||
| const std::string APP_VERSION = TOSTRING(VERSION); | |||
| const std::string API_HOST = "https://api.vcvrack.com"; | |||
| const std::string PRESET_FILTERS = "VCV Rack module preset (.vcvm):vcvm"; | |||
| const std::string PATCH_FILTERS = "VCV Rack patch (.vcv):vcv"; | |||
| } // namespace rack | |||
| @@ -1,12 +1,15 @@ | |||
| #include <unistd.h> | |||
| #include "osdialog.h" | |||
| #include "rack.hpp" | |||
| #include "random.hpp" | |||
| #include "logger.hpp" | |||
| #include "asset.hpp" | |||
| #include "rtmidi.hpp" | |||
| #include "keyboard.hpp" | |||
| #include "gamepad.hpp" | |||
| #include "bridge.hpp" | |||
| #include "settings.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include "app/Scene.hpp" | |||
| #ifdef ARCH_WIN | |||
| #include <Windows.h> | |||
| @@ -15,7 +18,18 @@ | |||
| using namespace rack; | |||
| int main(int argc, char* argv[]) { | |||
| int main(int argc, char *argv[]) { | |||
| #ifdef ARCH_WIN | |||
| // Windows global mutex to prevent multiple instances | |||
| // Handle will be closed by Windows when the process ends | |||
| HANDLE instanceMutex = CreateMutex(NULL, true, gApplicationName.c_str()); | |||
| if (GetLastError() == ERROR_ALREADY_EXISTS) { | |||
| osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported."); | |||
| exit(1); | |||
| } | |||
| (void) instanceMutex; | |||
| #endif | |||
| bool devMode = false; | |||
| std::string patchFile; | |||
| @@ -40,24 +54,13 @@ int main(int argc, char* argv[]) { | |||
| patchFile = argv[optind]; | |||
| } | |||
| #ifdef ARCH_WIN | |||
| // Windows global mutex to prevent multiple instances | |||
| // Handle will be closed by Windows when the process ends | |||
| HANDLE instanceMutex = CreateMutex(NULL, true, gApplicationName.c_str()); | |||
| if (GetLastError() == ERROR_ALREADY_EXISTS) { | |||
| osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported."); | |||
| exit(1); | |||
| } | |||
| (void) instanceMutex; | |||
| #endif | |||
| // Initialize environment | |||
| random::init(); | |||
| asset::init(devMode); | |||
| logger::init(devMode); | |||
| // Log environment | |||
| INFO("%s %s", gApplicationName.c_str(), gApplicationVersion.c_str()); | |||
| INFO("%s %s", APP_NAME.c_str(), APP_VERSION.c_str()); | |||
| if (devMode) | |||
| INFO("Development mode"); | |||
| INFO("Global directory: %s", asset::global("").c_str()); | |||
| @@ -70,7 +73,10 @@ int main(int argc, char* argv[]) { | |||
| bridgeInit(); | |||
| keyboard::init(); | |||
| gamepad::init(); | |||
| appInit(devMode); | |||
| event::gContext = new event::Context; | |||
| gScene = new Scene; | |||
| gScene->devMode = devMode; | |||
| event::gContext->rootWidget = gScene; | |||
| windowInit(); | |||
| settings::load(asset::local("settings.json")); | |||
| @@ -81,19 +87,19 @@ int main(int argc, char* argv[]) { | |||
| settings::save(asset::local("settings.json")); | |||
| settings::gSkipAutosaveOnLaunch = false; | |||
| if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | |||
| gRackWidget->lastPath = ""; | |||
| gScene->rackWidget->lastPath = ""; | |||
| } | |||
| else { | |||
| // Load autosave | |||
| std::string oldLastPath = gRackWidget->lastPath; | |||
| gRackWidget->load(asset::local("autosave.vcv")); | |||
| gRackWidget->lastPath = oldLastPath; | |||
| std::string oldLastPath = gScene->rackWidget->lastPath; | |||
| gScene->rackWidget->load(asset::local("autosave.vcv")); | |||
| gScene->rackWidget->lastPath = oldLastPath; | |||
| } | |||
| } | |||
| else { | |||
| // Load patch | |||
| gRackWidget->load(patchFile); | |||
| gRackWidget->lastPath = patchFile; | |||
| gScene->rackWidget->load(patchFile); | |||
| gScene->rackWidget->lastPath = patchFile; | |||
| } | |||
| gEngine->start(); | |||
| @@ -101,12 +107,16 @@ int main(int argc, char* argv[]) { | |||
| gEngine->stop(); | |||
| // Destroy namespaces | |||
| gRackWidget->save(asset::local("autosave.vcv")); | |||
| gScene->rackWidget->save(asset::local("autosave.vcv")); | |||
| settings::save(asset::local("settings.json")); | |||
| appDestroy(); | |||
| delete gScene; | |||
| gScene = NULL; | |||
| delete event::gContext; | |||
| event::gContext = NULL; | |||
| windowDestroy(); | |||
| bridgeDestroy(); | |||
| delete gEngine; | |||
| gEngine = NULL; | |||
| midiDestroy(); | |||
| pluginDestroy(); | |||
| logger::destroy(); | |||
| @@ -19,7 +19,13 @@ | |||
| #endif | |||
| #include <dirent.h> | |||
| #include "rack.hpp" | |||
| #include "plugin.hpp" | |||
| #include "system.hpp" | |||
| #include "logger.hpp" | |||
| #include "network.hpp" | |||
| #include "asset.hpp" | |||
| #include "string.hpp" | |||
| #include "app/common.hpp" | |||
| #include "osdialog.h" | |||
| @@ -164,7 +170,7 @@ static bool syncPlugin(std::string slug, json_t *manifestJ, bool dryRun) { | |||
| #endif | |||
| std::string downloadUrl; | |||
| downloadUrl = gApiHost; | |||
| downloadUrl = API_HOST; | |||
| downloadUrl += "/download"; | |||
| if (dryRun) { | |||
| downloadUrl += "/available"; | |||
| @@ -379,7 +385,7 @@ bool pluginSync(bool dryRun) { | |||
| // Get user's plugins list | |||
| json_t *pluginsReqJ = json_object(); | |||
| json_object_set(pluginsReqJ, "token", json_string(gToken.c_str())); | |||
| json_t *pluginsResJ = network::requestJson(network::METHOD_GET, gApiHost + "/plugins", pluginsReqJ); | |||
| json_t *pluginsResJ = network::requestJson(network::METHOD_GET, API_HOST + "/plugins", pluginsReqJ); | |||
| json_decref(pluginsReqJ); | |||
| if (!pluginsResJ) { | |||
| WARN("Request for user's plugins failed"); | |||
| @@ -396,7 +402,7 @@ bool pluginSync(bool dryRun) { | |||
| } | |||
| // Get community manifests | |||
| json_t *manifestsResJ = network::requestJson(network::METHOD_GET, gApiHost + "/community/manifests", NULL); | |||
| json_t *manifestsResJ = network::requestJson(network::METHOD_GET, API_HOST + "/community/manifests", NULL); | |||
| if (!manifestsResJ) { | |||
| WARN("Request for community manifests failed"); | |||
| return false; | |||
| @@ -444,7 +450,7 @@ void pluginLogIn(std::string email, std::string password) { | |||
| json_t *reqJ = json_object(); | |||
| json_object_set(reqJ, "email", json_string(email.c_str())); | |||
| json_object_set(reqJ, "password", json_string(password.c_str())); | |||
| json_t *resJ = network::requestJson(network::METHOD_POST, gApiHost + "/token", reqJ); | |||
| json_t *resJ = network::requestJson(network::METHOD_POST, API_HOST + "/token", reqJ); | |||
| json_decref(reqJ); | |||
| if (resJ) { | |||
| @@ -2,7 +2,8 @@ | |||
| #include "logger.hpp" | |||
| #include "window.hpp" | |||
| #include "plugin.hpp" | |||
| #include "app.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "app/ModuleBrowser.hpp" | |||
| #include "engine/Engine.hpp" | |||
| #include <jansson.h> | |||
| @@ -35,17 +36,17 @@ static json_t *settingsToJson() { | |||
| } | |||
| // opacity | |||
| float opacity = gToolbar->wireOpacity; | |||
| float opacity = gScene->toolbar->wireOpacity; | |||
| json_t *opacityJ = json_real(opacity); | |||
| json_object_set_new(rootJ, "wireOpacity", opacityJ); | |||
| // tension | |||
| float tension = gToolbar->wireTension; | |||
| float tension = gScene->toolbar->wireTension; | |||
| json_t *tensionJ = json_real(tension); | |||
| json_object_set_new(rootJ, "wireTension", tensionJ); | |||
| // zoom | |||
| float zoom = gRackScene->zoomWidget->zoom; | |||
| float zoom = gScene->zoomWidget->zoom; | |||
| json_t *zoomJ = json_real(zoom); | |||
| json_object_set_new(rootJ, "zoom", zoomJ); | |||
| @@ -58,7 +59,7 @@ static json_t *settingsToJson() { | |||
| json_object_set_new(rootJ, "sampleRate", sampleRateJ); | |||
| // lastPath | |||
| json_t *lastPathJ = json_string(gRackWidget->lastPath.c_str()); | |||
| json_t *lastPathJ = json_string(gScene->rackWidget->lastPath.c_str()); | |||
| json_object_set_new(rootJ, "lastPath", lastPathJ); | |||
| // skipAutosaveOnLaunch | |||
| @@ -67,13 +68,13 @@ static json_t *settingsToJson() { | |||
| } | |||
| // moduleBrowser | |||
| json_object_set_new(rootJ, "moduleBrowser", appModuleBrowserToJson()); | |||
| json_object_set_new(rootJ, "moduleBrowser", moduleBrowserToJson()); | |||
| // powerMeter | |||
| json_object_set_new(rootJ, "powerMeter", json_boolean(gEngine->powerMeter)); | |||
| // checkVersion | |||
| json_object_set_new(rootJ, "checkVersion", json_boolean(gCheckVersion)); | |||
| json_object_set_new(rootJ, "checkVersion", json_boolean(gScene->checkVersion)); | |||
| return rootJ; | |||
| } | |||
| @@ -103,17 +104,17 @@ static void settingsFromJson(json_t *rootJ) { | |||
| // opacity | |||
| json_t *opacityJ = json_object_get(rootJ, "wireOpacity"); | |||
| if (opacityJ) | |||
| gToolbar->wireOpacity = json_number_value(opacityJ); | |||
| gScene->toolbar->wireOpacity = json_number_value(opacityJ); | |||
| // tension | |||
| json_t *tensionJ = json_object_get(rootJ, "wireTension"); | |||
| if (tensionJ) | |||
| gToolbar->wireTension = json_number_value(tensionJ); | |||
| gScene->toolbar->wireTension = json_number_value(tensionJ); | |||
| // zoom | |||
| json_t *zoomJ = json_object_get(rootJ, "zoom"); | |||
| if (zoomJ) { | |||
| gRackScene->zoomWidget->setZoom(clamp((float) json_number_value(zoomJ), 0.25f, 4.0f)); | |||
| gScene->zoomWidget->setZoom(clamp((float) json_number_value(zoomJ), 0.25f, 4.0f)); | |||
| } | |||
| // allowCursorLock | |||
| @@ -131,7 +132,7 @@ static void settingsFromJson(json_t *rootJ) { | |||
| // lastPath | |||
| json_t *lastPathJ = json_object_get(rootJ, "lastPath"); | |||
| if (lastPathJ) | |||
| gRackWidget->lastPath = json_string_value(lastPathJ); | |||
| gScene->rackWidget->lastPath = json_string_value(lastPathJ); | |||
| // skipAutosaveOnLaunch | |||
| json_t *skipAutosaveOnLaunchJ = json_object_get(rootJ, "skipAutosaveOnLaunch"); | |||
| @@ -141,7 +142,7 @@ static void settingsFromJson(json_t *rootJ) { | |||
| // moduleBrowser | |||
| json_t *moduleBrowserJ = json_object_get(rootJ, "moduleBrowser"); | |||
| if (moduleBrowserJ) | |||
| appModuleBrowserFromJson(moduleBrowserJ); | |||
| moduleBrowserFromJson(moduleBrowserJ); | |||
| // powerMeter | |||
| json_t *powerMeterJ = json_object_get(rootJ, "powerMeter"); | |||
| @@ -151,7 +152,7 @@ static void settingsFromJson(json_t *rootJ) { | |||
| // checkVersion | |||
| json_t *checkVersionJ = json_object_get(rootJ, "checkVersion"); | |||
| if (checkVersionJ) | |||
| gCheckVersion = json_boolean_value(checkVersionJ); | |||
| gScene->checkVersion = json_boolean_value(checkVersionJ); | |||
| } | |||
| @@ -1,5 +1,4 @@ | |||
| #include "widgets.hpp" | |||
| #include "app.hpp" | |||
| #include "widgets/Widget.hpp" | |||
| #include "event.hpp" | |||
| #include <algorithm> | |||
| @@ -10,7 +10,9 @@ | |||
| #include "osdialog.h" | |||
| #include "rack.hpp" | |||
| #include "logger.hpp" | |||
| #include "asset.hpp" | |||
| #include "app/Scene.hpp" | |||
| #include "keyboard.hpp" | |||
| #include "gamepad.hpp" | |||
| #include "event.hpp" | |||
| @@ -302,12 +304,12 @@ void windowRun() { | |||
| // Set window title | |||
| std::string windowTitle; | |||
| windowTitle = gApplicationName; | |||
| windowTitle = APP_NAME; | |||
| windowTitle += " "; | |||
| windowTitle += gApplicationVersion; | |||
| if (!gRackWidget->lastPath.empty()) { | |||
| windowTitle += APP_VERSION; | |||
| if (!gScene->rackWidget->lastPath.empty()) { | |||
| windowTitle += " - "; | |||
| windowTitle += string::filename(gRackWidget->lastPath); | |||
| windowTitle += string::filename(gScene->rackWidget->lastPath); | |||
| } | |||
| if (windowTitle != lastWindowTitle) { | |||
| glfwSetWindowTitle(gWindow, windowTitle.c_str()); | |||