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