Browse Source

Change all deprecated APP->window->loadSvg() calls to Svg::load(). Fix FramebufferWidget::onContextDestroy() not unsetting framebuffer handle.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
4e7f1edb24
16 changed files with 138 additions and 111 deletions
  1. +82
    -82
      include/componentlibrary.hpp
  2. +4
    -1
      include/svg.hpp
  3. +1
    -1
      src/app/RackRail.cpp
  4. +7
    -3
      src/app/RackWidget.cpp
  5. +3
    -3
      src/core/AudioInterface.cpp
  6. +1
    -1
      src/core/CV_CC.cpp
  7. +1
    -1
      src/core/CV_Gate.cpp
  8. +1
    -1
      src/core/CV_MIDI.cpp
  9. +1
    -1
      src/core/MIDI_CC.cpp
  10. +1
    -1
      src/core/MIDI_CV.cpp
  11. +1
    -1
      src/core/MIDI_Gate.cpp
  12. +1
    -1
      src/core/MIDI_Map.cpp
  13. +1
    -1
      src/core/Notes.cpp
  14. +2
    -0
      src/dep.cpp
  15. +23
    -10
      src/svg.cpp
  16. +8
    -3
      src/widget/FramebufferWidget.cpp

+ 82
- 82
include/componentlibrary.hpp View File

@@ -222,31 +222,31 @@ struct RoundKnob : app::SvgKnob {

struct RoundBlackKnob : RoundKnob {
RoundBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundBlackKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundBlackKnob.svg")));
}
};

struct RoundSmallBlackKnob : RoundKnob {
RoundSmallBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg")));
}
};

struct RoundLargeBlackKnob : RoundKnob {
RoundLargeBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg")));
}
};

struct RoundBigBlackKnob : RoundKnob {
RoundBigBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundBigBlackKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundBigBlackKnob.svg")));
}
};

struct RoundHugeBlackKnob : RoundKnob {
RoundHugeBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg")));
}
};

@@ -266,37 +266,37 @@ struct Davies1900hKnob : app::SvgKnob {

struct Davies1900hWhiteKnob : Davies1900hKnob {
Davies1900hWhiteKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hWhite.svg")));
}
};

struct Davies1900hBlackKnob : Davies1900hKnob {
Davies1900hBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hBlack.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hBlack.svg")));
}
};

struct Davies1900hRedKnob : Davies1900hKnob {
Davies1900hRedKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hRed.svg")));
}
};

struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
Davies1900hLargeWhiteKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
}
};

struct Davies1900hLargeBlackKnob : Davies1900hKnob {
Davies1900hLargeBlackKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
}
};

struct Davies1900hLargeRedKnob : Davies1900hKnob {
Davies1900hLargeRedKnob() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg")));
}
};

@@ -310,163 +310,163 @@ struct Rogan : app::SvgKnob {

struct Rogan6PSWhite : Rogan {
Rogan6PSWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg")));
}
};

struct Rogan5PSGray : Rogan {
Rogan5PSGray() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan5PSGray.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan5PSGray.svg")));
}
};

struct Rogan3PSBlue : Rogan {
Rogan3PSBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg")));
}
};

struct Rogan3PSRed : Rogan {
Rogan3PSRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PSRed.svg")));
}
};

struct Rogan3PSGreen : Rogan {
Rogan3PSGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg")));
}
};

struct Rogan3PSWhite : Rogan {
Rogan3PSWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg")));
}
};

struct Rogan3PBlue : Rogan {
Rogan3PBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PBlue.svg")));
}
};

struct Rogan3PRed : Rogan {
Rogan3PRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PRed.svg")));
}
};

struct Rogan3PGreen : Rogan {
Rogan3PGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PGreen.svg")));
}
};

struct Rogan3PWhite : Rogan {
Rogan3PWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan3PWhite.svg")));
}
};

struct Rogan2SGray : Rogan {
Rogan2SGray() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2SGray.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2SGray.svg")));
}
};

struct Rogan2PSBlue : Rogan {
Rogan2PSBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg")));
}
};

struct Rogan2PSRed : Rogan {
Rogan2PSRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PSRed.svg")));
}
};

struct Rogan2PSGreen : Rogan {
Rogan2PSGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg")));
}
};

struct Rogan2PSWhite : Rogan {
Rogan2PSWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg")));
}
};

