Component arrays?


#1

I’m using about 60 sliders in my new synth and each slider corresponds to a parameter. In roid, I kept the sliders in an array with the indices corresponding to the synth parameter index. This made updating back and forth very easy.

Can Jucer make arrays somehow?


#2

Hmm - that’d be a bit complex to get it to do, and I can’t even think how you’d attempt to put it into the UI!


#3

Ok. I’ll just have to settle for a GUI and make the transition manually. It will keep me from doing uneeded tweaks. :smiley:

I’d think that you could implement it as a sort of meta object though. You create an Component array, and then the type of component as well as the number are it’s properties. You could even add a list that creates an enum.

This just puts the widgets on the screen and from then on its all still manual.

My code ends up looking like this:

     //Sliders, Common props
     for(int i = 0; i < 41; i++){
         addAndMakeVisible (Sliders[i] = new SnappingSlider (T("DobbiDoo")));
         Sliders[i]->setRange (0, 1.0f, 0);
         Sliders[i]->setSliderStyle (Slider::RotaryVerticalDrag);
         Sliders[i]->setTextBoxStyle (Slider::NoTextBox, true, 80, 20);
         Sliders[i]->addListener (this);
         Sliders[i]->setSnap(0.0f , 0.05f);
     }

    //Sliders, Specials
    Sliders[penv_amt]->setRange (-1, 1, 0);
    Sliders[fenv_amt]->setRange (-1, 1, 0);
    Sliders[f_80]->setRange (-1, 1, 0);
    Sliders[vel_filter]->setRange (-1, 1, 0);
    Sliders[vel_pitch]->setRange (-1, 1, 0);
    Sliders[o1_semi]->setRange (-1, 1, 0);
    Sliders[o2_semi]->setRange (-1, 1, 0);
    Sliders[o1_cent]->setRange (-1, 1, 0);
    Sliders[o2_cent]->setRange (-1, 1, 0);
    Sliders[o_mix]->setRange (-1, 1, 0);
    Sliders[g_len]->setRange (0, 32, 1);
    Sliders[vel_amp]->setRange (-1, 1, 0);

    Sliders[penv_a]->setBounds (428, 28, 32, 32);
    Sliders[penv_d]->setBounds (460, 28, 32, 32);
    Sliders[penv_s]->setBounds (492, 28, 32, 32);
    Sliders[penv_r]->setBounds (524, 28, 32, 32);
    Sliders[penv_amt]->setBounds (556, 12, 32, 32);
    Sliders[fenv_a]->setBounds (428, 104, 32, 32);
    Sliders[fenv_s]->setBounds (460, 104, 32, 32);
    Sliders[fenv_d]->setBounds (492, 104, 32, 32);
    Sliders[fenv_r]->setBounds (524, 104, 32, 32);
    Sliders[fenv_amt]->setBounds (556, 88, 32, 32);
    Sliders[aenv_a]->setBounds (428, 180, 32, 32);
    Sliders[aenv_d]->setBounds (460, 180, 32, 32);
    Sliders[aenv_s]->setBounds (492, 180, 32, 32);
    Sliders[aenv_r]->setBounds (524, 180, 32, 32);

I don’t mind doing it manually though.


#4

You could always create an array, and in the constructor, copy all the jucer’s components into the appropriate index, then use the array instead of the normal pointers?


#5

Yeah. That ought to work. That way I only have to do the mapping once and can still just plug in the Jucer code.

Good call.


#6