VSTGUI
4.4
Graphical User Interface Framework not only for VST plugins
|
This tutorial should give you a brief overview on how to get started using VSTGUI.
To add a user interface to a VST Plug-In with VSTGUI is quiet simple.
Create a new class which inherits from AEffGUIEditor. Overwrite AEffGUIEditor::open and AEffGUIEditor::close.
In MyEditor::open you create the CFrame.
In MyEditor::close you need to delete the CFrame
Now you just need to set the editor of your VST Plug-In to a new instance of MyEditor.
So you have your own editor for a VST Plug-In. Now you need to add controls to it.
Most controls provided with VSTGUI use images. So you need to know how to load and use images in VSTGUI. To load an image, you just need to use the CBitmap class.
The image "MyBitmap.png" must be defined in the .rc file on Windows like this :
On Mac OS X the image must be inside the Resources folder of the vst bundle.
Now that we have loaded an image, we want this image to be shown in our editor. The simplest way is to use the CView class, which is the base of all view and control classes.
To actually get this shown, we need to add this view to the CFrame object created earlier.
So after we have setup all views we can get rid of our image as all views will remember the image by its own.
Now lets see how this looks as a complete example :
To only have an image shown in our editor is a little bit lame. We want to have some controls the user can interact with.
VSTGUI provides some basic controls you can use. As an example we use the CKnob control. The CKnob control takes two images, the background and the handle. The background as its name suggest is always drawn as the background of this control, while the handle is drawn at the position of the value of this control. See VSTGUI::CKnob for more info.
Now lets see how to create such a knob:
As you can see there are some parameters set to zero. Ignore them for a moment. I will talk about it later. If you add this knob to the frame and test the interface you will see that if you press the mouse button over this control and move the mouse, the handle of the knob is also moving. Great, we have something to play with in the editor.
The complete example :
So now we have a knob in our editor. We'd like to know when the user uses this control.
This is done with the CControlListener interface. Every control in VSTGUI can have one listener. When the value of the control has changed the listener is notified.
First we need a CControlListener. The easiest way is to inherit our editor not only from AEffGUIEditor but also from CControlListener :
Now we can use our editor as the listener parameter in the CKnob constructor.
We only need to implement the valueChanged method and we know when the user twiddles our knob.
With one control it's fairly easy to know which control was used by the user. If there are more controls in our editor, to know which control was used is done by the tag of the control. So if we add two knobs to the frame we gave them different tags :
Now in our valueChanged method we can differentiate between the controls :
For a complete example have a look at the tutorial project included with VSTGUI.