Creating GUI without editor / XML

A User Interface Toolkit mainly for Audio Plug-Ins (VST, AudioUnit, etc).
User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Creating GUI without editor / XML

Postby .rhavin » Sat Aug 05, 2017 1:44 pm

My controller just needs 7 controls. I want to create them myself, without XML and editor. Lets say you just have a button:

Code: Select all

class FooController : public EditController
{
   // … //
protected:
   COnOffButton* m_pButton;
}


How would you set up the frame and create it in VSTGUI4 / VST3? All examples are for 2.x…

User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Re: Creating GUI without editor / XML

Postby .rhavin » Fri Sep 15, 2017 6:35 pm

well, *anyone* ?? :|

ray
Posts: 14
Joined: Fri Sep 02, 2016 9:37 am

Re: Creating GUI without editor / XML

Postby ray » Mon Sep 18, 2017 9:04 am

Considering the basics, there's not much of a difference between VST2.x and VST3 editor wise imo.

One way would be to let FooController inherit from VSTGUIEditor and IControlListener:

Override open() to create a frame and place your controls. Something along the lines of

Code: Select all

virtual bool PLUGIN_API open(void* parent, const PlatformType& platformType = kDefaultNative)
{
   CRect size(rect.left, rect.top, rect.right, rect.bottom);

   auto old_frame = frame;
   frame = new CFrame(size, this);
   if(old_frame)
      old_frame->forget();

   if(frame && frame->open(parent, platformType))
   {
      // Create your controls here and add them via frame->addView(...)
      ...
      return true;
   }
   return false;
}


Make sure to destroy your frame in your overrider of close(). Note that frame->close() will take care of forgetting your previously added controls and also forget() itself, so don't worry about leaking here...

Code: Select all

virtual void PLUGIN_API close()
{
   if(frame)
   {
      auto old_frame = frame;
      frame = 0;
      if(old_frame)
         old_frame->close();
   }
}


Then override valueChanged() to react to mouse/keyboard interaction performed by the user and forward them to your controller. Dispatching is typically handeled using tags (just use the IDs assigned to your parameters) and set the new values via

Code: Select all

controller->setParameterNormalized(control->getTag(), control->getValue());


Additionally, you'll need a machanism to make your GUI controls react to parameter changes imposed by the host (e.g. automation). You can do that by polling or you implement a custom synchronization protocol, e.g. take a look into the VST3Editor implementation to see how it's done - look out for the paramChangeListeners member.

Hope this helps.


Return to “VSTGUI”

Who is online

Users browsing this forum: No registered users and 1 guest