@@ -266,11 +266,11 @@ void ::StoneyDSP::StoneyVCV::VCA::VCAModule::process(const ::StoneyDSP::StoneyVC
266266 if (this ->lightDivider .process ()) {
267267 auto lightValue = *::std::max_element<float *>(this ->lightGains .begin (), this ->lightGains .end ());
268268 blink_light.setBrightnessSmooth (
269- 1 .0F - (lightValue * lightValue),
269+ 1 .0F - lightValue, // (lightValue * lightValue),
270270 this ->lightDivider .getDivision () * args.sampleTime
271271 );
272272 blink_light_r.setBrightnessSmooth (
273- (lightValue * lightValue),
273+ lightValue, // (lightValue * lightValue),
274274 this ->lightDivider .getDivision () * args.sampleTime
275275 );
276276 // blink_light.setBrightnessSmooth(
@@ -343,89 +343,75 @@ ::rack::engine::Light &::StoneyDSP::StoneyVCV::VCA::VCAModule::getBlinkLight() n
343343
344344// ==============================================================================
345345
346- ::StoneyDSP::StoneyVCV::VCA::VCAWidget::VCAWidget ()
347- : ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget()
346+ ::StoneyDSP::StoneyVCV::VCA::VCAWidget::VCAWidget (::rack::math::Rect newBox )
347+ : ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget(newBox )
348348{
349349 DBG (" Constructing StoneyVCV::VCA::VCAWidget" );
350350
351- this ->setSize (::StoneyDSP::StoneyVCV::VCA::VCADimensions);
352-
353- this ->fb ->setSize (this ->getSize ());
354-
355- // Screws
356- this ->screwsPositions = {
357- ::rack::math::Vec ( // top-left
358- (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F ),
359- (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F )
360- ),
361- ::rack::math::Vec( // top-right
362- (::StoneyDSP::StoneyVCV::VCA::VCADimensions.x - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F )),
363- (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F )
364- ),
365- ::rack::math::Vec( // bottom-left
366- (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F ),
367- (::StoneyDSP::StoneyVCV::VCA::VCADimensions.y - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F ))
368- ),
369- ::rack::math::Vec( // bottom-right
370- (::StoneyDSP::StoneyVCV::VCA::VCADimensions.x - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F )),
371- (::StoneyDSP::StoneyVCV::VCA::VCADimensions.y - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0 .5F ))
372- ),
373- };
374- this ->screws [0 ]->setPosition ( // Centered
375- this ->screwsPositions [0 ].minus (this ->screws [0 ]->getSize ().div (2 .0F ))
376- );
377- this ->screws [1 ]->setPosition ( // Centered
378- this ->screwsPositions [1 ].minus (this ->screws [1 ]->getSize ().div (2 .0F ))
379- );
380- this ->screws [2 ]->setPosition ( // Centered
381- this ->screwsPositions [2 ].minus (this ->screws [2 ]->getSize ().div (2 .0F ))
382- );
383- this ->screws [3 ]->setPosition ( // Centered
384- this ->screwsPositions [3 ].minus (this ->screws [3 ]->getSize ().div (2 .0F ))
385- );
351+ // // Screws
352+ // this->screwsPositions = {
353+ // ::rack::math::Vec( // top-left
354+ // (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F),
355+ // (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F)
356+ // ),
357+ // ::rack::math::Vec( // top-right
358+ // (this->getSize().x - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F)),
359+ // (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F)
360+ // ),
361+ // ::rack::math::Vec( // bottom-left
362+ // (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F),
363+ // (this->getSize().y - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F))
364+ // ),
365+ // ::rack::math::Vec( // bottom-right
366+ // (this->getSize().x - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F)),
367+ // (this->getSize().y - (::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH * 0.5F))
368+ // ),
369+ // };
370+ // this->screws.at(0)->setPosition( // Centered
371+ // this->screwsPositions.at(0).minus(this->screws.at(0)->getSize().div(2.0F))
372+ // );
373+ // this->screws.at(1)->setPosition( // Centered
374+ // this->screwsPositions.at(1).minus(this->screws.at(1)->getSize().div(2.0F))
375+ // );
376+ // this->screws.at(2)->setPosition( // Centered
377+ // this->screwsPositions.at(2).minus(this->screws.at(2)->getSize().div(2.0F))
378+ // );
379+ // this->screws.at(3)->setPosition( // Centered
380+ // this->screwsPositions.at(3).minus(this->screws.at(3)->getSize().div(2.0F))
381+ // );
386382 // Params
387- this ->paramPanelWidgets .reserve (1 );
388- this ->paramPanelWidgets .emplace_back <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedRoundKnobPanelWidget *>(
389- dynamic_cast <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedRoundKnobPanelWidget *>(
390- ::StoneyDSP::StoneyVCV::createWidgetCentered<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedRoundKnobPanelWidget>(
391- ::rack::math::Vec ()
392- )
393- )
394- );
395- this ->fb ->addChild (this ->paramPanelWidgets [1 ]);
383+ this ->setNumParams (::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_PARAMS);
384+ this ->paramPanelWidgets .clear (); // because element 0 is a null-ish value from the in-class initializer...
385+ this ->paramPanelWidgets .reserve (this ->getNumParams ());
386+ for (::std::size_t i = 0U ; i < this ->getNumParams (); ++i)
387+ {
388+ this ->addParamPanelWidgetCentered <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedRoundKnobPanelWidget>(::rack::math::Vec ());
389+ this ->fb ->addChild (&this ->getParamPanelWidget (i));
390+ }
396391 // Ports
397- this ->portPanelWidgets .reserve (3 );
398- this ->portPanelWidgets .emplace_back <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
399- dynamic_cast <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
400- ::StoneyDSP::StoneyVCV::createWidgetCentered<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>(
401- ::rack::math::Vec ()
402- )
403- )
404- );
405- this ->portPanelWidgets .emplace_back <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
406- dynamic_cast <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
407- ::StoneyDSP::StoneyVCV::createWidgetCentered<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>(
408- ::rack::math::Vec ()
409- )
410- )
411- );
412- this ->portPanelWidgets .emplace_back <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
413- dynamic_cast <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *>(
414- ::StoneyDSP::StoneyVCV::createWidgetCentered<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>(
415- ::rack::math::Vec ()
416- )
417- )
418- );
419- this ->fb ->addChild (this ->portPanelWidgets [1 ]);
420- this ->fb ->addChild (this ->portPanelWidgets [2 ]);
421- this ->fb ->addChild (this ->portPanelWidgets [3 ]);
392+ this ->setNumPorts (::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_INPUTS + ::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_OUTPUTS);
393+ this ->portPanelWidgets .clear (); // because element 0 is a null-ish value from the in-class initializer...
394+ this ->portPanelWidgets .reserve (this ->getNumPorts ());
395+ for (::std::size_t i = 0U ; i < this ->getNumPorts (); ++i)
396+ {
397+ this ->addPortPanelWidgetCentered <::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>(::rack::math::Vec ());
398+ this ->fb ->addChild (&this ->getPortPanelWidget (i));
399+ }
422400 // Update
423401 this ->fb ->setDirty ();
424402 // Assertions
425403 assert (static_cast <unsigned int >(this ->getSize ().x ) == 6U * static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH));
426404 assert (static_cast <unsigned int >(this ->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
427405 assert (static_cast <unsigned int >(this ->fb ->getSize ().x ) == 6U * static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH));
428406 assert (static_cast <unsigned int >(this ->fb ->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
407+ assert (this ->getNumParams () == ::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_PARAMS);
408+ for (::std::size_t i = 0U ; i < this ->getNumParams (); ++i) {
409+ assert (&this ->getParamPanelWidget (i) != nullptr );
410+ }
411+ assert (this ->getNumPorts () == ::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_INPUTS + ::StoneyDSP::StoneyVCV::VCA::VCAModule::NUM_OUTPUTS);
412+ for (::std::size_t i = 0U ; i < this ->getNumPorts (); ++i) {
413+ assert (&this ->getPortPanelWidget (i) != nullptr );
414+ }
429415}
430416
431417::StoneyDSP::StoneyVCV::VCA::VCAWidget::~VCAWidget () noexcept
@@ -505,9 +491,11 @@ ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::VCAModuleWidget(::StoneyDSP::Stone
505491 )
506492 );
507493 this ->vcaWidget = dynamic_cast <::StoneyDSP::StoneyVCV::VCA::VCAWidget *>(
508- ::StoneyDSP::StoneyVCV::createWidgetSized<::StoneyDSP::StoneyVCV::VCA::VCAWidget>(
509- ::rack::math::Vec (0 .0F , 0 .0F ),
510- ::StoneyDSP::StoneyVCV::VCA::VCADimensions
494+ ::StoneyDSP::StoneyVCV::createPanelWidget<::StoneyDSP::StoneyVCV::VCA::VCAWidget>(
495+ ::rack::math::Rect (
496+ ::rack::math::Vec (0 .0F , 0 .0F ),
497+ ::StoneyDSP::StoneyVCV::VCA::VCADimensions
498+ )
511499 )
512500 );
513501 this ->vcaModuleWidgetFrameBuffer = dynamic_cast <::StoneyDSP::StoneyVCV::ComponentLibrary::FramebufferWidget *>(
@@ -570,71 +558,36 @@ ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::VCAModuleWidget(::StoneyDSP::Stone
570558 )
571559 );
572560
573- // try {
574- // std::cout << "Element at index 0: " << this->vcaWidget->portPanelWidgets.at(0) << std::endl; // Output: 3
575- // } catch (const std::out_of_range& e) {
576- // std::cerr << "Index out of range: " << e.what() << std::endl;
577- // }
578-
579- // try {
580- // std::cout << "Element at index 1: " << this->vcaWidget->portPanelWidgets.at(1) << std::endl; // Output: 3
581- // } catch (const std::out_of_range& e) {
582- // std::cerr << "Index out of range: " << e.what() << std::endl;
583- // }
584-
585- // try {
586- // std::cout << "Element at index 2: " << this->vcaWidget->portPanelWidgets.at(2) << std::endl; // Output: 3
587- // } catch (const std::out_of_range& e) {
588- // std::cerr << "Index out of range: " << e.what() << std::endl;
589- // }
590-
591- // try {
592- // std::cout << "Element at index 3: " << this->vcaWidget->portPanelWidgets.at(3) << std::endl; // Output: 3
593- // } catch (const std::out_of_range& e) {
594- // std::cerr << "Index out of range: " << e.what() << std::endl;
595- // }
596-
597- this ->vcaWidget ->portPanelWidgets [1 ]->setPosition (
561+ this ->vcaWidget->getPortPanelWidget (0 ).setPosition(
598562 ::rack::math::Vec (
599563 this ->portVcaInput->getPosition ().x - 2.425775F, // margin = portPanel.x - port.x / 2
600564 this->portVcaInput->getPosition().y - ((39 .15691F - 23 .7F ) - 2.425775F) // portPanel.y - port.y - margin
601565 )
602566 );
603- this ->vcaWidget->portPanelWidgets[ 2 ]-> setPosition (
567+ this ->vcaWidget->getPortPanelWidget ( 1 ). setPosition(
604568 ::rack::math::Vec (
605569 this ->portCvInput->getPosition ().x - 2.425775F,
606570 this->portCvInput->getPosition().y - ((39 .15691F - 23 .7F ) - 2.425775F)
607571 )
608572 );
609- this ->vcaWidget->portPanelWidgets[ 3 ]-> setPosition (
573+ this ->vcaWidget->getPortPanelWidget ( 2 ). setPosition(
610574 ::rack::math::Vec (
611575 this ->portVcaOutput->getPosition ().x - 2.425775F,
612576 this->portVcaOutput->getPosition().y - ((39 .15691F - 23 .7F ) - 2.425775F)
613577 )
614578 );
615579
616- this ->vcaWidget->portPanelWidgets[ 1 ]-> setIsOutput (false );
617- this ->vcaWidget->portPanelWidgets[ 2 ]-> setIsOutput (false );
618- this ->vcaWidget->portPanelWidgets[ 3 ]-> setIsOutput (true );
580+ this ->vcaWidget->getPortPanelWidget ( 0 ). setIsOutput(false );
581+ this ->vcaWidget->getPortPanelWidget ( 1 ). setIsOutput(false );
582+ this ->vcaWidget->getPortPanelWidget ( 2 ). setIsOutput(true );
619583
620- this ->vcaWidget->portPanelWidgets[ 1 ]-> setLabelText (" IN" );
621- this ->vcaWidget->portPanelWidgets[ 2 ]-> setLabelText (" CV" );
622- this ->vcaWidget->portPanelWidgets[ 3 ]-> setLabelText (" OUT" );
584+ this ->vcaWidget->getPortPanelWidget ( 0 ). setLabelText(" IN" );
585+ this ->vcaWidget->getPortPanelWidget ( 1 ). setLabelText(" CV" );
586+ this ->vcaWidget->getPortPanelWidget ( 2 ). setLabelText(" OUT" );
623587
624- this ->vcaWidget->paramPanelWidgets[1 ]->setPosition (
625- ::rack::math::Vec (
626- this ->gainKnob->getPosition ().x,
627- this->gainKnob->getPosition().y
628- )
629- );
630- this ->vcaWidget->paramPanelWidgets[1 ]->setSize ( // this instead of defining one knob panel struct per knob size?
631- ::rack::math::Vec (
632- this ->gainKnob->getSize ().x,
633- this->gainKnob->getSize().y
634- )
635- );
636- this ->vcaWidget->paramPanelWidgets[1 ]->setFontSize (12 .0F );
637- this ->vcaWidget->paramPanelWidgets[1 ]->setLabelText (" GAIN" );
588+ this ->vcaWidget->getParamPanelWidget (0 ).setBox(this ->gainKnob->getBox ());
589+ this ->vcaWidget->getParamPanelWidget (0 ).setFontSize(12 .0F );
590+ this ->vcaWidget->getParamPanelWidget (0 ).setLabelText(" GAIN" );
638591
639592 this ->prefersDarkPanelsPtr = static_cast <const bool *>(&::rack::settings::preferDarkPanels);
640593 this ->pixelRatioPtr = static_cast <const float *>(&APP->window->pixelRatio);
@@ -676,10 +629,6 @@ ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::VCAModuleWidget(::StoneyDSP::Stone
676629 // assert(module != nullptr);
677630 assert (this ->panel != nullptr );
678631 assert (this ->vcaWidget != nullptr );
679- // assert(this->vcaWidget->portPanelWidgets[0] != nullptr);
680- assert (this ->vcaWidget->portPanelWidgets[1 ] != nullptr );
681- assert (this ->vcaWidget->portPanelWidgets[2 ] != nullptr );
682- assert (this ->vcaWidget->portPanelWidgets[3 ] != nullptr );
683632 assert (this ->vcaModuleWidgetFrameBuffer != nullptr );
684633 assert (this ->gainKnob != nullptr );
685634 assert (this ->portCvInput != nullptr );
@@ -689,10 +638,10 @@ ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::VCAModuleWidget(::StoneyDSP::Stone
689638 assert (this ->prefersDarkPanelsPtr != nullptr );
690639 assert (this ->pixelRatioPtr != nullptr );
691640
692- assert (static_cast <unsigned int >(this ->getSize ().x ) == 6U * static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH));
693- assert (static_cast <unsigned int >(this ->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
641+ assert (static_cast <unsigned int >(this ->getSize ().x ) == 6U * static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH));
642+ assert (static_cast <unsigned int >(this ->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
694643 assert (static_cast <unsigned int >(this ->getPanel ()->getSize ().x ) == 6U * static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_WIDTH));
695- assert (static_cast <unsigned int >(this ->getPanel ()->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
644+ assert (static_cast <unsigned int >(this ->getPanel ()->getSize ().y ) == static_cast <unsigned int >(::StoneyDSP::StoneyVCV::Panels::MIN_HEIGHT));
696645}
697646
698647::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::~VCAModuleWidget () noexcept
@@ -702,7 +651,6 @@ ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::~VCAModuleWidget() noexcept
702651 assert (!this ->parent );
703652
704653 // Children
705- // this->vcaWidget->clearChildren();
706654 this ->vcaModuleWidgetFrameBuffer ->clearChildren ();
707655 this ->clearChildren ();
708656 this ->setModule (NULL );
0 commit comments