Passing parameters to custom light using VCVLightBezel

I’m having some issues trying to pass a pointer to my module into my custom light class. When I learned C++, there wasn’t the concept of SomeClass<SomeOtherClass>, which is throwing me off. Here’s what my code looks like:

VCVLightBezel<GrooveboxBlueLight> *groovebox_light = createLightParamCentered<VCVLightBezel<GrooveboxBlueLight>>(Vec(button_positions[i][0],button_positions[i][1]), module, GrooveBox::DRUM_PADS + i, GrooveBox::DRUM_PAD_LIGHTS + i);
groovebox_light->groove_box_module = module;
addParam(groovebox_light);

However, the code above is attempting to set the groove_box_module variable in VCVLightBezel, when I actually want to set it in GrooveboxBlueLight, so it throws an error:

In file included from src/GrooveBox.cpp:31: src/GrooveBox/GrooveBoxWidget.hpp: In constructor ‘GrooveBoxWidget::GrooveBoxWidget(GrooveBox*)’: src/GrooveBox/GrooveBoxWidget.hpp:704:24: error: ‘struct rack::componentlibrary::VCVLightBezel’ has no member named ‘groove_box_module’ 704 | groovebox_light->groove_box_module = module;

What’s a graceful way of padding the module * to GrooveboxBlueLight? Second question: What is this technique called SomeClass<SomeOtherClass> so that I can learn more about it? Thanks!!

Bret, I think you have to look at the concept of class templates, although I would expect you have run into those earlier.

I think that I found my solution. I used VCVLightBezel::getLight() and cast the resulting 'rack::app::ModuleLightWidget* to my stuct type, and that seemed to work.

VCVLightBezel<GrooveboxBlueLight> *groovebox_blue_light_bezel = createLightParamCentered<VCVLightBezel<GrooveboxBlueLight>>(Vec(button_positions[i][0],button_positions[i][1]), module, GrooveBox::DRUM_PADS + i, GrooveBox::DRUM_PAD_LIGHTS + i);
GrooveboxBlueLight *groove_box_blue_light = dynamic_cast<GrooveboxBlueLight*>(groovebox_blue_light_bezel->getLight());
groove_box_blue_light->module = module;
addParam(groovebox_blue_light_bezel);

I think we’ve all entered code like this, right? addInput(createInput<PJ301MPort>(...)

1 Like