Browse Source

Clean up app namespace.

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
5e0378cb5a
19 changed files with 79 additions and 44 deletions
  1. +1
    -7
      include/app/AudioWidget.hpp
  2. +1
    -0
      include/app/CableWidget.hpp
  3. +1
    -0
      include/app/CircularShadow.hpp
  4. +1
    -0
      include/app/LightWidget.hpp
  5. +1
    -7
      include/app/MidiWidget.hpp
  6. +1
    -0
      include/app/ModuleLightWidget.hpp
  7. +5
    -4
      include/app/ModuleWidget.hpp
  8. +1
    -0
      include/app/MultiLightWidget.hpp
  9. +2
    -2
      include/app/Scene.hpp
  10. +2
    -1
      include/app/SvgKnob.hpp
  11. +3
    -3
      include/app/common.hpp
  12. +9
    -3
      src/Core/Blank.cpp
  13. +0
    -1
      src/app/AudioWidget.cpp
  14. +6
    -0
      src/app/Knob.cpp
  15. +0
    -1
      src/app/MidiWidget.cpp
  16. +14
    -14
      src/app/ModuleWidget.cpp
  17. +13
    -1
      src/app/PortWidget.cpp
  18. +3
    -0
      src/app/Switch.cpp
  19. +15
    -0
      src/app/common.cpp

+ 1
- 7
include/app/AudioWidget.hpp View File

@@ -1,16 +1,10 @@
#pragma once
#include "app/common.hpp"
#include "app/LedDisplay.hpp"
#include "audio.hpp"


