Setting browser lights and svg switch image in browser

I’m sure I have seen something posted on this, but I cannot for the life of me find it.

My plugin has svg switches that always show up as the index 0 image in the browser, but I would like other values. The module configures the switches to other default values, but I suppose that code is not called because there is no module in the browser.

Also, I have some lights and segmented displays. Mysteriously, sometimes they are lit and or show numbers in the browser, and sometimes they are blank. That makes no sense, and leads me to believe perhaps the browser is perhaps accessing some uninitialized values? Anyway, how do I control how the lights appear in the browser.

Some links to example code would be great

just put in special code is the widget drawing code for when there is no module. You can see that in my Seq++ and Comp II modules. They have “stuff” in the browser, but it’s just for show.

Oh, sorry, I mis-read. The built in widgets - I don’t know if you can control what they look like when they are not backed by a real param (from a real module). Maybe you can override their draw behavior? But I don’t think I’ve every seen a VCV thing do that.

While certainly not succinct nor easy to read. My PurrSoftware Meander code overrides draw() extensively to get things to work the way I want them to in the browser and yet not crash when there is no module.

Meander does not use SVGs but rather PNGs to render the panel in the browser.

In the module, Meander uses all NVG for panel graphics.

Yeah - thanks. Definitely more than I can parse at this point.

I think I have the basic framework in mind as to what to do, but I struggle with how to manipulate each component widget within the module widget constructor - the specifics of each type.

I managed to properly set the correct active svg from the svg switch frames, which was my highest priority. But my attempts to set light brightness and set a knob value both managed to crash the browser. I think I will leave things as they are for now, and maybe revisit later.

1 Like

I really don’t know if I understand you correct,
but I see that Bogaudio has changing GUI colors (themes)
that show up in the browser,
maybe a look there ( the Bogaudio github site ) can help you?

I’m not sure this is relevant, but you might check out:

In my ModuleWidget step() override, I do some graphics things even if the module is null. This is mostly for my panel colors and PNG panel image rendering.

Yes, that is the same as my original answer. We all do that. The problem for @DaveVenom is that he is using an SvgSwitch widget. He wants to utilize the drawing code that is already there, but wants to substitute a different value. It’s all in what the ParamWidget does when there is no module, and the behavior is not what he wants.

There may be a way to do it by overriding something like SvgSwitch::onChange(), but I don’t know. The “obvious” way to do it is add some functionality all the way up in ParamWidget, but that would involve forking the entire hierarchy.

Sorry, I missed your reference to “step()”. :wink:

I actually solved the SvgSwitch issue.

Here is my original code where each instance defaults to the 0 index svg image - not what I want. (ellipses indicate missing irrelevant code)

struct RhythmExplorerWidget : ModuleWidget {
  struct DivSwitch : app::SvgSwitch {
    DivSwitch() {
      shadow->opacity = 0.0;
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_0.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_1.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_2.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_3.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_4.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_5.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_6.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_7.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_8.svg")));
      addFrame(Svg::load(asset::plugin(pluginInstance,"res/rate_9.svg")));
    }
  };
  ...
  RhythmExplorerWidget(RhythmExplorer* module) {
    ...
    for(int si = 0; si < SLIDER_COUNT; si++, x+=dx){
      ...
      addParam(createParamCentered<DivSwitch>(Vec(x,y), module, RhythmExplorer::RATE_PARAM + si));
      ...
    }
  }
  ...
}

And here is my simple fix, just showing the changed for loop:

    for(int si = 0; si < SLIDER_COUNT; si++, x+=dx){
      ...
      DivSwitch* divSwitch = createParamCentered<DivSwitch>(Vec(x,y), module, RhythmExplorer::RATE_PARAM + si);
      if (!module) {
        divSwitch->sw->svg = divSwitch->frames[si+1];
      }
      addParam(divSwitch);
      ...
    }

I tried something similar with lights and knob parameters - manipulating the new widget before adding. But my efforts failed with a crashing browser. Not critical to solve because the SvgSwitch was my primary concern anyway.

1 Like

actually, I think you are correct, we are talking about slightly different things. Either could almost work, except that ParamWidget::getParamQuantity() is not virtual. If it were you could override it do to your bidding…

Anyway, yeah, your trick of overriding step is not something I have not done to modify the visual rendition.