Just as all the plug-ins are derived from AudioEffectX
, all the editors
are derived from the class AEffEditor
. If a plug-in has
its own editor, it instanciates one when it. If a plug-in has its own
editor, as opposed to working on the built-in 'string interface provided by
a VST host. it instanciates one when it itself is constructed.
The editor gets passed the plug-in object as a parameter to its constructor, and the editor uses this to notify the effect object of its presence.
As usual we define a class for the new plug-in. This ADelayEdit
class inherits directly from ADelay
, thus both the declaration
and constructor methods are very simple...
class ADelayEdit : public ADelay
{
public:
ADelayEdit (audioMasterCallback audioMaster);
~ADelayEdit ();
};
ADelayEdit::ADelayEdit (audioMasterCallback audioMaster)
: ADelay (audioMaster)
{
setUniqueID ('ADlE');
editor = new ADEditor (this);
if (!editor)
oome = true;
}
As you can see from the constructor, ADelayEdit
merely adds
an editor ADEditor
. This editor is derived from the base
class AEffEditor
as described above. Looking at the constructor
of the editor, you can see the Audio Effect (our plug-in) being used
as a parameter, and the plug-in being formally informed about the editor.
ADEditor::ADEditor (AudioEffect *effect)
: AEffEditor (effect)
{
effect->setEditor (this); // notify effect that "this is the editor"
}
The ADelayEdit
destructor has nothing to do, as AudioEffect
takes care of deleting the editor when the plug-in is removed.
ADelayEdit::~ADelayEdit ()
{
// the editor gets deleted by the
// AudioEffect base class
}
Host is asking the editor how big it wants its window to be.
Host is about to open a window for the editor.
Host is about to close the window for the editor.
void MyEditor::close ()
{
// don't forget to remove the frame !!
if (frame)
delete frame;
frame = 0;
// forget background if not anymore used
if (myBackground)
{
if (myBackground->getNbReference () <= 1)
{
myBackground->forget ();
myBackground = 0;
}
else
myBackground->forget ();
}
// set to zero all pointer (security)
myControl = 0;
}
Host has "idling" events for the editor.
Update your graphics during this call if you have flagged any updates.
This gets called during idle ()
.
Here you can flag any updates that will later be actioned in update ()
.
The resource file should always be open, and the current resource file should point to the plugs' resources, in all of the following calls:
that means all init/exit calls, and all GUI related calls where we expect the plug to do something with its resources.Don't forget to set the current resource file before calling into any of the mentioned calls, by applying something like :
short currentResFile = CurResFile ();
UseResFile (plug->resFile);
plug->effect->dispatcher (whateverOpcode, bla, bla...)
UseResFile (currentResFile);
The vstgui will mainly access the resource file when the editor is opened (most of all when getting PICTs for CBitmap classes). I hope all of this is utterly correct because i can't access the sources while writing this... if you still have problems, we can look it up.
On the Macintosh the window your plug-in receives is created by the host, and the GUI events your plug-in receives are received globally by the host application and posted on to the plug-in with these methods. VST hosts on the Mac create a window for the plug-in's editor and then passes all the events on to the editor. There are a few functions that negotiate this process. Here they are:
Host says this area of the editor window needs updating.
Host says the mouse was clicked here. See AEffGUIEditor
.
Host says what key was pressed.
Members are of type short
and in the folowing order : top
,
left
, bottom
, right
.