Browse Source

Move Svg to window:: namespace.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
df89de7847
44 changed files with 73 additions and 67 deletions
  1. +1
    -1
      adapters/standalone.cpp
  2. +3
    -2
      include/Quantity.hpp
  3. +1
    -1
      include/app/ModuleWidget.hpp
  4. +2
    -2
      include/app/SvgButton.hpp
  5. +2
    -2
      include/app/SvgKnob.hpp
  6. +2
    -2
      include/app/SvgPanel.hpp
  7. +2
    -2
      include/app/SvgPort.hpp
  8. +1
    -1
      include/app/SvgScrew.hpp
  9. +5
    -5
      include/app/SvgSlider.hpp
  10. +2
    -2
      include/app/SvgSwitch.hpp
  11. +1
    -1
      include/app/common.hpp
  12. +3
    -0
      include/componentlibrary.hpp
  13. +1
    -2
      include/helpers.hpp
  14. +1
    -0
      include/patch.hpp
  15. +1
    -1
      include/rack.hpp
  16. +1
    -1
      include/weakptr.hpp
  17. +3
    -4
      include/widget/SvgWidget.hpp
  18. +1
    -1
      include/widget/Widget.hpp
  19. +2
    -0
      include/window/Svg.hpp
  20. +8
    -8
      include/window/Window.hpp
  21. +2
    -2
      src/app/CableWidget.cpp
  22. +2
    -2
      src/app/LedDisplay.cpp
  23. +1
    -1
      src/app/MenuBar.cpp
  24. +1
    -1
      src/app/ModuleWidget.cpp
  25. +1
    -1
      src/app/PortWidget.cpp
  26. +1
    -1
      src/app/RackScrollWidget.cpp
  27. +1
    -2
      src/app/RailWidget.cpp
  28. +1
    -1
      src/app/SvgButton.cpp
  29. +1
    -1
      src/app/SvgKnob.cpp
  30. +1
    -1
      src/app/SvgPanel.cpp
  31. +1
    -1
      src/app/SvgPort.cpp
  32. +1
    -1
      src/app/SvgScrew.cpp
  33. +2
    -2
      src/app/SvgSlider.cpp
  34. +1
    -1
      src/app/SvgSwitch.cpp
  35. +1
    -1
      src/context.cpp
  36. +1
    -1
      src/gamepad.cpp
  37. +1
    -1
      src/keyboard.cpp
  38. +1
    -1
      src/library.cpp
  39. +1
    -1
      src/settings.cpp
  40. +1
    -1
      src/ui/Scrollbar.cpp
  41. +2
    -2
      src/widget/SvgWidget.cpp
  42. +1
    -1
      src/widget/event.cpp
  43. +3
    -1
      src/window/Svg.cpp
  44. +1
    -1
      src/window/Window.cpp

+ 1
- 1
adapters/standalone.cpp View File

@@ -13,7 +13,7 @@
#include <app/Scene.hpp>
#include <plugin.hpp>
#include <context.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <patch.hpp>
#include <history.hpp>
#include <ui/common.hpp>


+ 3
- 2
include/Quantity.hpp View File

