@@ -45,7 +45,7 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
Transfers ownership | Transfers ownership | ||||
*/ | */ | ||||
void setModule(engine::Module *module); | void setModule(engine::Module *module); | ||||
void setPanel(std::shared_ptr<SVG> svg); | |||||
void setPanel(std::shared_ptr<Svg> svg); | |||||
/** Convenience functions for adding special widgets (calls addChild()) */ | /** Convenience functions for adding special widgets (calls addChild()) */ | ||||
void addParam(ParamWidget *param); | void addParam(ParamWidget *param); | ||||
@@ -1,35 +0,0 @@ | |||||
#pragma once | |||||
#include "app/common.hpp" | |||||
#include "app/SliderKnob.hpp" | |||||
#include "widget/FramebufferWidget.hpp" | |||||
#include "widget/SVGWidget.hpp" | |||||
namespace rack { | |||||
namespace app { | |||||
/** Behaves like a knob but linearly moves an widget::SVGWidget between two points. | |||||
Can be used for horizontal or vertical linear faders. | |||||
*/ | |||||
struct SVGSlider : app::SliderKnob { | |||||
widget::FramebufferWidget *fb; | |||||
widget::SVGWidget *background; | |||||
widget::SVGWidget *handle; | |||||
/** Intermediate positions will be interpolated between these positions */ | |||||
math::Vec minHandlePos, maxHandlePos; | |||||
SVGSlider(); | |||||
void setBackgroundSVG(std::shared_ptr<SVG> backgroundSVG); | |||||
void setHandleSVG(std::shared_ptr<SVG> handleSVG); | |||||
void onChange(const event::Change &e) override; | |||||
DEPRECATED void setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG) { | |||||
setBackgroundSVG(backgroundSVG); | |||||
setHandleSVG(handleSVG); | |||||
} | |||||
}; | |||||
} // namespace app | |||||
} // namespace rack |
@@ -2,25 +2,28 @@ | |||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "widget/OpaqueWidget.hpp" | #include "widget/OpaqueWidget.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
struct SVGButton : widget::OpaqueWidget { | |||||
struct SvgButton : widget::OpaqueWidget { | |||||
widget::FramebufferWidget *fb; | widget::FramebufferWidget *fb; | ||||
widget::SVGWidget *sw; | |||||
std::vector<std::shared_ptr<SVG>> frames; | |||||
widget::SvgWidget *sw; | |||||
std::vector<std::shared_ptr<Svg>> frames; | |||||
SVGButton(); | |||||
void addFrame(std::shared_ptr<SVG> svg); | |||||
SvgButton(); | |||||
void addFrame(std::shared_ptr<Svg> svg); | |||||
void onDragStart(const event::DragStart &e) override; | void onDragStart(const event::DragStart &e) override; | ||||
void onDragEnd(const event::DragEnd &e) override; | void onDragEnd(const event::DragEnd &e) override; | ||||
void onDragDrop(const event::DragDrop &e) override; | void onDragDrop(const event::DragDrop &e) override; | ||||
}; | }; | ||||
DEPRECATED typedef SvgButton SVGButton; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -3,7 +3,7 @@ | |||||
#include "app/Knob.hpp" | #include "app/Knob.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/TransformWidget.hpp" | #include "widget/TransformWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "app/CircularShadow.hpp" | #include "app/CircularShadow.hpp" | ||||
@@ -12,19 +12,23 @@ namespace app { | |||||
/** A knob which rotates an SVG and caches it in a framebuffer */ | /** A knob which rotates an SVG and caches it in a framebuffer */ | ||||
struct SVGKnob : Knob { | |||||
struct SvgKnob : Knob { | |||||
widget::FramebufferWidget *fb; | widget::FramebufferWidget *fb; | ||||
widget::TransformWidget *tw; | widget::TransformWidget *tw; | ||||
widget::SVGWidget *sw; | |||||
widget::SvgWidget *sw; | |||||
CircularShadow *shadow; | CircularShadow *shadow; | ||||
/** Angles in radians */ | /** Angles in radians */ | ||||
float minAngle, maxAngle; | float minAngle, maxAngle; | ||||
SVGKnob(); | |||||
void setSVG(std::shared_ptr<SVG> svg); | |||||
SvgKnob(); | |||||
void setSvg(std::shared_ptr<Svg> svg); | |||||
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
void onChange(const event::Change &e) override; | void onChange(const event::Change &e) override; | ||||
}; | }; | ||||
DEPRECATED typedef SvgKnob SVGKnob; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -2,7 +2,7 @@ | |||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "widget/TransparentWidget.hpp" | #include "widget/TransparentWidget.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
@@ -15,12 +15,14 @@ struct PanelBorder : widget::TransparentWidget { | |||||
}; | }; | ||||
struct SVGPanel : widget::FramebufferWidget { | |||||
struct SvgPanel : widget::FramebufferWidget { | |||||
void step() override; | void step() override; | ||||
void setBackground(std::shared_ptr<SVG> svg); | |||||
void setBackground(std::shared_ptr<Svg> svg); | |||||
}; | }; | ||||
DEPRECATED typedef SvgPanel SVGPanel; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -2,7 +2,7 @@ | |||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "app/PortWidget.hpp" | #include "app/PortWidget.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "app/CircularShadow.hpp" | #include "app/CircularShadow.hpp" | ||||
@@ -10,15 +10,19 @@ namespace rack { | |||||
namespace app { | namespace app { | ||||
struct SVGPort : PortWidget { | |||||
struct SvgPort : PortWidget { | |||||
widget::FramebufferWidget *fb; | widget::FramebufferWidget *fb; | ||||
widget::SVGWidget *sw; | |||||
widget::SvgWidget *sw; | |||||
CircularShadow *shadow; | CircularShadow *shadow; | ||||
SVGPort(); | |||||
void setSVG(std::shared_ptr<SVG> svg); | |||||
SvgPort(); | |||||
void setSvg(std::shared_ptr<Svg> svg); | |||||
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
}; | }; | ||||
DEPRECATED typedef SvgPort SVGPort; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -1,7 +1,7 @@ | |||||
#pragma once | #pragma once | ||||
#include "common.hpp" | #include "common.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -9,12 +9,15 @@ namespace app { | |||||
/** If you don't add these to your ModuleWidget, they will fall out of the rack... */ | /** If you don't add these to your ModuleWidget, they will fall out of the rack... */ | ||||
struct SVGScrew : widget::FramebufferWidget { | |||||
widget::SVGWidget *sw; | |||||
struct SvgScrew : widget::FramebufferWidget { | |||||
widget::SvgWidget *sw; | |||||
SVGScrew(); | |||||
SvgScrew(); | |||||
}; | }; | ||||
DEPRECATED typedef SvgScrew SVGScrew; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -0,0 +1,40 @@ | |||||
#pragma once | |||||
#include "app/common.hpp" | |||||
#include "app/SliderKnob.hpp" | |||||
#include "widget/FramebufferWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
namespace rack { | |||||
namespace app { | |||||
/** Behaves like a knob but linearly moves an widget::SvgWidget between two points. | |||||
Can be used for horizontal or vertical linear faders. | |||||
*/ | |||||
struct SvgSlider : app::SliderKnob { | |||||
widget::FramebufferWidget *fb; | |||||
widget::SvgWidget *background; | |||||
widget::SvgWidget *handle; | |||||
/** Intermediate positions will be interpolated between these positions */ | |||||
math::Vec minHandlePos, maxHandlePos; | |||||
SvgSlider(); | |||||
void setBackgroundSvg(std::shared_ptr<Svg> svg); | |||||
void setHandleSvg(std::shared_ptr<Svg> svg); | |||||
void onChange(const event::Change &e) override; | |||||
DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | |||||
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | |||||
DEPRECATED void setSVGs(std::shared_ptr<Svg> backgroundSvg, std::shared_ptr<Svg> handleSvg) { | |||||
setBackgroundSvg(backgroundSvg); | |||||
setHandleSvg(handleSvg); | |||||
} | |||||
}; | |||||
DEPRECATED typedef SvgSlider SVGSlider; | |||||
} // namespace app | |||||
} // namespace rack |
@@ -1,7 +1,7 @@ | |||||
#pragma once | #pragma once | ||||
#include "app/common.hpp" | #include "app/common.hpp" | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "app/Switch.hpp" | #include "app/Switch.hpp" | ||||
@@ -10,17 +10,20 @@ namespace app { | |||||
/** A ParamWidget with multiple frames corresponding to its value */ | /** A ParamWidget with multiple frames corresponding to its value */ | ||||
struct SVGSwitch : Switch { | |||||
struct SvgSwitch : Switch { | |||||
widget::FramebufferWidget *fb; | widget::FramebufferWidget *fb; | ||||
widget::SVGWidget *sw; | |||||
std::vector<std::shared_ptr<SVG>> frames; | |||||
widget::SvgWidget *sw; | |||||
std::vector<std::shared_ptr<Svg>> frames; | |||||
SVGSwitch(); | |||||
SvgSwitch(); | |||||
/** Adds an SVG file to represent the next switch position */ | /** Adds an SVG file to represent the next switch position */ | ||||
void addFrame(std::shared_ptr<SVG> svg); | |||||
void addFrame(std::shared_ptr<Svg> svg); | |||||
void onChange(const event::Change &e) override; | void onChange(const event::Change &e) override; | ||||
}; | }; | ||||
DEPRECATED typedef SvgSwitch SVGSwitch; | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -27,7 +27,7 @@ static const NVGcolor DARK_GRAY = nvgRGB(0x17, 0x17, 0x17); | |||||
// Knobs | // Knobs | ||||
//////////////////// | //////////////////// | ||||
struct RoundKnob : app::SVGKnob { | |||||
struct RoundKnob : app::SvgKnob { | |||||
RoundKnob() { | RoundKnob() { | ||||
minAngle = -0.83*M_PI; | minAngle = -0.83*M_PI; | ||||
maxAngle = 0.83*M_PI; | maxAngle = 0.83*M_PI; | ||||
@@ -36,25 +36,25 @@ struct RoundKnob : app::SVGKnob { | |||||
struct RoundBlackKnob : RoundKnob { | struct RoundBlackKnob : RoundKnob { | ||||
RoundBlackKnob() { | RoundBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundBlackKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundBlackKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct RoundSmallBlackKnob : RoundKnob { | struct RoundSmallBlackKnob : RoundKnob { | ||||
RoundSmallBlackKnob() { | RoundSmallBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct RoundLargeBlackKnob : RoundKnob { | struct RoundLargeBlackKnob : RoundKnob { | ||||
RoundLargeBlackKnob() { | RoundLargeBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct RoundHugeBlackKnob : RoundKnob { | struct RoundHugeBlackKnob : RoundKnob { | ||||
RoundHugeBlackKnob() { | RoundHugeBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -65,7 +65,7 @@ struct RoundBlackSnapKnob : RoundBlackKnob { | |||||
}; | }; | ||||
struct Davies1900hKnob : app::SVGKnob { | |||||
struct Davies1900hKnob : app::SvgKnob { | |||||
Davies1900hKnob() { | Davies1900hKnob() { | ||||
minAngle = -0.83*M_PI; | minAngle = -0.83*M_PI; | ||||
maxAngle = 0.83*M_PI; | maxAngle = 0.83*M_PI; | ||||
@@ -74,42 +74,42 @@ struct Davies1900hKnob : app::SVGKnob { | |||||
struct Davies1900hWhiteKnob : Davies1900hKnob { | struct Davies1900hWhiteKnob : Davies1900hKnob { | ||||
Davies1900hWhiteKnob() { | Davies1900hWhiteKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Davies1900hBlackKnob : Davies1900hKnob { | struct Davies1900hBlackKnob : Davies1900hKnob { | ||||
Davies1900hBlackKnob() { | Davies1900hBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hBlack.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hBlack.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Davies1900hRedKnob : Davies1900hKnob { | struct Davies1900hRedKnob : Davies1900hKnob { | ||||
Davies1900hRedKnob() { | Davies1900hRedKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Davies1900hLargeWhiteKnob : Davies1900hKnob { | struct Davies1900hLargeWhiteKnob : Davies1900hKnob { | ||||
Davies1900hLargeWhiteKnob() { | Davies1900hLargeWhiteKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Davies1900hLargeBlackKnob : Davies1900hKnob { | struct Davies1900hLargeBlackKnob : Davies1900hKnob { | ||||
Davies1900hLargeBlackKnob() { | Davies1900hLargeBlackKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Davies1900hLargeRedKnob : Davies1900hKnob { | struct Davies1900hLargeRedKnob : Davies1900hKnob { | ||||
Davies1900hLargeRedKnob() { | Davies1900hLargeRedKnob() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan : app::SVGKnob { | |||||
struct Rogan : app::SvgKnob { | |||||
Rogan() { | Rogan() { | ||||
minAngle = -0.83*M_PI; | minAngle = -0.83*M_PI; | ||||
maxAngle = 0.83*M_PI; | maxAngle = 0.83*M_PI; | ||||
@@ -118,191 +118,191 @@ struct Rogan : app::SVGKnob { | |||||
struct Rogan6PSWhite : Rogan { | struct Rogan6PSWhite : Rogan { | ||||
Rogan6PSWhite() { | Rogan6PSWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan5PSGray : Rogan { | struct Rogan5PSGray : Rogan { | ||||
Rogan5PSGray() { | Rogan5PSGray() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan5PSGray.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan5PSGray.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PSBlue : Rogan { | struct Rogan3PSBlue : Rogan { | ||||
Rogan3PSBlue() { | Rogan3PSBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PSRed : Rogan { | struct Rogan3PSRed : Rogan { | ||||
Rogan3PSRed() { | Rogan3PSRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PSGreen : Rogan { | struct Rogan3PSGreen : Rogan { | ||||
Rogan3PSGreen() { | Rogan3PSGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PSWhite : Rogan { | struct Rogan3PSWhite : Rogan { | ||||
Rogan3PSWhite() { | Rogan3PSWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PBlue : Rogan { | struct Rogan3PBlue : Rogan { | ||||
Rogan3PBlue() { | Rogan3PBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PRed : Rogan { | struct Rogan3PRed : Rogan { | ||||
Rogan3PRed() { | Rogan3PRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PGreen : Rogan { | struct Rogan3PGreen : Rogan { | ||||
Rogan3PGreen() { | Rogan3PGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan3PWhite : Rogan { | struct Rogan3PWhite : Rogan { | ||||
Rogan3PWhite() { | Rogan3PWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2SGray : Rogan { | struct Rogan2SGray : Rogan { | ||||
Rogan2SGray() { | Rogan2SGray() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2SGray.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2SGray.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PSBlue : Rogan { | struct Rogan2PSBlue : Rogan { | ||||
Rogan2PSBlue() { | Rogan2PSBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PSRed : Rogan { | struct Rogan2PSRed : Rogan { | ||||
Rogan2PSRed() { | Rogan2PSRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PSGreen : Rogan { | struct Rogan2PSGreen : Rogan { | ||||
Rogan2PSGreen() { | Rogan2PSGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PSWhite : Rogan { | struct Rogan2PSWhite : Rogan { | ||||
Rogan2PSWhite() { | Rogan2PSWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PBlue : Rogan { | struct Rogan2PBlue : Rogan { | ||||
Rogan2PBlue() { | Rogan2PBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PRed : Rogan { | struct Rogan2PRed : Rogan { | ||||
Rogan2PRed() { | Rogan2PRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PGreen : Rogan { | struct Rogan2PGreen : Rogan { | ||||
Rogan2PGreen() { | Rogan2PGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan2PWhite : Rogan { | struct Rogan2PWhite : Rogan { | ||||
Rogan2PWhite() { | Rogan2PWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PSBlue : Rogan { | struct Rogan1PSBlue : Rogan { | ||||
Rogan1PSBlue() { | Rogan1PSBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PSRed : Rogan { | struct Rogan1PSRed : Rogan { | ||||
Rogan1PSRed() { | Rogan1PSRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PSGreen : Rogan { | struct Rogan1PSGreen : Rogan { | ||||
Rogan1PSGreen() { | Rogan1PSGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PSWhite : Rogan { | struct Rogan1PSWhite : Rogan { | ||||
Rogan1PSWhite() { | Rogan1PSWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PBlue : Rogan { | struct Rogan1PBlue : Rogan { | ||||
Rogan1PBlue() { | Rogan1PBlue() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PBlue.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PBlue.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PRed : Rogan { | struct Rogan1PRed : Rogan { | ||||
Rogan1PRed() { | Rogan1PRed() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PRed.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PRed.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PGreen : Rogan { | struct Rogan1PGreen : Rogan { | ||||
Rogan1PGreen() { | Rogan1PGreen() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PGreen.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PGreen.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct Rogan1PWhite : Rogan { | struct Rogan1PWhite : Rogan { | ||||
Rogan1PWhite() { | Rogan1PWhite() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PWhite.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PWhite.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct SynthTechAlco : app::SVGKnob { | |||||
struct SynthTechAlco : app::SvgKnob { | |||||
SynthTechAlco() { | SynthTechAlco() { | ||||
minAngle = -0.82*M_PI; | minAngle = -0.82*M_PI; | ||||
maxAngle = 0.82*M_PI; | maxAngle = 0.82*M_PI; | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/SynthTechAlco.svg"))); | |||||
SVGWidget *cap = new SVGWidget; | |||||
cap->setSVG(SVG::load(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg"))); | |||||
SvgWidget *cap = new SvgWidget; | |||||
cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | |||||
addChild(cap); | addChild(cap); | ||||
} | } | ||||
}; | }; | ||||
struct Trimpot : app::SVGKnob { | |||||
struct Trimpot : app::SvgKnob { | |||||
Trimpot() { | Trimpot() { | ||||
minAngle = -0.75*M_PI; | minAngle = -0.75*M_PI; | ||||
maxAngle = 0.75*M_PI; | maxAngle = 0.75*M_PI; | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/Trimpot.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct BefacoBigKnob : app::SVGKnob { | |||||
struct BefacoBigKnob : app::SvgKnob { | |||||
BefacoBigKnob() { | BefacoBigKnob() { | ||||
minAngle = -0.75*M_PI; | minAngle = -0.75*M_PI; | ||||
maxAngle = 0.75*M_PI; | maxAngle = 0.75*M_PI; | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoBigKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -312,62 +312,62 @@ struct BefacoBigSnapKnob : BefacoBigKnob { | |||||
} | } | ||||
}; | }; | ||||
struct BefacoTinyKnob : app::SVGKnob { | |||||
struct BefacoTinyKnob : app::SvgKnob { | |||||
BefacoTinyKnob() { | BefacoTinyKnob() { | ||||
minAngle = -0.75*M_PI; | minAngle = -0.75*M_PI; | ||||
maxAngle = 0.75*M_PI; | maxAngle = 0.75*M_PI; | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct BefacoSlidePot : app::SVGSlider { | |||||
struct BefacoSlidePot : app::SvgSlider { | |||||
BefacoSlidePot() { | BefacoSlidePot() { | ||||
math::Vec margin = math::Vec(3.5, 3.5); | math::Vec margin = math::Vec(3.5, 3.5); | ||||
maxHandlePos = math::Vec(-1, -2).plus(margin); | maxHandlePos = math::Vec(-1, -2).plus(margin); | ||||
minHandlePos = math::Vec(-1, 87).plus(margin); | minHandlePos = math::Vec(-1, 87).plus(margin); | ||||
setBackgroundSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg"))); | |||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); | |||||
setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePot.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); | |||||
background->box.pos = margin; | background->box.pos = margin; | ||||
box.size = background->box.size.plus(margin.mult(2)); | box.size = background->box.size.plus(margin.mult(2)); | ||||
} | } | ||||
}; | }; | ||||
struct LEDSlider : app::SVGSlider { | |||||
struct LEDSlider : app::SvgSlider { | |||||
LEDSlider() { | LEDSlider() { | ||||
maxHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0))); | maxHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0))); | ||||
minHandlePos = mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0))); | minHandlePos = mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0))); | ||||
setBackgroundSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSlider.svg"))); | |||||
setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSlider.svg"))); | |||||
} | } | ||||
}; | }; | ||||
/** API is unstable for LEDSlider. Will add a LightWidget later. */ | /** API is unstable for LEDSlider. Will add a LightWidget later. */ | ||||
struct LEDSliderGreen : LEDSlider { | struct LEDSliderGreen : LEDSlider { | ||||
LEDSliderGreen() { | LEDSliderGreen() { | ||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDSliderRed : LEDSlider { | struct LEDSliderRed : LEDSlider { | ||||
LEDSliderRed() { | LEDSliderRed() { | ||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDSliderYellow : LEDSlider { | struct LEDSliderYellow : LEDSlider { | ||||
LEDSliderYellow() { | LEDSliderYellow() { | ||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDSliderBlue : LEDSlider { | struct LEDSliderBlue : LEDSlider { | ||||
LEDSliderBlue() { | LEDSliderBlue() { | ||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDSliderWhite : LEDSlider { | struct LEDSliderWhite : LEDSlider { | ||||
LEDSliderWhite() { | LEDSliderWhite() { | ||||
setHandleSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg"))); | |||||
setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -375,21 +375,21 @@ struct LEDSliderWhite : LEDSlider { | |||||
// Ports | // Ports | ||||
//////////////////// | //////////////////// | ||||
struct PJ301MPort : app::SVGPort { | |||||
struct PJ301MPort : app::SvgPort { | |||||
PJ301MPort() { | PJ301MPort() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ301M.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ301M.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct PJ3410Port : app::SVGPort { | |||||
struct PJ3410Port : app::SvgPort { | |||||
PJ3410Port() { | PJ3410Port() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ3410.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ3410.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct CL1362Port : app::SVGPort { | |||||
struct CL1362Port : app::SvgPort { | |||||
CL1362Port() { | CL1362Port() { | ||||
setSVG(SVG::load(asset::system("res/ComponentLibrary/CL1362.svg"))); | |||||
setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/CL1362.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -510,79 +510,79 @@ struct PB61303Light : BASE { | |||||
// Switches | // Switches | ||||
//////////////////// | //////////////////// | ||||
struct NKK : app::SVGSwitch { | |||||
struct NKK : app::SvgSwitch { | |||||
NKK() { | NKK() { | ||||
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"))); | |||||
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"))); | |||||
} | } | ||||
}; | }; | ||||
struct CKSS : app::SVGSwitch { | |||||
struct CKSS : app::SvgSwitch { | |||||
CKSS() { | CKSS() { | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_0.svg"))); | |||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_1.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_0.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_1.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct CKSSThree : app::SVGSwitch { | |||||
struct CKSSThree : app::SvgSwitch { | |||||
CKSSThree() { | CKSSThree() { | ||||
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"))); | |||||
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"))); | |||||
} | } | ||||
}; | }; | ||||
struct CKD6 : app::SVGSwitch { | |||||
struct CKD6 : app::SvgSwitch { | |||||
CKD6() { | CKD6() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_1.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_1.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct TL1105 : app::SVGSwitch { | |||||
struct TL1105 : app::SvgSwitch { | |||||
TL1105() { | TL1105() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_0.svg"))); | |||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_1.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_0.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_1.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDButton : app::SVGSwitch { | |||||
struct LEDButton : app::SvgSwitch { | |||||
LEDButton() { | LEDButton() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDButton.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDButton.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct BefacoSwitch : app::SVGSwitch { | |||||
struct BefacoSwitch : app::SvgSwitch { | |||||
BefacoSwitch() { | BefacoSwitch() { | ||||
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"))); | |||||
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"))); | |||||
} | } | ||||
}; | }; | ||||
struct BefacoPush : app::SVGSwitch { | |||||
struct BefacoPush : app::SvgSwitch { | |||||
BefacoPush() { | BefacoPush() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_0.svg"))); | |||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_1.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_0.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_1.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct LEDBezel : app::SVGSwitch { | |||||
struct LEDBezel : app::SvgSwitch { | |||||
LEDBezel() { | LEDBezel() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDBezel.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct PB61303 : app::SVGSwitch { | |||||
struct PB61303 : app::SvgSwitch { | |||||
PB61303() { | PB61303() { | ||||
momentary = true; | momentary = true; | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/PB61303.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -590,16 +590,16 @@ struct PB61303 : app::SVGSwitch { | |||||
// Misc | // Misc | ||||
//////////////////// | //////////////////// | ||||
struct ScrewSilver : app::SVGScrew { | |||||
struct ScrewSilver : app::SvgScrew { | |||||
ScrewSilver() { | ScrewSilver() { | ||||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewSilver.svg"))); | |||||
sw->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewSilver.svg"))); | |||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
} | } | ||||
}; | }; | ||||
struct ScrewBlack : app::SVGScrew { | |||||
struct ScrewBlack : app::SvgScrew { | |||||
ScrewBlack() { | ScrewBlack() { | ||||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewBlack.svg"))); | |||||
sw->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewBlack.svg"))); | |||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
} | } | ||||
}; | }; | ||||
@@ -6,7 +6,7 @@ namespace rack { | |||||
namespace dsp { | namespace dsp { | ||||
/** Deprecated. */ | |||||
/** Deprecated. Use VUMeter2. */ | |||||
struct VUMeter { | struct VUMeter { | ||||
/** Decibel level difference between adjacent meter lights */ | /** Decibel level difference between adjacent meter lights */ | ||||
float dBInterval = 3.0; | float dBInterval = 3.0; | ||||
@@ -15,7 +15,7 @@ struct VUMeter { | |||||
void setValue(float v) { | void setValue(float v) { | ||||
dBScaled = std::log10(std::abs(v)) * 20.0 / dBInterval; | dBScaled = std::log10(std::abs(v)) * 20.0 / dBInterval; | ||||
} | } | ||||
/** Returns the brightness of the light indexed by i | |||||
/** Returns the brightness of the light indexed by i. | |||||
Light 0 is a clip light (red) which is either on or off. | Light 0 is a clip light (red) which is either on or off. | ||||
All others are smooth lights which are fully bright at -dBInterval*i and higher, and fully off at -dBInterval*(i-1). | All others are smooth lights which are fully bright at -dBInterval*i and higher, and fully off at -dBInterval*(i-1). | ||||
*/ | */ | ||||
@@ -61,6 +61,7 @@ struct VUMeter2 { | |||||
} | } | ||||
/** Returns the LED brightness measuring tick marks between dbMin and dbMax. | /** Returns the LED brightness measuring tick marks between dbMin and dbMax. | ||||
For example, `getBrightness(-6.f, 0.f)` will be at minimum brightness at -6dB and maximum brightness at 0dB. | |||||
Set dbMin == dbMax == 0.f for a clip indicator. | Set dbMin == dbMax == 0.f for a clip indicator. | ||||
Expensive, so call this infrequently. | Expensive, so call this infrequently. | ||||
*/ | */ | ||||
@@ -17,9 +17,9 @@ | |||||
#include "widget/OpaqueWidget.hpp" | #include "widget/OpaqueWidget.hpp" | ||||
#include "widget/TransformWidget.hpp" | #include "widget/TransformWidget.hpp" | ||||
#include "widget/ZoomWidget.hpp" | #include "widget/ZoomWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/GLWidget.hpp" | |||||
#include "widget/OpenGlWidget.hpp" | |||||
#include "ui/SequentialLayout.hpp" | #include "ui/SequentialLayout.hpp" | ||||
#include "ui/Label.hpp" | #include "ui/Label.hpp" | ||||
@@ -56,13 +56,13 @@ | |||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "app/RackScrollWidget.hpp" | #include "app/RackScrollWidget.hpp" | ||||
#include "app/RackWidget.hpp" | #include "app/RackWidget.hpp" | ||||
#include "app/SVGButton.hpp" | |||||
#include "app/SVGKnob.hpp" | |||||
#include "app/SVGPanel.hpp" | |||||
#include "app/SVGPort.hpp" | |||||
#include "app/SVGScrew.hpp" | |||||
#include "app/SVGSlider.hpp" | |||||
#include "app/SVGSwitch.hpp" | |||||
#include "app/SvgButton.hpp" | |||||
#include "app/SvgKnob.hpp" | |||||
#include "app/SvgPanel.hpp" | |||||
#include "app/SvgPort.hpp" | |||||
#include "app/SvgScrew.hpp" | |||||
#include "app/SvgSlider.hpp" | |||||
#include "app/SvgSwitch.hpp" | |||||
#include "app/Toolbar.hpp" | #include "app/Toolbar.hpp" | ||||
#include "app/CableWidget.hpp" | #include "app/CableWidget.hpp" | ||||
@@ -1,6 +1,6 @@ | |||||
#pragma once | #pragma once | ||||
#include "widget/FramebufferWidget.hpp" | #include "widget/FramebufferWidget.hpp" | ||||
#include "widget/SVGWidget.hpp" | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "ui/common.hpp" | #include "ui/common.hpp" | ||||
#include "ui/Button.hpp" | #include "ui/Button.hpp" | ||||
@@ -11,10 +11,11 @@ namespace ui { | |||||
struct IconButton : Button { | struct IconButton : Button { | ||||
widget::FramebufferWidget *fw; | widget::FramebufferWidget *fw; | ||||
widget::SVGWidget *sw; | |||||
widget::SvgWidget *sw; | |||||
IconButton(); | IconButton(); | ||||
void setSVG(std::shared_ptr<SVG> svg); | |||||
void setSvg(std::shared_ptr<Svg> svg); | |||||
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
}; | }; | ||||
@@ -6,7 +6,7 @@ namespace rack { | |||||
namespace widget { | namespace widget { | ||||
struct GLWidget : FramebufferWidget { | |||||
struct OpenGlWidget : FramebufferWidget { | |||||
/** Draws every frame by default | /** Draws every frame by default | ||||
Override this to restore the default behavior of FramebufferWidget. | Override this to restore the default behavior of FramebufferWidget. | ||||
*/ | */ |
@@ -1,39 +0,0 @@ | |||||
#pragma once | |||||
#include "widget/Widget.hpp" | |||||
#include "svg.hpp" | |||||
namespace rack { | |||||
namespace widget { | |||||
/** Draws an SVG */ | |||||
struct SVGWidget : Widget { | |||||
std::shared_ptr<SVG> svg; | |||||
/** Sets the box size to the svg image size */ | |||||
void wrap() { | |||||
if (svg && svg->handle) { | |||||
box.size = math::Vec(svg->handle->width, svg->handle->height); | |||||
} | |||||
else { | |||||
box.size = math::Vec(); | |||||
} | |||||
} | |||||
/** Sets and wraps the SVG */ | |||||
void setSVG(std::shared_ptr<SVG> svg) { | |||||
this->svg = svg; | |||||
wrap(); | |||||
} | |||||
void draw(const DrawContext &ctx) override { | |||||
if (svg && svg->handle) { | |||||
svgDraw(ctx.vg, svg->handle); | |||||
} | |||||
} | |||||
}; | |||||
} // namespace widget | |||||
} // namespace rack |
@@ -0,0 +1,29 @@ | |||||
#pragma once | |||||
#include "widget/Widget.hpp" | |||||
#include "svg.hpp" | |||||
namespace rack { | |||||
namespace widget { | |||||
/** Draws an SVG */ | |||||
struct SvgWidget : Widget { | |||||
std::shared_ptr<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) {setSvg(svg);} | |||||
void draw(const DrawContext &ctx) override; | |||||
}; | |||||
DEPRECATED typedef SvgWidget SVGWidget; | |||||
} // namespace widget | |||||
} // namespace rack |
@@ -40,26 +40,34 @@ namespace rack { | |||||
// Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. | // Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. | ||||
struct Font { | struct Font { | ||||
NVGcontext *vg; | |||||
int handle; | int handle; | ||||
Font(const std::string &filename); | |||||
Font(NVGcontext *vg, const std::string &filename); | |||||
~Font(); | ~Font(); | ||||
static std::shared_ptr<Font> load(const std::string &filename); | |||||
/** Use `APP->window->loadFont()` instead. */ | |||||
DEPRECATED static std::shared_ptr<Font> load(const std::string &filename); | |||||
}; | }; | ||||
struct Image { | struct Image { | ||||
NVGcontext *vg; | |||||
int handle; | int handle; | ||||
Image(const std::string &filename); | |||||
Image(NVGcontext *vg, const std::string &filename); | |||||
~Image(); | ~Image(); | ||||
static std::shared_ptr<Image> load(const std::string &filename); | |||||
/** Use `APP->window->loadImage()` instead. */ | |||||
DEPRECATED static std::shared_ptr<Image> load(const std::string &filename); | |||||
}; | }; | ||||
struct SVG { | |||||
struct Svg { | |||||
NSVGimage *handle; | NSVGimage *handle; | ||||
SVG(const std::string &filename); | |||||
~SVG(); | |||||
static std::shared_ptr<SVG> load(const std::string &filename); | |||||
Svg(const std::string &filename); | |||||
~Svg(); | |||||
/** Use `APP->window->loadSvg()` instead. */ | |||||
DEPRECATED static std::shared_ptr<Svg> load(const std::string &filename); | |||||
}; | }; | ||||
DEPRECATED typedef Svg SVG; | |||||
struct Window { | struct Window { | ||||
GLFWwindow *win = NULL; | GLFWwindow *win = NULL; | ||||
NVGcontext *vg = NULL; | NVGcontext *vg = NULL; | ||||
@@ -91,6 +99,10 @@ struct Window { | |||||
int getMods(); | int getMods(); | ||||
void setFullScreen(bool fullScreen); | void setFullScreen(bool fullScreen); | ||||
bool isFullScreen(); | bool isFullScreen(); | ||||
std::shared_ptr<Font> loadFont(const std::string &filename); | |||||
std::shared_ptr<Image> loadImage(const std::string &filename); | |||||
std::shared_ptr<Svg> loadSvg(const std::string &filename); | |||||
}; | }; | ||||
@@ -236,7 +236,7 @@ struct AudioInterface : Module { | |||||
struct AudioInterfaceWidget : ModuleWidget { | struct AudioInterfaceWidget : ModuleWidget { | ||||
AudioInterfaceWidget(AudioInterface *module) { | AudioInterfaceWidget(AudioInterface *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/AudioInterface.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -112,7 +112,7 @@ struct CV_CC : Module { | |||||
struct CV_CCWidget : ModuleWidget { | struct CV_CCWidget : ModuleWidget { | ||||
CV_CCWidget(CV_CC *module) { | CV_CCWidget(CV_CC *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/CV-CC.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-CC.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -146,7 +146,7 @@ struct CV_Gate : Module { | |||||
struct CV_GateWidget : ModuleWidget { | struct CV_GateWidget : ModuleWidget { | ||||
CV_GateWidget(CV_Gate *module) { | CV_GateWidget(CV_Gate *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/CV-Gate.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-Gate.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -316,7 +316,7 @@ struct CV_MIDI : Module { | |||||
struct CV_MIDIWidget : ModuleWidget { | struct CV_MIDIWidget : ModuleWidget { | ||||
CV_MIDIWidget(CV_MIDI *module) { | CV_MIDIWidget(CV_MIDI *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/CV-MIDI.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/CV-MIDI.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -137,7 +137,7 @@ struct MIDI_CC : Module { | |||||
struct MIDI_CCWidget : ModuleWidget { | struct MIDI_CCWidget : ModuleWidget { | ||||
MIDI_CCWidget(MIDI_CC *module) { | MIDI_CCWidget(MIDI_CC *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/MIDI-CC.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CC.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -260,7 +260,7 @@ struct MIDI_CV : Module { | |||||
struct MIDI_CVWidget : ModuleWidget { | struct MIDI_CVWidget : ModuleWidget { | ||||
MIDI_CVWidget(MIDI_CV *module) { | MIDI_CVWidget(MIDI_CV *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/MIDI-CV.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CV.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -147,7 +147,7 @@ struct MIDI_Gate : Module { | |||||
struct MIDI_GateWidget : ModuleWidget { | struct MIDI_GateWidget : ModuleWidget { | ||||
MIDI_GateWidget(MIDI_Gate *module) { | MIDI_GateWidget(MIDI_Gate *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/MIDI-Gate.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Gate.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -46,13 +46,13 @@ struct MIDI_Map : Module { | |||||
}; | }; | ||||
struct CKD6Button : SVGButton { | |||||
struct CKD6Button : SvgButton { | |||||
MIDI_Map *module; | MIDI_Map *module; | ||||
int id; | int id; | ||||
CKD6Button() { | CKD6Button() { | ||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_1.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_1.svg"))); | |||||
} | } | ||||
void onAction(const event::Action &e) override { | void onAction(const event::Action &e) override { | ||||
@@ -73,7 +73,7 @@ TWidget *createMapButtonCentered(math::Vec pos, MIDI_Map *module, int id) { | |||||
struct MIDI_MapWidget : ModuleWidget { | struct MIDI_MapWidget : ModuleWidget { | ||||
MIDI_MapWidget(MIDI_Map *module) { | MIDI_MapWidget(MIDI_Map *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/MIDI-Map.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Map.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -9,7 +9,7 @@ struct NotesWidget : ModuleWidget { | |||||
NotesWidget(Module *module) { | NotesWidget(Module *module) { | ||||
setModule(module); | setModule(module); | ||||
setPanel(SVG::load(asset::system("res/Core/Notes.svg"))); | |||||
setPanel(APP->window->loadSvg(asset::system("res/Core/Notes.svg"))); | |||||
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||||
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); | ||||
@@ -35,7 +35,7 @@ void LedDisplaySeparator::draw(const widget::DrawContext &ctx) { | |||||
LedDisplayChoice::LedDisplayChoice() { | LedDisplayChoice::LedDisplayChoice() { | ||||
box.size = mm2px(math::Vec(0, 28.0 / 3)); | box.size = mm2px(math::Vec(0, 28.0 / 3)); | ||||
font = Font::load(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||||
font = APP->window->loadFont(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||||
color = nvgRGB(0xff, 0xd7, 0x14); | color = nvgRGB(0xff, 0xd7, 0x14); | ||||
textOffset = math::Vec(10, 18); | textOffset = math::Vec(10, 18); | ||||
} | } | ||||
@@ -65,7 +65,7 @@ void LedDisplayChoice::onButton(const event::Button &e) { | |||||
LedDisplayTextField::LedDisplayTextField() { | LedDisplayTextField::LedDisplayTextField() { | ||||
font = Font::load(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||||
font = APP->window->loadFont(asset::system("res/fonts/ShareTechMono-Regular.ttf")); | |||||
color = nvgRGB(0xff, 0xd7, 0x14); | color = nvgRGB(0xff, 0xd7, 0x14); | ||||
textOffset = math::Vec(5, 5); | textOffset = math::Vec(5, 5); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ | |||||
#include "system.hpp" | #include "system.hpp" | ||||
#include "asset.hpp" | #include "asset.hpp" | ||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "app/SVGPanel.hpp" | |||||
#include "app/SvgPanel.hpp" | |||||
#include "helpers.hpp" | #include "helpers.hpp" | ||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "settings.hpp" | #include "settings.hpp" | ||||
@@ -299,7 +299,7 @@ void ModuleWidget::setModule(engine::Module *module) { | |||||
this->module = module; | this->module = module; | ||||
} | } | ||||
void ModuleWidget::setPanel(std::shared_ptr<SVG> svg) { | |||||
void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) { | |||||
// Remove old panel | // Remove old panel | ||||
if (panel) { | if (panel) { | ||||
removeChild(panel); | removeChild(panel); | ||||
@@ -308,7 +308,7 @@ void ModuleWidget::setPanel(std::shared_ptr<SVG> svg) { | |||||
} | } | ||||
{ | { | ||||
SVGPanel *panel = new SVGPanel; | |||||
SvgPanel *panel = new SvgPanel; | |||||
panel->setBackground(svg); | panel->setBackground(svg); | ||||
addChild(panel); | addChild(panel); | ||||
box.size = panel->box.size; | box.size = panel->box.size; | ||||
@@ -1,44 +1,44 @@ | |||||
#include "app/SVGButton.hpp" | |||||
#include "app/SvgButton.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGButton::SVGButton() { | |||||
SvgButton::SvgButton() { | |||||
fb = new widget::FramebufferWidget; | fb = new widget::FramebufferWidget; | ||||
addChild(fb); | addChild(fb); | ||||
sw = new widget::SVGWidget; | |||||
sw = new widget::SvgWidget; | |||||
fb->addChild(sw); | fb->addChild(sw); | ||||
} | } | ||||
void SVGButton::addFrame(std::shared_ptr<SVG> svg) { | |||||
void SvgButton::addFrame(std::shared_ptr<Svg> svg) { | |||||
frames.push_back(svg); | frames.push_back(svg); | ||||
// If this is our first frame, automatically set SVG and size | // If this is our first frame, automatically set SVG and size | ||||
if (!sw->svg) { | if (!sw->svg) { | ||||
sw->setSVG(svg); | |||||
sw->setSvg(svg); | |||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
fb->box.size = sw->box.size; | fb->box.size = sw->box.size; | ||||
} | } | ||||
} | } | ||||
void SVGButton::onDragStart(const event::DragStart &e) { | |||||
void SvgButton::onDragStart(const event::DragStart &e) { | |||||
if (frames.size() >= 2) { | if (frames.size() >= 2) { | ||||
sw->setSVG(frames[1]); | |||||
sw->setSvg(frames[1]); | |||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void SVGButton::onDragEnd(const event::DragEnd &e) { | |||||
void SvgButton::onDragEnd(const event::DragEnd &e) { | |||||
if (frames.size() >= 1) { | if (frames.size() >= 1) { | ||||
sw->setSVG(frames[0]); | |||||
sw->setSvg(frames[0]); | |||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
} | } | ||||
void SVGButton::onDragDrop(const event::DragDrop &e) { | |||||
void SvgButton::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
event::Action eAction; | event::Action eAction; | ||||
onAction(eAction); | onAction(eAction); |
@@ -1,11 +1,11 @@ | |||||
#include "app/SVGKnob.hpp" | |||||
#include "app/SvgKnob.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGKnob::SVGKnob() { | |||||
SvgKnob::SvgKnob() { | |||||
fb = new widget::FramebufferWidget; | fb = new widget::FramebufferWidget; | ||||
addChild(fb); | addChild(fb); | ||||
@@ -16,12 +16,12 @@ SVGKnob::SVGKnob() { | |||||
tw = new widget::TransformWidget; | tw = new widget::TransformWidget; | ||||
fb->addChild(tw); | fb->addChild(tw); | ||||
sw = new widget::SVGWidget; | |||||
sw = new widget::SvgWidget; | |||||
tw->addChild(sw); | tw->addChild(sw); | ||||
} | } | ||||
void SVGKnob::setSVG(std::shared_ptr<SVG> svg) { | |||||
sw->setSVG(svg); | |||||
void SvgKnob::setSvg(std::shared_ptr<Svg> svg) { | |||||
sw->setSvg(svg); | |||||
tw->box.size = sw->box.size; | tw->box.size = sw->box.size; | ||||
fb->box.size = sw->box.size; | fb->box.size = sw->box.size; | ||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
@@ -31,7 +31,7 @@ void SVGKnob::setSVG(std::shared_ptr<SVG> svg) { | |||||
// shadow->box = shadow->box.grow(math::Vec(2, 2)); | // shadow->box = shadow->box.grow(math::Vec(2, 2)); | ||||
} | } | ||||
void SVGKnob::onChange(const event::Change &e) { | |||||
void SvgKnob::onChange(const event::Change &e) { | |||||
// Re-transform the widget::TransformWidget | // Re-transform the widget::TransformWidget | ||||
if (paramQuantity) { | if (paramQuantity) { | ||||
float angle; | float angle; |
@@ -1,4 +1,4 @@ | |||||
#include "app/SVGPanel.hpp" | |||||
#include "app/SvgPanel.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -15,7 +15,7 @@ void PanelBorder::draw(const widget::DrawContext &ctx) { | |||||
} | } | ||||
void SVGPanel::step() { | |||||
void SvgPanel::step() { | |||||
if (math::isNear(APP->window->pixelRatio, 1.0)) { | if (math::isNear(APP->window->pixelRatio, 1.0)) { | ||||
// Small details draw poorly at low DPI, so oversample when drawing to the framebuffer | // Small details draw poorly at low DPI, so oversample when drawing to the framebuffer | ||||
oversample = 2.0; | oversample = 2.0; | ||||
@@ -23,9 +23,9 @@ void SVGPanel::step() { | |||||
widget::FramebufferWidget::step(); | widget::FramebufferWidget::step(); | ||||
} | } | ||||
void SVGPanel::setBackground(std::shared_ptr<SVG> svg) { | |||||
widget::SVGWidget *sw = new widget::SVGWidget; | |||||
sw->setSVG(svg); | |||||
void SvgPanel::setBackground(std::shared_ptr<Svg> svg) { | |||||
widget::SvgWidget *sw = new widget::SvgWidget; | |||||
sw->setSvg(svg); | |||||
addChild(sw); | addChild(sw); | ||||
// Set size | // Set size |
@@ -1,26 +1,26 @@ | |||||
#include "app/SVGPort.hpp" | |||||
#include "app/SvgPort.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGPort::SVGPort() { | |||||
SvgPort::SvgPort() { | |||||
fb = new widget::FramebufferWidget; | fb = new widget::FramebufferWidget; | ||||
addChild(fb); | addChild(fb); | ||||
shadow = new CircularShadow; | shadow = new CircularShadow; | ||||
fb->addChild(shadow); | fb->addChild(shadow); | ||||
// Avoid breakage if plugins fail to call setSVG() | |||||
// Avoid breakage if plugins fail to call setSvg() | |||||
// In that case, just disable the shadow. | // In that case, just disable the shadow. | ||||
shadow->box.size = math::Vec(); | shadow->box.size = math::Vec(); | ||||
sw = new widget::SVGWidget; | |||||
sw = new widget::SvgWidget; | |||||
fb->addChild(sw); | fb->addChild(sw); | ||||
} | } | ||||
void SVGPort::setSVG(std::shared_ptr<SVG> svg) { | |||||
sw->setSVG(svg); | |||||
void SvgPort::setSvg(std::shared_ptr<Svg> svg) { | |||||
sw->setSvg(svg); | |||||
fb->box.size = sw->box.size; | fb->box.size = sw->box.size; | ||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
shadow->box.size = sw->box.size; | shadow->box.size = sw->box.size; |
@@ -1,12 +1,12 @@ | |||||
#include "app/SVGScrew.hpp" | |||||
#include "app/SvgScrew.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGScrew::SVGScrew() { | |||||
sw = new widget::SVGWidget; | |||||
SvgScrew::SvgScrew() { | |||||
sw = new widget::SvgWidget; | |||||
addChild(sw); | addChild(sw); | ||||
} | } | ||||
@@ -1,36 +1,36 @@ | |||||
#include "app/SVGSlider.hpp" | |||||
#include "app/SvgSlider.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGSlider::SVGSlider() { | |||||
SvgSlider::SvgSlider() { | |||||
fb = new widget::FramebufferWidget; | fb = new widget::FramebufferWidget; | ||||
addChild(fb); | addChild(fb); | ||||
background = new widget::SVGWidget; | |||||
background = new widget::SvgWidget; | |||||
fb->addChild(background); | fb->addChild(background); | ||||
handle = new widget::SVGWidget; | |||||
handle = new widget::SvgWidget; | |||||
fb->addChild(handle); | fb->addChild(handle); | ||||
speed = 2.0; | speed = 2.0; | ||||
} | } | ||||
void SVGSlider::setBackgroundSVG(std::shared_ptr<SVG> backgroundSVG) { | |||||
background->setSVG(backgroundSVG); | |||||
void SvgSlider::setBackgroundSvg(std::shared_ptr<Svg> svg) { | |||||
background->setSvg(svg); | |||||
fb->box.size = background->box.size; | fb->box.size = background->box.size; | ||||
box.size = background->box.size; | box.size = background->box.size; | ||||
} | } | ||||
void SVGSlider::setHandleSVG(std::shared_ptr<SVG> handleSVG) { | |||||
handle->setSVG(handleSVG); | |||||
void SvgSlider::setHandleSvg(std::shared_ptr<Svg> svg) { | |||||
handle->setSvg(svg); | |||||
handle->box.pos = maxHandlePos; | handle->box.pos = maxHandlePos; | ||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
void SVGSlider::onChange(const event::Change &e) { | |||||
void SvgSlider::onChange(const event::Change &e) { | |||||
if (paramQuantity) { | if (paramQuantity) { | ||||
// Interpolate handle position | // Interpolate handle position | ||||
float v = paramQuantity->getScaledValue(); | float v = paramQuantity->getScaledValue(); |
@@ -1,33 +1,33 @@ | |||||
#include "app/SVGSwitch.hpp" | |||||
#include "app/SvgSwitch.hpp" | |||||
namespace rack { | namespace rack { | ||||
namespace app { | namespace app { | ||||
SVGSwitch::SVGSwitch() { | |||||
SvgSwitch::SvgSwitch() { | |||||
fb = new widget::FramebufferWidget; | fb = new widget::FramebufferWidget; | ||||
addChild(fb); | addChild(fb); | ||||
sw = new widget::SVGWidget; | |||||
sw = new widget::SvgWidget; | |||||
fb->addChild(sw); | fb->addChild(sw); | ||||
} | } | ||||
void SVGSwitch::addFrame(std::shared_ptr<SVG> svg) { | |||||
void SvgSwitch::addFrame(std::shared_ptr<Svg> svg) { | |||||
frames.push_back(svg); | frames.push_back(svg); | ||||
// If this is our first frame, automatically set SVG and size | // If this is our first frame, automatically set SVG and size | ||||
if (!sw->svg) { | if (!sw->svg) { | ||||
sw->setSVG(svg); | |||||
sw->setSvg(svg); | |||||
box.size = sw->box.size; | box.size = sw->box.size; | ||||
fb->box.size = sw->box.size; | fb->box.size = sw->box.size; | ||||
} | } | ||||
} | } | ||||
void SVGSwitch::onChange(const event::Change &e) { | |||||
void SvgSwitch::onChange(const event::Change &e) { | |||||
if (!frames.empty() && paramQuantity) { | if (!frames.empty() && paramQuantity) { | ||||
int index = (int) std::round(paramQuantity->getValue()); | int index = (int) std::round(paramQuantity->getValue()); | ||||
index = math::clamp(index, 0, (int) frames.size() - 1); | index = math::clamp(index, 0, (int) frames.size() - 1); | ||||
sw->setSVG(frames[index]); | |||||
sw->setSvg(frames[index]); | |||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
ParamWidget::onChange(e); | ParamWidget::onChange(e); |
@@ -12,13 +12,13 @@ IconButton::IconButton() { | |||||
fw->oversample = 2; | fw->oversample = 2; | ||||
addChild(fw); | addChild(fw); | ||||
sw = new widget::SVGWidget; | |||||
sw = new widget::SvgWidget; | |||||
sw->box.pos = math::Vec(2, 2); | sw->box.pos = math::Vec(2, 2); | ||||
fw->addChild(sw); | fw->addChild(sw); | ||||
} | } | ||||
void IconButton::setSVG(std::shared_ptr<SVG> svg) { | |||||
sw->setSVG(svg); | |||||
void IconButton::setSvg(std::shared_ptr<Svg> svg) { | |||||
sw->setSvg(svg); | |||||
fw->dirty = true; | fw->dirty = true; | ||||
} | } | ||||
@@ -1,4 +1,4 @@ | |||||
#include "widget/GLWidget.hpp" | |||||
#include "widget/OpenGlWidget.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
@@ -6,13 +6,13 @@ namespace rack { | |||||
namespace widget { | namespace widget { | ||||
void GLWidget::step() { | |||||
void OpenGlWidget::step() { | |||||
// Render every frame | // Render every frame | ||||
dirty = true; | dirty = true; | ||||
} | } | ||||
void GLWidget::drawFramebuffer() { | |||||
void OpenGlWidget::drawFramebuffer() { | |||||
glViewport(0.0, 0.0, fbSize.x, fbSize.y); | glViewport(0.0, 0.0, fbSize.x, fbSize.y); | ||||
glClearColor(0.0, 0.0, 0.0, 1.0); | glClearColor(0.0, 0.0, 0.0, 1.0); | ||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
@@ -0,0 +1,31 @@ | |||||
#include "widget/SvgWidget.hpp" | |||||
#include "app.hpp" | |||||
namespace rack { | |||||
namespace widget { | |||||
void SvgWidget::wrap() { | |||||
if (svg && svg->handle) { | |||||
box.size = math::Vec(svg->handle->width, svg->handle->height); | |||||
} | |||||
else { | |||||
box.size = math::Vec(); | |||||
} | |||||
} | |||||
void SvgWidget::setSvg(std::shared_ptr<Svg> svg) { | |||||
this->svg = svg; | |||||
wrap(); | |||||
} | |||||
void SvgWidget::draw(const DrawContext &ctx) { | |||||
if (svg && svg->handle) { | |||||
svgDraw(ctx.vg, svg->handle); | |||||
} | |||||
} | |||||
} // namespace widget | |||||
} // namespace rack |
@@ -23,13 +23,8 @@ | |||||
namespace rack { | namespace rack { | ||||
static std::map<std::string, std::weak_ptr<Font>> fontCache; | |||||
static std::map<std::string, std::weak_ptr<Image>> imageCache; | |||||
static std::map<std::string, std::weak_ptr<SVG>> svgCache; | |||||
Font::Font(const std::string &filename) { | |||||
handle = nvgCreateFont(APP->window->vg, filename.c_str(), filename.c_str()); | |||||
Font::Font(NVGcontext *vg, const std::string &filename) { | |||||
handle = nvgCreateFont(vg, filename.c_str(), filename.c_str()); | |||||
if (handle >= 0) { | if (handle >= 0) { | ||||
INFO("Loaded font %s", filename.c_str()); | INFO("Loaded font %s", filename.c_str()); | ||||
} | } | ||||
@@ -43,14 +38,11 @@ Font::~Font() { | |||||
} | } | ||||
std::shared_ptr<Font> Font::load(const std::string &filename) { | std::shared_ptr<Font> Font::load(const std::string &filename) { | ||||
auto sp = fontCache[filename].lock(); | |||||
if (!sp) | |||||
fontCache[filename] = sp = std::make_shared<Font>(filename); | |||||
return sp; | |||||
return APP->window->loadFont(filename); | |||||
} | } | ||||
Image::Image(const std::string &filename) { | |||||
handle = nvgCreateImage(APP->window->vg, filename.c_str(), NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); | |||||
Image::Image(NVGcontext *vg, const std::string &filename) { | |||||
handle = nvgCreateImage(vg, filename.c_str(), NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); | |||||
if (handle > 0) { | if (handle > 0) { | ||||
INFO("Loaded image %s", filename.c_str()); | INFO("Loaded image %s", filename.c_str()); | ||||
} | } | ||||
@@ -61,17 +53,14 @@ Image::Image(const std::string &filename) { | |||||
Image::~Image() { | Image::~Image() { | ||||
// TODO What if handle is invalid? | // TODO What if handle is invalid? | ||||
nvgDeleteImage(APP->window->vg, handle); | |||||
nvgDeleteImage(vg, handle); | |||||
} | } | ||||
std::shared_ptr<Image> Image::load(const std::string &filename) { | std::shared_ptr<Image> Image::load(const std::string &filename) { | ||||
auto sp = imageCache[filename].lock(); | |||||
if (!sp) | |||||
imageCache[filename] = sp = std::make_shared<Image>(filename); | |||||
return sp; | |||||
return APP->window->loadImage(filename); | |||||
} | } | ||||
SVG::SVG(const std::string &filename) { | |||||
Svg::Svg(const std::string &filename) { | |||||
handle = nsvgParseFromFile(filename.c_str(), "px", app::SVG_DPI); | handle = nsvgParseFromFile(filename.c_str(), "px", app::SVG_DPI); | ||||
if (handle) { | if (handle) { | ||||
INFO("Loaded SVG %s", filename.c_str()); | INFO("Loaded SVG %s", filename.c_str()); | ||||
@@ -81,15 +70,12 @@ SVG::SVG(const std::string &filename) { | |||||
} | } | ||||
} | } | ||||
SVG::~SVG() { | |||||
Svg::~Svg() { | |||||
nsvgDelete(handle); | nsvgDelete(handle); | ||||
} | } | ||||
std::shared_ptr<SVG> SVG::load(const std::string &filename) { | |||||
auto sp = svgCache[filename].lock(); | |||||
if (!sp) | |||||
svgCache[filename] = sp = std::make_shared<SVG>(filename); | |||||
return sp; | |||||
std::shared_ptr<Svg> Svg::load(const std::string &filename) { | |||||
return APP->window->loadSvg(filename); | |||||
} | } | ||||
@@ -100,6 +86,10 @@ struct Window::Internal { | |||||
int lastWindowY = 0; | int lastWindowY = 0; | ||||
int lastWindowWidth = 0; | int lastWindowWidth = 0; | ||||
int lastWindowHeight = 0; | int lastWindowHeight = 0; | ||||
std::map<std::string, std::weak_ptr<Font>> fontCache; | |||||
std::map<std::string, std::weak_ptr<Image>> imageCache; | |||||
std::map<std::string, std::weak_ptr<Svg>> svgCache; | |||||
}; | }; | ||||
@@ -316,7 +306,7 @@ Window::~Window() { | |||||
} | } | ||||
void Window::run() { | void Window::run() { | ||||
uiFont = Font::load(asset::system("res/fonts/DejaVuSans.ttf")); | |||||
uiFont = APP->window->loadFont(asset::system("res/fonts/DejaVuSans.ttf")); | |||||
frame = 0; | frame = 0; | ||||
while(!glfwWindowShouldClose(win)) { | while(!glfwWindowShouldClose(win)) { | ||||
@@ -460,6 +450,29 @@ bool Window::isFullScreen() { | |||||
return monitor != NULL; | return monitor != NULL; | ||||
} | } | ||||
std::shared_ptr<Font> Window::loadFont(const std::string &filename) { | |||||
auto sp = internal->fontCache[filename].lock(); | |||||
if (!sp) | |||||
internal->fontCache[filename] = sp = std::make_shared<Font>(vg, filename); | |||||
return sp; | |||||
} | |||||
std::shared_ptr<Image> Window::loadImage(const std::string &filename) { | |||||
auto sp = internal->imageCache[filename].lock(); | |||||
if (!sp) | |||||
internal->imageCache[filename] = sp = std::make_shared<Image>(vg, filename); | |||||
return sp; | |||||
} | |||||
std::shared_ptr<Svg> Window::loadSvg(const std::string &filename) { | |||||
auto sp = internal->svgCache[filename].lock(); | |||||
if (!sp) | |||||
internal->svgCache[filename] = sp = std::make_shared<Svg>(filename); | |||||
return sp; | |||||
} | |||||
void windowInit() { | void windowInit() { | ||||
int err; | int err; | ||||