struct Rogan2PBlue : Rogan {
Rogan2PBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PBlue.svg")));
}
};

struct Rogan2PRed : Rogan {
Rogan2PRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PRed.svg")));
}
};

struct Rogan2PGreen : Rogan {
Rogan2PGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PGreen.svg")));
}
};

struct Rogan2PWhite : Rogan {
Rogan2PWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan2PWhite.svg")));
}
};

struct Rogan1PSBlue : Rogan {
Rogan1PSBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg")));
}
};

struct Rogan1PSRed : Rogan {
Rogan1PSRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PSRed.svg")));
}
};

struct Rogan1PSGreen : Rogan {
Rogan1PSGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg")));
}
};

struct Rogan1PSWhite : Rogan {
Rogan1PSWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg")));
}
};

struct Rogan1PBlue : Rogan {
Rogan1PBlue() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PBlue.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PBlue.svg")));
}
};

struct Rogan1PRed : Rogan {
Rogan1PRed() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PRed.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PRed.svg")));
}
};

struct Rogan1PGreen : Rogan {
Rogan1PGreen() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PGreen.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PGreen.svg")));
}
};

struct Rogan1PWhite : Rogan {
Rogan1PWhite() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PWhite.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Rogan1PWhite.svg")));
}
};

@@ -475,11 +475,11 @@ struct SynthTechAlco : app::SvgKnob {
SynthTechAlco() {
minAngle = -0.82 * M_PI;
maxAngle = 0.82 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/SynthTechAlco.svg")));
// Add cap
widget::FramebufferWidget* capFb = new widget::FramebufferWidget;
widget::SvgWidget* cap = new widget::SvgWidget;
cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg")));
cap->setSvg(Svg::load(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg")));
capFb->addChild(cap);
addChild(capFb);
}
@@ -489,7 +489,7 @@ struct Trimpot : app::SvgKnob {
Trimpot() {
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/Trimpot.svg")));
}
};

@@ -497,7 +497,7 @@ struct BefacoBigKnob : app::SvgKnob {
BefacoBigKnob() {
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoBigKnob.svg")));
}
};

@@ -511,7 +511,7 @@ struct BefacoTinyKnob : app::SvgKnob {
BefacoTinyKnob() {
minAngle = -0.75 * M_PI;
maxAngle = 0.75 * M_PI;
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg")));
}
};

@@ -520,8 +520,8 @@ struct BefacoSlidePot : app::SvgSlider {
math::Vec margin = math::Vec(3.5, 3.5);
maxHandlePos = math::Vec(-1, -2).plus(margin);
minHandlePos = math::Vec(-1, 87).plus(margin);
setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")));
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
background->box.pos = margin;
box.size = background->box.size.plus(margin.mult(2));
}
@@ -531,38 +531,38 @@ struct LEDSlider : app::SvgSlider {
LEDSlider() {
maxHandlePos = app::mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0)));
minHandlePos = app::mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0)));
setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSlider.svg")));
setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSlider.svg")));
}
};

/** API is unstable for LEDSlider. Will add a LightWidget later. */
struct LEDSliderGreen : LEDSlider {
LEDSliderGreen() {
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
}
};

struct LEDSliderRed : LEDSlider {
LEDSliderRed() {
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg")));
}
};

struct LEDSliderYellow : LEDSlider {
LEDSliderYellow() {
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
}
};

struct LEDSliderBlue : LEDSlider {
LEDSliderBlue() {
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
}
};

struct LEDSliderWhite : LEDSlider {
LEDSliderWhite() {
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
}
};

@@ -571,7 +571,7 @@ struct LEDSliderHorizontal : app::SvgSlider {
horizontal = true;
maxHandlePos = app::mm2px(math::Vec(22.078, 0.738).plus(math::Vec(0, 2)));
minHandlePos = app::mm2px(math::Vec(0.738, 0.738).plus(math::Vec(0, 2)));
setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderHorizontal.svg")));
setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHorizontal.svg")));
}
};