@@ -7,8 +7,9 @@
namespace rack {


/** A controller for manipulating a float value (which subclasses must store somehow) with limits and labels
Often used as a decorator component for widget::Widgets that read or write a quantity.
/** A controller for manipulating a float value (which subclasses must store somehow) with limits and labels.

Often used as a decorator component for `widget::Widget`s that read or write a quantity.
*/
struct Quantity {
virtual ~Quantity() {}


+ 1
- 1
include/app/ModuleWidget.hpp View File

@@ -42,7 +42,7 @@ struct ModuleWidget : widget::OpaqueWidget {
Transfers ownership.
*/
void setPanel(widget::Widget* panel);
void setPanel(std::shared_ptr<Svg> svg);
void setPanel(std::shared_ptr<window::Svg> svg);

/** Convenience functions for adding special widgets.
Just calls addChild() with additional checking.


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

@@ -14,10 +14,10 @@ struct SvgButton : widget::OpaqueWidget {
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::SvgWidget* sw;
std::vector<std::shared_ptr<Svg>> frames;
std::vector<std::shared_ptr<window::Svg>> frames;

SvgButton();
void addFrame(std::shared_ptr<Svg> svg);
void addFrame(std::shared_ptr<window::Svg> svg);
void onButton(const ButtonEvent& e) override;
void onDragStart(const DragStartEvent& e) override;
void onDragEnd(const DragEndEvent& e) override;


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

@@ -19,8 +19,8 @@ struct SvgKnob : Knob {
widget::SvgWidget* sw;

SvgKnob();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
void setSvg(std::shared_ptr<window::Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<window::Svg> svg) {
setSvg(svg);
}
void onChange(const ChangeEvent& e) override;


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

@@ -19,11 +19,11 @@ struct SvgPanel : widget::Widget {
widget::FramebufferWidget* fb;
widget::SvgWidget* sw;
PanelBorder* panelBorder;
std::shared_ptr<Svg> svg;
std::shared_ptr<window::Svg> svg;

SvgPanel();
void step() override;
void setBackground(std::shared_ptr<Svg> svg);
void setBackground(std::shared_ptr<window::Svg> svg);
};




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

@@ -16,8 +16,8 @@ struct SvgPort : PortWidget {
widget::SvgWidget* sw;

SvgPort();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
void setSvg(std::shared_ptr<window::Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<window::Svg> svg) {
setSvg(svg);
}
};


+ 1
- 1
include/app/SvgScrew.hpp View File

@@ -15,7 +15,7 @@ struct SvgScrew : widget::Widget {
widget::SvgWidget* sw;

SvgScrew();
void setSvg(std::shared_ptr<Svg> svg);
void setSvg(std::shared_ptr<window::Svg> svg);
};




+ 5
- 5
include/app/SvgSlider.hpp View File

@@ -20,19 +20,19 @@ struct SvgSlider : app::SliderKnob {
math::Vec minHandlePos, maxHandlePos;

SvgSlider();
void setBackgroundSvg(std::shared_ptr<Svg> svg);
void setHandleSvg(std::shared_ptr<Svg> svg);
void setBackgroundSvg(std::shared_ptr<window::Svg> svg);
void setHandleSvg(std::shared_ptr<window::Svg> svg);
void setHandlePos(math::Vec minHandlePos, math::Vec maxHandlePos);
void setHandlePosCentered(math::Vec minHandlePosCentered, math::Vec maxHandlePosCentered);
void onChange(const ChangeEvent& e) override;

DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {
DEPRECATED void setBackgroundSVG(std::shared_ptr<window::Svg> svg) {
setBackgroundSvg(svg);
}
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {
DEPRECATED void setHandleSVG(std::shared_ptr<window::Svg> svg) {
setBackgroundSvg(svg);
}
DEPRECATED void setSVGs(std::shared_ptr<Svg> backgroundSvg, std::shared_ptr<Svg> handleSvg) {
DEPRECATED void setSVGs(std::shared_ptr<window::Svg> backgroundSvg, std::shared_ptr<window::Svg> handleSvg) {
setBackgroundSvg(backgroundSvg);
setHandleSvg(handleSvg);
}


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

@@ -15,11 +15,11 @@ struct SvgSwitch : Switch {
widget::FramebufferWidget* fb;
CircularShadow* shadow;
widget::SvgWidget* sw;
std::vector<std::shared_ptr<Svg>> frames;
std::vector<std::shared_ptr<window::Svg>> frames;

SvgSwitch();
/** Adds an SVG file to represent the next switch position */
void addFrame(std::shared_ptr<Svg> svg);
void addFrame(std::shared_ptr<window::Svg> svg);
void onChange(const ChangeEvent& e) override;
};



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

@@ -2,8 +2,8 @@
#include <jansson.h>

#include <common.hpp>
#include <math.hpp>
#include <ui/common.hpp>
#include <svg.hpp> // for mm2px(), etc


namespace rack {


+ 3
- 0
include/componentlibrary.hpp View File

@@ -21,6 +21,9 @@ See LICENSE.md for legal details about using Rack component graphics in your Rac
namespace componentlibrary {


using namespace window;


////////////////////
// Color scheme
////////////////////


+ 1
- 2
include/helpers.hpp View File

@@ -66,8 +66,7 @@ TWidget* createWidgetCentered(math::Vec pos) {

inline app::SvgPanel* createPanel(std::string svgPath) {
app::SvgPanel* panel = new app::SvgPanel;
std::shared_ptr<Svg> svg = Svg::load(svgPath);
panel->setBackground(svg);
panel->setBackground(window::Svg::load(svgPath));
return panel;
}



+ 1
- 0
include/patch.hpp View File

@@ -8,6 +8,7 @@ namespace rack {
namespace patch {


/** Handles the Rack patch file state. */
struct Manager {
struct Internal;
Internal* internal;


+ 1
- 1
include/rack.hpp View File

@@ -9,7 +9,7 @@
#include <random.hpp>
#include <network.hpp>
#include <asset.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <context.hpp>
#include <midi.hpp>
#include <settings.hpp>


+ 1
- 1
include/weakptr.hpp View File

@@ -12,7 +12,7 @@ struct WeakHandle {
};


/** Base class for classes that allow WeakPtrs to be used.
/** Base class for classes that allow `WeakPtr`s to be used.
*/
struct WeakBase {
WeakHandle* weakHandle = nullptr;


+ 3
- 4
include/widget/SvgWidget.hpp View File

@@ -1,6 +1,5 @@
#pragma once
#include <widget/Widget.hpp>
#include <svg.hpp>


namespace rack {
@@ -9,14 +8,14 @@ namespace widget {

/** Draws an Svg */
struct SvgWidget : Widget {
std::shared_ptr<Svg> svg;
std::shared_ptr<window::Svg> svg;

/** Sets the box size to the SVG image size */
void wrap();

/** Sets and wraps the SVG */
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {
void setSvg(std::shared_ptr<window::Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<window::Svg> svg) {
setSvg(svg);
}



+ 1
- 1
include/widget/Widget.hpp View File

@@ -3,7 +3,7 @@

#include <common.hpp>
#include <math.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <color.hpp>
#include <widget/event.hpp>
#include <weakptr.hpp>


include/svg.hpp → include/window/Svg.hpp View File

@@ -9,6 +9,7 @@


namespace rack {
namespace window {


/** Arbitrary DPI, standardized for Rack. */
@@ -60,4 +61,5 @@ DEPRECATED typedef Svg SVG;
void svgDraw(NVGcontext* vg, NSVGimage* svg);


} // namespace window
} // namespace rack

include/window.hpp → include/window/Window.hpp View File

@@ -3,6 +3,10 @@
#include <memory>
#include <map>

#include <common.hpp>
#include <math.hpp>
#include <window/Svg.hpp>

#define GLEW_STATIC
#define GLEW_NO_GLU
#include <GL/glew.h>
@@ -11,14 +15,11 @@
#define NANOVG_GL2
#include <nanovg_gl.h>
#include <nanovg_gl_utils.h>
#include <nanosvg.h>
#include <svg.hpp>

#include <common.hpp>
#include <math.hpp>


namespace rack {
/** Handles OS windowing, OpenGL, and NanoVG
*/
namespace window {


@@ -48,6 +49,7 @@ struct Image {
};


/** OS window with OpenGL context. */
struct Window {
struct Internal;
Internal* internal;
@@ -93,9 +95,7 @@ struct Window {

std::shared_ptr<Font> loadFont(const std::string& filename);
std::shared_ptr<Image> loadImage(const std::string& filename);

/** Use `Svg::load(filename)` in new code. */
DEPRECATED std::shared_ptr<Svg> loadSvg(const std::string& filename) {
std::shared_ptr<Svg> loadSvg(const std::string& filename) {
return Svg::load(filename);
}


+ 2
- 2
src/app/CableWidget.cpp View File

@@ -57,14 +57,14 @@ struct PlugWidget : widget::Widget {
plugTransform->addChild(plugTint);

plug = new widget::SvgWidget;
plug->setSvg(Svg::load(asset::system("res/ComponentLibrary/Plug.svg")));
plug->setSvg(window::Svg::load(asset::system("res/ComponentLibrary/Plug.svg")));
plugTint->addChild(plug);
plugTransform->setSize(plug->getSize());
plugTransform->setPosition(plug->getSize().mult(-0.5));
plugTint->setSize(plug->getSize());

plugPort = new widget::SvgWidget;
plugPort->setSvg(Svg::load(asset::system("res/ComponentLibrary/PlugPort.svg")));
plugPort->setSvg(window::Svg::load(asset::system("res/ComponentLibrary/PlugPort.svg")));
plugPort->setPosition(plugPort->getSize().mult(-0.5));
fb->addChild(plugPort);



+ 2
- 2
src/app/LedDisplay.cpp View File

@@ -1,6 +1,6 @@
#include <app/LedDisplay.hpp>
#include <asset.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <context.hpp>


@@ -36,7 +36,7 @@ void LedDisplaySeparator::draw(const DrawArgs& args) {


LedDisplayChoice::LedDisplayChoice() {
box.size = mm2px(math::Vec(0, 28.0 / 3));
box.size = window::mm2px(math::Vec(0, 28.0 / 3));
fontPath = asset::system("res/fonts/ShareTechMono-Regular.ttf");
textOffset = math::Vec(10, 18);
color = nvgRGB(0xff, 0xd7, 0x14);


+ 1
- 1
src/app/MenuBar.cpp View File

@@ -16,7 +16,7 @@
#include <ui/ProgressBar.hpp>
#include <ui/Label.hpp>
#include <engine/Engine.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <asset.hpp>
#include <context.hpp>
#include <settings.hpp>


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

@@ -98,7 +98,7 @@ void ModuleWidget::setPanel(widget::Widget* panel) {
}
}

void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) {
void ModuleWidget::setPanel(std::shared_ptr<window::Svg> svg) {
// Create SvgPanel
SvgPanel* panel = new SvgPanel;
panel->setBackground(svg);


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

@@ -1,6 +1,6 @@
#include <app/PortWidget.hpp>
#include <app/Scene.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <context.hpp>
#include <history.hpp>
#include <engine/Engine.hpp>


+ 1
- 1
src/app/RackScrollWidget.cpp View File

@@ -1,6 +1,6 @@
#include <app/RackScrollWidget.hpp>
#include <app/Scene.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <context.hpp>
#include <settings.hpp>



+ 1
- 2
src/app/RailWidget.cpp View File

@@ -1,7 +1,6 @@
#include <app/RailWidget.hpp>
#include <context.hpp>
#include <asset.hpp>
#include <svg.hpp>
#include <widget/SvgWidget.hpp>
#include <widget/FramebufferWidget.hpp>

@@ -27,7 +26,7 @@ RailWidget::RailWidget() {
addChild(internal->railFb);

internal->railSw = new widget::SvgWidget;
internal->railSw->setSvg(Svg::load(asset::system("res/ComponentLibrary/Rail.svg")));
internal->railSw->setSvg(window::Svg::load(asset::system("res/ComponentLibrary/Rail.svg")));
internal->railFb->addChild(internal->railSw);
}



+ 1
- 1
src/app/SvgButton.cpp View File

@@ -30,7 +30,7 @@ void SvgButton::onButton(const ButtonEvent& e) {
}


void SvgButton::addFrame(std::shared_ptr<Svg> svg) {
void SvgButton::addFrame(std::shared_ptr<window::Svg> svg) {
frames.push_back(svg);
// If this is our first frame, automatically set SVG and size
if (!sw->svg) {


+ 1
- 1
src/app/SvgKnob.cpp View File

@@ -20,7 +20,7 @@ SvgKnob::SvgKnob() {
tw->addChild(sw);
}

void SvgKnob::setSvg(std::shared_ptr<Svg> svg) {
void SvgKnob::setSvg(std::shared_ptr<window::Svg> svg) {
sw->setSvg(svg);
tw->box.size = sw->box.size;
fb->box.size = sw->box.size;


+ 1
- 1
src/app/SvgPanel.cpp View File

@@ -37,7 +37,7 @@ void SvgPanel::step() {
Widget::step();
}

void SvgPanel::setBackground(std::shared_ptr<Svg> svg) {
void SvgPanel::setBackground(std::shared_ptr<window::Svg> svg) {
this->svg = svg;

sw->setSvg(svg);


+ 1
- 1
src/app/SvgPort.cpp View File

@@ -19,7 +19,7 @@ SvgPort::SvgPort() {
fb->addChild(sw);
}

void SvgPort::setSvg(std::shared_ptr<Svg> svg) {
void SvgPort::setSvg(std::shared_ptr<window::Svg> svg) {
sw->setSvg(svg);
fb->box.size = sw->box.size;
box.size = sw->box.size;


+ 1
- 1
src/app/SvgScrew.cpp View File

@@ -14,7 +14,7 @@ SvgScrew::SvgScrew() {
}


void SvgScrew::setSvg(std::shared_ptr<Svg> svg) {
void SvgScrew::setSvg(std::shared_ptr<window::Svg> svg) {
sw->setSvg(svg);
fb->box.size = sw->box.size;
box.size = sw->box.size;


+ 2
- 2
src/app/SvgSlider.cpp View File

@@ -19,7 +19,7 @@ SvgSlider::SvgSlider() {
}


void SvgSlider::setBackgroundSvg(std::shared_ptr<Svg> svg) {
void SvgSlider::setBackgroundSvg(std::shared_ptr<window::Svg> svg) {
background->setSvg(svg);
box.size = background->box.size;
fb->box.size = background->box.size;
@@ -27,7 +27,7 @@ void SvgSlider::setBackgroundSvg(std::shared_ptr<Svg> svg) {
}


void SvgSlider::setHandleSvg(std::shared_ptr<Svg> svg) {
void SvgSlider::setHandleSvg(std::shared_ptr<window::Svg> svg) {
handle->setSvg(svg);
handle->box.pos = minHandlePos;
fb->setDirty();


+ 1
- 1
src/app/SvgSwitch.cpp View File

@@ -17,7 +17,7 @@ SvgSwitch::SvgSwitch() {
fb->addChild(sw);
}

void SvgSwitch::addFrame(std::shared_ptr<Svg> svg) {
void SvgSwitch::addFrame(std::shared_ptr<window::Svg> svg) {
frames.push_back(svg);
// If this is our first frame, automatically set SVG and size
if (!sw->svg) {


+ 1
- 1
src/context.cpp View File

@@ -1,5 +1,5 @@
#include <context.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <patch.hpp>
#include <engine/Engine.hpp>
#include <app/Scene.hpp>


+ 1
- 1
src/gamepad.cpp View File

@@ -1,7 +1,7 @@
#include <gamepad.hpp>
#include <midi.hpp>
#include <string.hpp>
#include <window.hpp>
#include <window/Window.hpp>


namespace rack {


+ 1
- 1
src/keyboard.cpp View File

@@ -2,7 +2,7 @@

#include <keyboard.hpp>
#include <midi.hpp>
#include <window.hpp>
#include <window/Window.hpp>


namespace rack {


+ 1
- 1
src/library.cpp View File

@@ -8,7 +8,7 @@
#include <network.hpp>
#include <system.hpp>
#include <context.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <asset.hpp>
#include <settings.hpp>
#include <plugin.hpp>


+ 1
- 1
src/settings.cpp View File

@@ -1,7 +1,7 @@
#include <jansson.h>

#include <settings.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <plugin.hpp>
#include <app/Scene.hpp>
#include <engine/Engine.hpp>


+ 1
- 1
src/ui/Scrollbar.cpp View File

@@ -1,7 +1,7 @@
#include <ui/Scrollbar.hpp>
#include <ui/ScrollWidget.hpp>
#include <context.hpp>
#include <window.hpp>
#include <window/Window.hpp>


namespace rack {


+ 2
- 2
src/widget/SvgWidget.cpp View File

@@ -15,7 +15,7 @@ void SvgWidget::wrap() {
}
}

void SvgWidget::setSvg(std::shared_ptr<Svg> svg) {
void SvgWidget::setSvg(std::shared_ptr<window::Svg> svg) {
this->svg = svg;
wrap();
}
@@ -24,7 +24,7 @@ void SvgWidget::draw(const DrawArgs& args) {
if (!svg)
return;

svgDraw(args.vg, svg->handle);
window::svgDraw(args.vg, svg->handle);
}




+ 1
- 1
src/widget/event.cpp View File

@@ -1,7 +1,7 @@
#include <widget/event.hpp>
#include <widget/Widget.hpp>
#include <context.hpp>
#include <window.hpp>
#include <window/Window.hpp>
#include <system.hpp>




src/svg.cpp → src/window/Svg.cpp View File

@@ -1,4 +1,4 @@
#include <svg.hpp>
#include <window/Svg.hpp>
#include <map>
#include <math.hpp>
#include <string.hpp>
@@ -9,6 +9,7 @@


namespace rack {
namespace window {


Svg::~Svg() {
@@ -301,4 +302,5 @@ void svgDraw(NVGcontext* vg, NSVGimage* svg) {
}


} // namespace window
} // namespace rack

src/window.cpp → src/window/Window.cpp View File

@@ -10,7 +10,7 @@
#include <stb_image_write.h>
#include <osdialog.h>

#include <window.hpp>
#include <window/Window.hpp>
#include <asset.hpp>
#include <widget/Widget.hpp>
#include <app/Scene.hpp>

Loading…
Cancel
Save