The Rhythm Explorer module in my soon to be released Venom plugin has square SvgSwitch widgets (buttons) that I want to glow in the dark. Each frame has a grey background with black text.
I had all but given up hope solving this, but then I saw How to use custom lights - #16 by Ahornberg. That was enough for me to get the following solution.
struct ModeSwitch : app::SvgSwitch {
ModeSwitch() {
shadow->opacity = 0.0;
addFrame(Svg::load(asset::plugin(pluginInstance,"res/mode_0.svg")));
addFrame(Svg::load(asset::plugin(pluginInstance,"res/mode_1.svg")));
addFrame(Svg::load(asset::plugin(pluginInstance,"res/mode_2.svg")));
addFrame(Svg::load(asset::plugin(pluginInstance,"res/mode_3.svg")));
}
void drawLayer(const DrawArgs& args, int layer) override {
if (layer==1) {
if (module && !module->isBypassed()) {
std::shared_ptr<window::Svg> svg = frames[static_cast<int>(getParamQuantity()->getValue())];
if (svg)
window::svgDraw(args.vg, svg->handle);
}
}
}
};
It seems to be working perfectly. But Iâd like some experts to point out if I got anything wrong or incomplete.
Also, I tried to do some defensive programming, checking to make sure the svg was loaded before trying to access the handle. If I didnât do this, then I assume my plugin could crash VCV if the svg file was missing or inaccessible for some reason - correct?