namespace rack {


namespace audio {
struct Port;
}


namespace app {




+ 1
- 0
include/app/CableWidget.hpp View File

@@ -16,6 +16,7 @@ struct CableWidget : widget::OpaqueWidget {
PortWidget *inputPort = NULL;
PortWidget *hoveredOutputPort = NULL;
PortWidget *hoveredInputPort = NULL;
/** Owned. */
engine::Cable *cable;
NVGcolor color;



+ 1
- 0
include/app/CircularShadow.hpp View File

@@ -10,6 +10,7 @@ namespace app {
struct CircularShadow : widget::TransparentWidget {
float blurRadius;
float opacity;

CircularShadow();
void draw(const DrawArgs &args) override;
};


+ 1
- 0
include/app/LightWidget.hpp View File

@@ -11,6 +11,7 @@ struct LightWidget : widget::TransparentWidget {
NVGcolor bgColor = nvgRGBA(0, 0, 0, 0);
NVGcolor color = nvgRGBA(0, 0, 0, 0);
NVGcolor borderColor = nvgRGBA(0, 0, 0, 0);

void draw(const DrawArgs &args) override;
virtual void drawLight(const DrawArgs &args);
virtual void drawHalo(const DrawArgs &args);


+ 1
- 7
include/app/MidiWidget.hpp View File

@@ -1,16 +1,10 @@
#pragma once
#include "app/common.hpp"
#include "app/LedDisplay.hpp"
#include "midi.hpp"


namespace rack {


namespace midi {
struct Port;
}


namespace app {




+ 1
- 0
include/app/ModuleLightWidget.hpp View File

@@ -14,6 +14,7 @@ Will access firstLightId, firstLightId + 1, etc. for each added color
struct ModuleLightWidget : MultiLightWidget {
engine::Module *module = NULL;
int firstLightId;

void step() override;
};



+ 5
- 4
include/app/ModuleWidget.hpp View File

@@ -4,6 +4,7 @@
#include "ui/Menu.hpp"
#include "app/PortWidget.hpp"
#include "app/ParamWidget.hpp"
#include "app/SvgPanel.hpp"
#include "plugin/Model.hpp"
#include "engine/Module.hpp"

@@ -15,11 +16,11 @@ namespace app {
/** Manages an engine::Module in the rack. */
struct ModuleWidget : widget::OpaqueWidget {
plugin::Model *model = NULL;
/** Owns the module pointer */
/** Owned. */
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<PortWidget*> outputs;
@@ -29,7 +30,7 @@ struct ModuleWidget : widget::OpaqueWidget {
math::Vec oldPos;

ModuleWidget();
DEPRECATED ModuleWidget(engine::Module *module) {
DEPRECATED ModuleWidget(engine::Module *module) : ModuleWidget() {
setModule(module);
}
~ModuleWidget();


+ 1
- 0
include/app/MultiLightWidget.hpp View File

@@ -11,6 +11,7 @@ namespace app {
struct MultiLightWidget : LightWidget {
/** Colors of each value state */
std::vector<NVGcolor> baseColors;

void addBaseColor(NVGcolor baseColor);
/** Sets the color to a linear combination of the baseColors with the given weights */
void setBrightnesses(const std::vector<float> &brightnesses);


+ 2
- 2
include/app/Scene.hpp View File

@@ -17,13 +17,13 @@ struct Scene : widget::OpaqueWidget {
MenuBar *menuBar;
widget::Widget *moduleBrowser;

double lastAutoSaveTime = 0.0;

// Version checking
bool checkVersion = true;
bool checkedVersion = false;
std::string latestVersion;

double lastAutoSaveTime = 0.0;

Scene();
~Scene();
void step() override;


+ 2
- 1
include/app/SvgKnob.hpp View File

@@ -18,7 +18,8 @@ struct SvgKnob : Knob {
widget::TransformWidget *tw;
widget::SvgWidget *sw;
/** Angles in radians */
float minAngle, maxAngle;
float minAngle = 0.f;
float maxAngle = M_PI;

SvgKnob();
void setSvg(std::shared_ptr<Svg> svg);


+ 3
- 3
include/app/common.hpp View File

@@ -12,9 +12,9 @@ namespace rack {
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 MM_PER_IN = 25.4;


+ 9
- 3
src/Core/Blank.cpp View File

@@ -93,13 +93,19 @@ struct BlankWidget : ModuleWidget {
Widget *topRightScrew;
Widget *bottomRightScrew;
Widget *rightHandle;
BlankPanel *blankPanel;

BlankWidget(Module *module) {
setModule(module);
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 *rightHandle = new ModuleResizeHandle;
@@ -117,7 +123,7 @@ struct BlankWidget : ModuleWidget {
}

void step() override {
panel->box.size = box.size;
blankPanel->box.size = box.size;
topRightScrew->box.pos.x = box.size.x - 30;
bottomRightScrew->box.pos.x = box.size.x - 30;
if (box.size.x < RACK_GRID_WIDTH * 6) {


+ 0
- 1
src/app/AudioWidget.cpp View File

@@ -1,5 +1,4 @@
#include "app/AudioWidget.hpp"
#include "audio.hpp"
#include "helpers.hpp"




+ 6
- 0
src/app/Knob.cpp View File

@@ -43,6 +43,9 @@ void Knob::onDragStart(const event::DragStart &e) {
}

void Knob::onDragEnd(const event::DragEnd &e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

APP->window->cursorUnlock();

if (paramQuantity) {
@@ -66,6 +69,9 @@ void Knob::onDragEnd(const event::DragEnd &e) {
}

void Knob::onDragMove(const event::DragMove &e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

if (paramQuantity) {
float range;
if (paramQuantity->isBounded()) {


+ 0
- 1
src/app/MidiWidget.cpp View File

@@ -1,5 +1,4 @@
#include "app/MidiWidget.hpp"
#include "midi.hpp"
#include "helpers.hpp"




+ 14
- 14
src/app/ModuleWidget.cpp View File

@@ -1,6 +1,5 @@
#include "app/ModuleWidget.hpp"
#include "app/Scene.hpp"
#include "app/SvgPanel.hpp"
#include "engine/Engine.hpp"
#include "plugin/Plugin.hpp"
#include "system.hpp"
@@ -243,6 +242,9 @@ struct ModuleDeleteItem : ui::MenuItem {

ModuleWidget::ModuleWidget() {
box.size = math::Vec(0, RACK_GRID_HEIGHT);

panel = new SvgPanel;
addChild(panel);
}

ModuleWidget::~ModuleWidget() {
@@ -311,7 +313,7 @@ void ModuleWidget::onButton(const event::Button &e) {

if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
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) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

history::ComplexAction *h = APP->scene->rack->getModuleDragAction();
if (!h) {
delete h;
@@ -399,6 +404,9 @@ void ModuleWidget::onDragEnd(const event::DragEnd &e) {
}

void ModuleWidget::onDragMove(const event::DragMove &e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

if (!settings::lockModules) {
math::Vec pos = APP->scene->rack->mousePos.minus(dragPos);
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) {
// 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) {


+ 13
- 1
src/app/PortWidget.cpp View File

@@ -74,7 +74,7 @@ void PortWidget::onButton(const event::Button &e) {
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) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

CableWidget *cw = APP->scene->rack->releaseIncompleteCable();
if (cw->isComplete()) {
APP->scene->rack->addCable(cw);
@@ -150,6 +153,9 @@ void PortWidget::onDragEnd(const event::DragEnd &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
if (type == INPUT) {
if (APP->scene->rack->getTopCable(this))
@@ -167,6 +173,9 @@ void PortWidget::onDragDrop(const event::DragDrop &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
if (type == INPUT) {
if (APP->scene->rack->getTopCable(this))
@@ -183,6 +192,9 @@ void PortWidget::onDragEnter(const event::DragEnter &e) {
}

void PortWidget::onDragLeave(const event::DragLeave &e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin);
if (!originPort)
return;


+ 3
- 0
src/app/Switch.cpp View File

@@ -67,6 +67,9 @@ void Switch::onDragStart(const event::DragStart &e) {
}

void Switch::onDragEnd(const event::DragEnd &e) {
if (e.button != GLFW_MOUSE_BUTTON_LEFT)
return;

if (momentary) {
momentaryReleased = true;
}


+ 15
- 0
src/app/common.cpp View File

@@ -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

Loading…
Cancel
Save