@@ -601,7 +601,7 @@ struct LightSlider : TBase {
template <typename TLightBase = RedLight>
struct LEDLightSlider : LightSlider<LEDSlider, TLightBase> {
LEDLightSlider() {
this->setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderHandle.svg")));
this->setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHandle.svg")));
this->light->box.size = app::mm2px(math::Vec(1.524, 3.276));
}
};
@@ -609,7 +609,7 @@ struct LEDLightSlider : LightSlider<LEDSlider, TLightBase> {
template <typename TLightBase = RedLight>
struct LEDLightSliderHorizontal : LightSlider<LEDSliderHorizontal, TLightBase> {
LEDLightSliderHorizontal() {
this->setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderHorizontalHandle.svg")));
this->setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHorizontalHandle.svg")));
this->light->box.size = app::mm2px(math::Vec(3.276, 1.524));
}
};
@@ -621,19 +621,19 @@ struct LEDLightSliderHorizontal : LightSlider<LEDSliderHorizontal, TLightBase> {

struct PJ301MPort : app::SvgPort {
PJ301MPort() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ301M.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/PJ301M.svg")));
}
};

struct PJ3410Port : app::SvgPort {
PJ3410Port() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ3410.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/PJ3410.svg")));
}
};

struct CL1362Port : app::SvgPort {
CL1362Port() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/CL1362.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/CL1362.svg")));
}
};

@@ -658,70 +658,70 @@ struct MomentarySwitch : TSwitch {

struct NKK : app::SvgSwitch {
NKK() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_1.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_2.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/NKK_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/NKK_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/NKK_2.svg")));
}
};

struct CKSS : app::SvgSwitch {
CKSS() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKSS_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKSS_1.svg")));
}
};

struct CKSSThree : app::SvgSwitch {
CKSSThree() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_1.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_2.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKSSThree_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKSSThree_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKSSThree_2.svg")));
}
};

struct CKD6 : app::SvgSwitch {
CKD6() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKD6_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/CKD6_1.svg")));
}
};

struct TL1105 : app::SvgSwitch {
TL1105() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/TL1105_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/TL1105_1.svg")));
}
};

struct LEDButton : app::SvgSwitch {
LEDButton() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDButton.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/LEDButton.svg")));
}
};

struct BefacoSwitch : app::SvgSwitch {
BefacoSwitch() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_1.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_2.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/BefacoSwitch_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/BefacoSwitch_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/BefacoSwitch_2.svg")));
}
};

struct BefacoPush : app::SvgSwitch {
BefacoPush() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_0.svg")));
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_1.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/BefacoPush_0.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/BefacoPush_1.svg")));
}
};

struct LEDBezel : app::SvgSwitch {
LEDBezel() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDBezel.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/LEDBezel.svg")));
}
};

