@@ -1,16 +1,10 @@ | |||||
#pragma once | #pragma once | ||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "app/LedDisplay.hpp" | #include "app/LedDisplay.hpp" | ||||
#include "audio.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace audio { | |||||
struct Port; | |||||
} | |||||
namespace app { | namespace app { | ||||
@@ -16,6 +16,7 @@ struct CableWidget : widget::OpaqueWidget { | |||||
PortWidget *inputPort = NULL; | PortWidget *inputPort = NULL; | ||||
PortWidget *hoveredOutputPort = NULL; | PortWidget *hoveredOutputPort = NULL; | ||||
PortWidget *hoveredInputPort = NULL; | PortWidget *hoveredInputPort = NULL; | ||||
/** Owned. */ | |||||
engine::Cable *cable; | engine::Cable *cable; | ||||
NVGcolor color; | NVGcolor color; | ||||
@@ -10,6 +10,7 @@ namespace app { | |||||
struct CircularShadow : widget::TransparentWidget { | struct CircularShadow : widget::TransparentWidget { | ||||
float blurRadius; | float blurRadius; | ||||
float opacity; | float opacity; | ||||
CircularShadow(); | CircularShadow(); | ||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
}; | }; | ||||
@@ -11,6 +11,7 @@ struct LightWidget : widget::TransparentWidget { | |||||
NVGcolor bgColor = nvgRGBA(0, 0, 0, 0); | NVGcolor bgColor = nvgRGBA(0, 0, 0, 0); | ||||
NVGcolor color = nvgRGBA(0, 0, 0, 0); | NVGcolor color = nvgRGBA(0, 0, 0, 0); | ||||
NVGcolor borderColor = nvgRGBA(0, 0, 0, 0); | NVGcolor borderColor = nvgRGBA(0, 0, 0, 0); | ||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
virtual void drawLight(const DrawArgs &args); | virtual void drawLight(const DrawArgs &args); | ||||
virtual void drawHalo(const DrawArgs &args); | virtual void drawHalo(const DrawArgs &args); | ||||
@@ -1,16 +1,10 @@ | |||||
#pragma once | #pragma once | ||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "app/LedDisplay.hpp" | #include "app/LedDisplay.hpp" | ||||
#include "midi.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace midi { | |||||
struct Port; | |||||
} | |||||
namespace app { | namespace app { | ||||
@@ -14,6 +14,7 @@ Will access firstLightId, firstLightId + 1, etc. for each added color | |||||
struct ModuleLightWidget : MultiLightWidget { | struct ModuleLightWidget : MultiLightWidget { | ||||
engine::Module *module = NULL; | engine::Module *module = NULL; | ||||
int firstLightId; | int firstLightId; | ||||
void step() override; | void step() override; | ||||
}; | }; | ||||
@@ -4,6 +4,7 @@ | |||||
#include "ui/Menu.hpp" | #include "ui/Menu.hpp" | ||||
#include "app/PortWidget.hpp" | #include "app/PortWidget.hpp" | ||||
#include "app/ParamWidget.hpp" | #include "app/ParamWidget.hpp" | ||||
#include "app/SvgPanel.hpp" | |||||
#include "plugin/Model.hpp" | #include "plugin/Model.hpp" | ||||
#include "engine/Module.hpp" | #include "engine/Module.hpp" | ||||
@@ -15,11 +16,11 @@ namespace app { | |||||
/** Manages an engine::Module in the rack. */ | /** Manages an engine::Module in the rack. */ | ||||
struct ModuleWidget : widget::OpaqueWidget { | struct ModuleWidget : widget::OpaqueWidget { | ||||
plugin::Model *model = NULL; | plugin::Model *model = NULL; | ||||
/** Owns the module pointer */ | |||||
/** Owned. */ | |||||
engine::Module *module = NULL; | engine::Module *module = NULL; | ||||
widget::Widget *panel = NULL; | |||||
/** Note that the indexes of these vectors might not correspond with the indexes of `Module::params` etc. | |||||
SvgPanel *panel = NULL; | |||||
/** Note that the indexes of these vectors do not necessarily correspond with the indexes of `Module::params` etc. | |||||
*/ | */ | ||||
std::vector<ParamWidget*> params; | std::vector<ParamWidget*> params; | ||||
std::vector<PortWidget*> outputs; | std::vector<PortWidget*> outputs; | ||||
@@ -29,7 +30,7 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
math::Vec oldPos; | math::Vec oldPos; | ||||
ModuleWidget(); | ModuleWidget(); | ||||
DEPRECATED ModuleWidget(engine::Module *module) { | |||||
DEPRECATED ModuleWidget(engine::Module *module) : ModuleWidget() { | |||||
setModule(module); | setModule(module); | ||||
} | } | ||||
~ModuleWidget(); | ~ModuleWidget(); | ||||
@@ -11,6 +11,7 @@ namespace app { | |||||
struct MultiLightWidget : LightWidget { | struct MultiLightWidget : LightWidget { | ||||
/** Colors of each value state */ | /** Colors of each value state */ | ||||
std::vector<NVGcolor> baseColors; | std::vector<NVGcolor> baseColors; | ||||
void addBaseColor(NVGcolor baseColor); | void addBaseColor(NVGcolor baseColor); | ||||
/** Sets the color to a linear combination of the baseColors with the given weights */ | /** Sets the color to a linear combination of the baseColors with the given weights */ | ||||
void setBrightnesses(const std::vector<float> &brightnesses); | void setBrightnesses(const std::vector<float> &brightnesses); | ||||
@@ -17,13 +17,13 @@ struct Scene : widget::OpaqueWidget { | |||||
MenuBar *menuBar; | MenuBar *menuBar; | ||||
widget::Widget *moduleBrowser; | widget::Widget *moduleBrowser; | ||||
double lastAutoSaveTime = 0.0; | |||||
// Version checking | // Version checking | ||||
bool checkVersion = true; | bool checkVersion = true; | ||||
bool checkedVersion = false; | bool checkedVersion = false; | ||||
std::string latestVersion; | std::string latestVersion; | ||||
double lastAutoSaveTime = 0.0; | |||||
Scene(); | Scene(); | ||||
~Scene(); | ~Scene(); | ||||
void step() override; | void step() override; | ||||
@@ -18,7 +18,8 @@ struct SvgKnob : Knob { | |||||
widget::TransformWidget *tw; | widget::TransformWidget *tw; | ||||
widget::SvgWidget *sw; | widget::SvgWidget *sw; | ||||
/** Angles in radians */ | /** Angles in radians */ | ||||
float minAngle, maxAngle; | |||||
float minAngle = 0.f; | |||||
float maxAngle = M_PI; | |||||
SvgKnob(); | SvgKnob(); | ||||
void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
@@ -12,9 +12,9 @@ namespace rack { | |||||
namespace app { | namespace app { | ||||
static const char APP_NAME[] = "VCV Rack"; | |||||
static const char APP_VERSION[] = TOSTRING(VERSION); | |||||
static const char API_URL[] = "https://api.vcvrack.com"; | |||||
extern const char APP_NAME[]; | |||||
extern const char APP_VERSION[]; | |||||
extern const char API_URL[]; | |||||
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; | ||||
@@ -93,13 +93,19 @@ struct BlankWidget : ModuleWidget { | |||||
Widget *topRightScrew; | Widget *topRightScrew; | ||||
Widget *bottomRightScrew; | Widget *bottomRightScrew; | ||||
Widget *rightHandle; | Widget *rightHandle; | ||||
BlankPanel *blankPanel; | |||||
BlankWidget(Module *module) { | BlankWidget(Module *module) { | ||||
setModule(module); | setModule(module); | ||||
box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); | box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); | ||||
panel = new BlankPanel; | |||||
addChild(panel); | |||||
// Delete SvgPanel | |||||
removeChild(panel); | |||||
delete panel; | |||||
panel = NULL; | |||||
blankPanel = new BlankPanel; | |||||
addChild(blankPanel); | |||||
ModuleResizeHandle *leftHandle = new ModuleResizeHandle; | ModuleResizeHandle *leftHandle = new ModuleResizeHandle; | ||||
ModuleResizeHandle *rightHandle = new ModuleResizeHandle; | ModuleResizeHandle *rightHandle = new ModuleResizeHandle; | ||||
@@ -117,7 +123,7 @@ struct BlankWidget : ModuleWidget { | |||||
} | } | ||||
void step() override { | void step() override { | ||||
panel->box.size = box.size; | |||||
blankPanel->box.size = box.size; | |||||
topRightScrew->box.pos.x = box.size.x - 30; | topRightScrew->box.pos.x = box.size.x - 30; | ||||
bottomRightScrew->box.pos.x = box.size.x - 30; | bottomRightScrew->box.pos.x = box.size.x - 30; | ||||
if (box.size.x < RACK_GRID_WIDTH * 6) { | if (box.size.x < RACK_GRID_WIDTH * 6) { | ||||
@@ -1,5 +1,4 @@ | |||||
#include "app/AudioWidget.hpp" | #include "app/AudioWidget.hpp" | ||||
#include "audio.hpp" | |||||
#include "helpers.hpp" | #include "helpers.hpp" | ||||
@@ -43,6 +43,9 @@ void Knob::onDragStart(const event::DragStart &e) { | |||||
} | } | ||||
void Knob::onDragEnd(const event::DragEnd &e) { | void Knob::onDragEnd(const event::DragEnd &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
APP->window->cursorUnlock(); | APP->window->cursorUnlock(); | ||||
if (paramQuantity) { | if (paramQuantity) { | ||||
@@ -66,6 +69,9 @@ void Knob::onDragEnd(const event::DragEnd &e) { | |||||
} | } | ||||
void Knob::onDragMove(const event::DragMove &e) { | void Knob::onDragMove(const event::DragMove &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
if (paramQuantity) { | if (paramQuantity) { | ||||
float range; | float range; | ||||
if (paramQuantity->isBounded()) { | if (paramQuantity->isBounded()) { | ||||
@@ -1,5 +1,4 @@ | |||||
#include "app/MidiWidget.hpp" | #include "app/MidiWidget.hpp" | ||||
#include "midi.hpp" | |||||
#include "helpers.hpp" | #include "helpers.hpp" | ||||
@@ -1,6 +1,5 @@ | |||||
#include "app/ModuleWidget.hpp" | #include "app/ModuleWidget.hpp" | ||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "app/SvgPanel.hpp" | |||||
#include "engine/Engine.hpp" | #include "engine/Engine.hpp" | ||||
#include "plugin/Plugin.hpp" | #include "plugin/Plugin.hpp" | ||||
#include "system.hpp" | #include "system.hpp" | ||||
@@ -243,6 +242,9 @@ struct ModuleDeleteItem : ui::MenuItem { | |||||
ModuleWidget::ModuleWidget() { | ModuleWidget::ModuleWidget() { | ||||
box.size = math::Vec(0, RACK_GRID_HEIGHT); | box.size = math::Vec(0, RACK_GRID_HEIGHT); | ||||
panel = new SvgPanel; | |||||
addChild(panel); | |||||
} | } | ||||
ModuleWidget::~ModuleWidget() { | ModuleWidget::~ModuleWidget() { | ||||
@@ -311,7 +313,7 @@ void ModuleWidget::onButton(const event::Button &e) { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | ||||
createContextMenu(); | createContextMenu(); | ||||
e.consume(NULL); | |||||
e.consume(this); | |||||
} | } | ||||
} | } | ||||
@@ -390,6 +392,9 @@ void ModuleWidget::onDragStart(const event::DragStart &e) { | |||||
} | } | ||||
void ModuleWidget::onDragEnd(const event::DragEnd &e) { | void ModuleWidget::onDragEnd(const event::DragEnd &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
history::ComplexAction *h = APP->scene->rack->getModuleDragAction(); | history::ComplexAction *h = APP->scene->rack->getModuleDragAction(); | ||||
if (!h) { | if (!h) { | ||||
delete h; | delete h; | ||||
@@ -399,6 +404,9 @@ void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||||
} | } | ||||
void ModuleWidget::onDragMove(const event::DragMove &e) { | void ModuleWidget::onDragMove(const event::DragMove &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
if (!settings::lockModules) { | if (!settings::lockModules) { | ||||
math::Vec pos = APP->scene->rack->mousePos.minus(dragPos); | math::Vec pos = APP->scene->rack->mousePos.minus(dragPos); | ||||
if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) | if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) | ||||
@@ -416,18 +424,10 @@ void ModuleWidget::setModule(engine::Module *module) { | |||||
} | } | ||||
void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) { | void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) { | ||||
// Remove old panel | |||||
if (panel) { | |||||
removeChild(panel); | |||||
delete panel; | |||||
panel = NULL; | |||||
} | |||||
SvgPanel *svgPanel = new SvgPanel; | |||||
svgPanel->setBackground(svg); | |||||
addChild(svgPanel); | |||||
box.size.x = std::round(svgPanel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | |||||
panel = svgPanel; | |||||
assert(panel); | |||||
panel->setBackground(svg); | |||||
// Set ModuleWidget size based on panel | |||||
box.size.x = std::round(panel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | |||||
} | } | ||||
void ModuleWidget::addParam(ParamWidget *param) { | void ModuleWidget::addParam(ParamWidget *param) { | ||||
@@ -74,7 +74,7 @@ void PortWidget::onButton(const event::Button &e) { | |||||
delete cw; | delete cw; | ||||
} | } | ||||
e.consume(NULL); | |||||
e.consume(this); | |||||
} | } | ||||
} | } | ||||
@@ -135,6 +135,9 @@ void PortWidget::onDragStart(const event::DragStart &e) { | |||||
} | } | ||||
void PortWidget::onDragEnd(const event::DragEnd &e) { | void PortWidget::onDragEnd(const event::DragEnd &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
CableWidget *cw = APP->scene->rack->releaseIncompleteCable(); | CableWidget *cw = APP->scene->rack->releaseIncompleteCable(); | ||||
if (cw->isComplete()) { | if (cw->isComplete()) { | ||||
APP->scene->rack->addCable(cw); | APP->scene->rack->addCable(cw); | ||||
@@ -150,6 +153,9 @@ void PortWidget::onDragEnd(const event::DragEnd &e) { | |||||
} | } | ||||
void PortWidget::onDragDrop(const event::DragDrop &e) { | void PortWidget::onDragDrop(const event::DragDrop &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
// 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) { | ||||
if (APP->scene->rack->getTopCable(this)) | if (APP->scene->rack->getTopCable(this)) | ||||
@@ -167,6 +173,9 @@ void PortWidget::onDragDrop(const event::DragDrop &e) { | |||||
} | } | ||||
void PortWidget::onDragEnter(const event::DragEnter &e) { | void PortWidget::onDragEnter(const event::DragEnter &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
// 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) { | ||||
if (APP->scene->rack->getTopCable(this)) | if (APP->scene->rack->getTopCable(this)) | ||||
@@ -183,6 +192,9 @@ void PortWidget::onDragEnter(const event::DragEnter &e) { | |||||
} | } | ||||
void PortWidget::onDragLeave(const event::DragLeave &e) { | void PortWidget::onDragLeave(const event::DragLeave &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | ||||
if (!originPort) | if (!originPort) | ||||
return; | return; | ||||
@@ -67,6 +67,9 @@ void Switch::onDragStart(const event::DragStart &e) { | |||||
} | } | ||||
void Switch::onDragEnd(const event::DragEnd &e) { | void Switch::onDragEnd(const event::DragEnd &e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | |||||
return; | |||||
if (momentary) { | if (momentary) { | ||||
momentaryReleased = true; | momentaryReleased = true; | ||||
} | } | ||||
@@ -0,0 +1,15 @@ | |||||
#include "app/common.hpp" | |||||
namespace rack { | |||||
namespace app { | |||||
const char APP_NAME[] = "VCV Rack"; | |||||
const char APP_VERSION[] = TOSTRING(VERSION); | |||||
const char API_URL[] = "https://api.vcvrack.com"; | |||||
} // namespace app | |||||
} // namespace rack |