Nested/Composite/Meta Controls

I’m wondering how to “nest” controls into reusable components (or meta controls, I guess).

Is this the best example to follow?

Any other helpful advice? (Asked in Slack but posting here for benefit of others.)

Just bear in mind these IControls that nest other IControls are a bit niche (i personally haven’t used them much before) and are not the only way of grouping controls. Controls can be assigned a control group (see IGraphics::AttachControl). You can also have parameter groups, which might be useful.

I would like to advocate some support for nesting controls in iPlug 2.

The one thing I have run into is that, while I can do GetUI()->AttachControl(...) in OnAttached() of some “parent” control, this doesn’t establish a parent-child relationship.

For example, if I call Hide() on the parent control, the controls attached as “children” don’t also get hidden.

This shows up in the bundled controls too; if you call IVNumberBoxControl::Hide it doesn’t get properly hidden. You must override Hide() to ensure that the “child” controls get hidden manually:

  void Hide(bool hide) override
  {
    mTextReadout->Hide(hide);
    mIncButton->Hide(hide);
    mDecButton->Hide(hide);
  }

So I would advocate a basic set of child management built into IControl interface. Like AddChild, RemoveChild, etc. Instead of GetUI()->AttachControl() it would be great to have this->AddChild(), which would manage UI and add the control to a vector<IControl*> mChildren or something like that.

Thoughts? :slight_smile:

It’s a nice thought, but the big question would be how does the mouse event propagation work? Do child controls also get added to the main IGraphics::mControls stack.

I’ve been investigating nested controls for a while (i have a branch where i am working on multi-touchable controls, including an MPE keyboard that is made up of individual controls fro each key), so I will try and look at it soon.

I did that kind of relationship for the TotalEQ we released earlier this year.
The controls that surround the frequency and gain control point are “children” of the control that draws the EQ response curve, actually to create what at the time i called the “proxy” control i had to explicitly pass every “OnMouse…” event from the “proxy” to the child control that was hit, thus evaluating if the mouse pointer was inside the chidren’s IRECT when the event fired. Also there are some little quirks with the mouse up event that may happen outside the chidren’s rect but the mouse down could have been originated inside the children’s area, so you must keep track of where the mouse down event started.

Saverio

1 Like