@@ -745,7 +745,7 @@ struct LEDLightBezel : LEDBezel {
struct PB61303 : app::SvgSwitch {
PB61303() {
momentary = true;
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/PB61303.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/PB61303.svg")));
}
};

@@ -755,13 +755,13 @@ struct PB61303 : app::SvgSwitch {

struct ScrewSilver : app::SvgScrew {
ScrewSilver() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewSilver.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/ScrewSilver.svg")));
}
};

struct ScrewBlack : app::SvgScrew {
ScrewBlack() {
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewBlack.svg")));
setSvg(Svg::load(asset::system("res/ComponentLibrary/ScrewBlack.svg")));
}
};

@@ -808,7 +808,7 @@ struct SegmentDisplay : widget::Widget {

struct AudioButton_ADAT : app::AudioButton {
AudioButton_ADAT() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/ADAT.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/ADAT.svg")));
shadow->opacity = 0.0;
}
};
@@ -816,7 +816,7 @@ struct AudioButton_ADAT : app::AudioButton {

struct AudioButton_USB_B : app::AudioButton {
AudioButton_USB_B() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/USB-B.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/USB-B.svg")));
shadow->opacity = 0.0;
}
};
@@ -824,7 +824,7 @@ struct AudioButton_USB_B : app::AudioButton {

struct MidiButton_MIDI_DIN : app::MidiButton {
MidiButton_MIDI_DIN() {
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/MIDI_DIN.svg")));
addFrame(Svg::load(asset::system("res/ComponentLibrary/MIDI_DIN.svg")));
shadow->opacity = 0.0;
}
};


+ 4
- 1
include/svg.hpp View File

@@ -12,9 +12,12 @@ namespace rack {

struct Svg {
NSVGimage* handle = NULL;

~Svg();
/** Don't call this directly. Use `Svg::load()` for caching. */
void loadFile(const std::string& filename);
~Svg();
/** Loads SVG data from a string. */
void loadString(const std::string& str);

/** Loads Svg from a cache. */
static std::shared_ptr<Svg> load(const std::string& filename);


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

@@ -9,7 +9,7 @@ namespace app {


RackRail::RackRail() {
busBoardSvg = APP->window->loadSvg(asset::system("res/ComponentLibrary/RackBusboard.svg"));
busBoardSvg = Svg::load(asset::system("res/ComponentLibrary/RackBusboard.svg"));
}




+ 7
- 3
src/app/RackWidget.cpp View File

@@ -389,11 +389,15 @@ static void RackWidget_updateExpanders(RackWidget* that) {
}

void RackWidget::addModule(ModuleWidget* m) {
// Add module to ModuleContainer
assert(m);

// Module must be 3U high and at least 1HP wide
assert(m->box.size.x >= RACK_GRID_WIDTH);
assert(m->box.size.y == RACK_GRID_HEIGHT);
if (m->box.size.x < RACK_GRID_WIDTH / 2)
throw Exception("Module %s width is %g px, must be at least %g px", m->model->getFullName().c_str(), m->box.size.x, RACK_GRID_WIDTH);

if (m->box.size.y != RACK_GRID_HEIGHT)
throw Exception("Module %s height is %g px, must be %g px", m->model->getFullName().c_str(), m->box.size.y, RACK_GRID_HEIGHT);

moduleContainer->addChild(m);

RackWidget_updateExpanders(this);


+ 3
- 3
src/core/AudioInterface.cpp View File

@@ -414,7 +414,7 @@ struct AudioInterfaceWidget : ModuleWidget {
setModule(module);

if (NUM_AUDIO_INPUTS == 8 && NUM_AUDIO_OUTPUTS == 8) {
setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface.svg")));
setPanel(Svg::load(asset::system("res/Core/AudioInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
@@ -454,7 +454,7 @@ struct AudioInterfaceWidget : ModuleWidget {
addChild(audioWidget);
}
else if (NUM_AUDIO_INPUTS == 16 && NUM_AUDIO_OUTPUTS == 16) {
setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface16.svg")));
setPanel(Svg::load(asset::system("res/Core/AudioInterface16.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
@@ -518,7 +518,7 @@ struct AudioInterfaceWidget : ModuleWidget {
addChild(audioWidget);
}
else if (NUM_AUDIO_INPUTS == 2 && NUM_AUDIO_OUTPUTS == 2) {
setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface2.svg")));
setPanel(Svg::load(asset::system("res/Core/AudioInterface2.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/CV_CC.cpp View File

@@ -125,7 +125,7 @@ struct CV_CC : Module {
struct CV_CCWidget : ModuleWidget {
CV_CCWidget(CV_CC* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-CC.svg")));
setPanel(Svg::load(asset::system("res/Core/CV-CC.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/CV_Gate.cpp View File

@@ -181,7 +181,7 @@ struct CV_GatePanicItem : MenuItem {
struct CV_GateWidget : ModuleWidget {
CV_GateWidget(CV_Gate* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-Gate.svg")));
setPanel(Svg::load(asset::system("res/Core/CV-Gate.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/CV_MIDI.cpp View File

@@ -149,7 +149,7 @@ struct CV_MIDIPanicItem : MenuItem {
struct CV_MIDIWidget : ModuleWidget {
CV_MIDIWidget(CV_MIDI* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-MIDI.svg")));
setPanel(Svg::load(asset::system("res/Core/CV-MIDI.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/MIDI_CC.cpp View File

@@ -216,7 +216,7 @@ struct MIDI_CC : Module {
struct MIDI_CCWidget : ModuleWidget {
MIDI_CCWidget(MIDI_CC* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CC.svg")));
setPanel(Svg::load(asset::system("res/Core/MIDI-CC.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/MIDI_CV.cpp View File

@@ -482,7 +482,7 @@ struct MIDI_CV : Module {
struct MIDI_CVWidget : ModuleWidget {
MIDI_CVWidget(MIDI_CV* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CV.svg")));
setPanel(Svg::load(asset::system("res/Core/MIDI-CV.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/MIDI_Gate.cpp View File

@@ -208,7 +208,7 @@ struct MIDI_GatePanicItem : MenuItem {
struct MIDI_GateWidget : ModuleWidget {
MIDI_GateWidget(MIDI_Gate* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Gate.svg")));
setPanel(Svg::load(asset::system("res/Core/MIDI-Gate.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/MIDI_Map.cpp View File

@@ -477,7 +477,7 @@ struct MIDI_MapDisplay : MidiWidget {
struct MIDI_MapWidget : ModuleWidget {
MIDI_MapWidget(MIDI_Map* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Map.svg")));
setPanel(Svg::load(asset::system("res/Core/MIDI-Map.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 1
- 1
src/core/Notes.cpp View File

@@ -60,7 +60,7 @@ struct NotesWidget : ModuleWidget {

NotesWidget(NotesModule* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::system("res/Core/Notes.svg")));
setPanel(Svg::load(asset::system("res/Core/Notes.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));


+ 2
- 0
src/dep.cpp View File

@@ -1,5 +1,7 @@
// This source file compiles those annoying implementation-in-header libraries

#include <common.hpp> // for fopen_u8

#define GLEW_STATIC
#define GLEW_NO_GLU
#include <GL/glew.h>


+ 23
- 10
src/svg.cpp View File

@@ -1,15 +1,22 @@
#include <svg.hpp>
#include <map>
#include <math.hpp>
#include <app/common.hpp>
#include <app/common.hpp> // for app::SVG_DPI


// #define DEBUG_ONLY(x) x
#define DEBUG_ONLY(x)


namespace rack {


Svg::~Svg() {
if (handle)
nsvgDelete(handle);
}


void Svg::loadFile(const std::string& filename) {
handle = nsvgParseFromFile(filename.c_str(), "px", app::SVG_DPI);
if (handle) {
@@ -21,13 +28,19 @@ void Svg::loadFile(const std::string& filename) {
}


Svg::~Svg() {
if (handle)
nsvgDelete(handle);
void Svg::loadString(const std::string& str) {
// nsvgParse modifies the input string
std::string strCopy = str;
handle = nsvgParse(&strCopy[0], "px", app::SVG_DPI);
if (handle) {
INFO("Loaded SVG");
}
else {
WARN("Failed to load SVG");
}
}



static std::map<std::string, std::weak_ptr<Svg>> svgCache;


@@ -35,7 +48,7 @@ std::shared_ptr<Svg> Svg::load(const std::string& filename) {
auto sp = svgCache[filename].lock();
if (!sp) {
svgCache[filename] = sp = std::make_shared<Svg>();
sp->load(filename);
sp->loadFile(filename);
}
return sp;
}
@@ -43,10 +56,10 @@ std::shared_ptr<Svg> Svg::load(const std::string& filename) {

static NVGcolor getNVGColor(uint32_t color) {
return nvgRGBA(
(color >> 0) & 0xff,
(color >> 8) & 0xff,
(color >> 16) & 0xff,
(color >> 24) & 0xff);
(color >> 0) & 0xff,
(color >> 8) & 0xff,
(color >> 16) & 0xff,
(color >> 24) & 0xff);
}

static NVGpaint getPaint(NVGcontext* vg, NSVGpaint* p) {


+ 8
- 3
src/widget/FramebufferWidget.cpp View File

@@ -71,7 +71,7 @@ void FramebufferWidget::step() {
return;

// In case we fail drawing the framebuffer, don't try again the next frame, so reset `dirty` here.
setDirty(false);
dirty = false;
NVGcontext* vg = APP->window->vg;

internal->fbScale = internal->scale;
@@ -98,8 +98,10 @@ void FramebufferWidget::step() {
if (!internal->fb || !newFbSize.equals(internal->fbSize)) {
internal->fbSize = newFbSize;
// Delete old framebuffer
if (internal->fb)
if (internal->fb) {
nvgluDeleteFramebuffer(internal->fb);
internal->fb = NULL;
}
// Create a framebuffer
if (internal->fbSize.isFinite() && !internal->fbSize.isZero()) {
internal->fb = nvgluCreateFramebuffer(vg, internal->fbSize.x, internal->fbSize.y, 0);
@@ -292,8 +294,11 @@ void FramebufferWidget::onContextCreate(const ContextCreateEvent& e) {


void FramebufferWidget::onContextDestroy(const ContextDestroyEvent& e) {
if (internal->fb)
if (internal->fb) {
nvgluDeleteFramebuffer(internal->fb);
internal->fb = NULL;
}
setDirty();
Widget::onContextDestroy(e);
}



Loading…
Cancel
Save