> Jane wrote:
> > What about one huge Fl_Widget[] array. Since each parameter has a unique
> > ID starting by 0 and ending at 1900+ something, the index of that array
> > is also the parameter ID (we knew that already).
> >
> > But since I know what kind of widget is used for each parameter,
> > I can decide on incomung MIDI data what to update.
>
> > (MIDI comes in)
> > ..
> > if (parameter == 0 || (parameter >= 12 && parameter <= 24)) // slider
> >   ui->set_slider(parameter, value);
> > else if ... // spinners
> >   ui->set_spinner(parameter, value);
>
>       Yes, I think this would be the 'wrapper object' approach, where
>       'ui' is an object that is a wrapper around all the possible
>       widgets a midi event can be.
>
>       But with this approach you don't need separate set_xxx() methods,
>       you could just have one, and have all the logic for how to set
>       the value within the single SetValue() method.
>
>       Here's one way to do it, where the 'wrapper' object can contain
>       pointers to all the types of objects (spinners, sliders), and
>       has a single method that converts them. eg:
>
[..]


Here's another approach, in outline (nb uncompiled/untested),
that you can consider.

class Control {
public:
    virtual void set_value(int) = 0;
    virtual int get_value() const = 0;
};
class Slider : public Fl_Slider, public Control {
public:
    Slider(int x, int y, int w, int h, char const* label = 0)
        : Fl_Slider(x, y, w, h, label)
    {;}
    void set_value(int v) { Fl_Slider::value(v); }
    int get_value() const { return Fl_Slider::value(); }
};

// similarly for other classes of interest

Then, store a container of Control*, and proceed as Ian
and others have suggested.

To me it's more attractive than switch/case logic, but of course
decide for yourself.

HTH,
Stan
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to