diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 777a88e4..f675bf24 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -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 struct LEDLightSlider : LightSlider { 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 { template struct LEDLightSliderHorizontal : LightSlider { 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 { 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; } }; diff --git a/include/svg.hpp b/include/svg.hpp index fd09255f..ac7840d4 100644 --- a/include/svg.hpp +++ b/include/svg.hpp @@ -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 load(const std::string& filename); diff --git a/src/app/RackRail.cpp b/src/app/RackRail.cpp index 3b741caa..35aaec84 100644 --- a/src/app/RackRail.cpp +++ b/src/app/RackRail.cpp @@ -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")); } diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 97f13b3a..d7b710ee 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -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); diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index 57b64e29..14062a53 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/CV_CC.cpp b/src/core/CV_CC.cpp index 91fe6f83..80d704e3 100644 --- a/src/core/CV_CC.cpp +++ b/src/core/CV_CC.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/CV_Gate.cpp b/src/core/CV_Gate.cpp index 609d5b87..a11d5082 100644 --- a/src/core/CV_Gate.cpp +++ b/src/core/CV_Gate.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/CV_MIDI.cpp b/src/core/CV_MIDI.cpp index 39e0945d..aaa9c775 100644 --- a/src/core/CV_MIDI.cpp +++ b/src/core/CV_MIDI.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/MIDI_CC.cpp b/src/core/MIDI_CC.cpp index 26911d79..490f2a8e 100644 --- a/src/core/MIDI_CC.cpp +++ b/src/core/MIDI_CC.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/MIDI_CV.cpp b/src/core/MIDI_CV.cpp index 245408d7..ec495758 100644 --- a/src/core/MIDI_CV.cpp +++ b/src/core/MIDI_CV.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/MIDI_Gate.cpp b/src/core/MIDI_Gate.cpp index 31c64c66..49ca1bc2 100644 --- a/src/core/MIDI_Gate.cpp +++ b/src/core/MIDI_Gate.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/MIDI_Map.cpp b/src/core/MIDI_Map.cpp index c3ad9c37..6604fefe 100644 --- a/src/core/MIDI_Map.cpp +++ b/src/core/MIDI_Map.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/core/Notes.cpp b/src/core/Notes.cpp index 616c43e6..cbff4bb6 100644 --- a/src/core/Notes.cpp +++ b/src/core/Notes.cpp @@ -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(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); diff --git a/src/dep.cpp b/src/dep.cpp index 9b4961ad..650738f1 100644 --- a/src/dep.cpp +++ b/src/dep.cpp @@ -1,5 +1,7 @@ // This source file compiles those annoying implementation-in-header libraries +#include // for fopen_u8 + #define GLEW_STATIC #define GLEW_NO_GLU #include diff --git a/src/svg.cpp b/src/svg.cpp index 75451c21..7cb5109a 100644 --- a/src/svg.cpp +++ b/src/svg.cpp @@ -1,15 +1,22 @@ #include #include #include -#include +#include // 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> svgCache; @@ -35,7 +48,7 @@ std::shared_ptr Svg::load(const std::string& filename) { auto sp = svgCache[filename].lock(); if (!sp) { svgCache[filename] = sp = std::make_shared(); - sp->load(filename); + sp->loadFile(filename); } return sp; } @@ -43,10 +56,10 @@ std::shared_ptr 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) { diff --git a/src/widget/FramebufferWidget.cpp b/src/widget/FramebufferWidget.cpp index 6c01deee..2578d406 100644 --- a/src/widget/FramebufferWidget.cpp +++ b/src/widget/FramebufferWidget.cpp @@ -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); }