AEffEditor

class AEffEditor

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.


Constructor and Destructor


AEffEditor

AEffEditor (AudioEffect*effect);

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.

Example :

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"
}

~AEffEditor

virtual ~AEffEditor ();

Example :

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
}

getRect

virtual long getRect (ERect **rect);

Host is asking the editor how big it wants its window to be.


open

virtual long open (void *ptr);

Host is about to open a window for the editor.


close

virtual void close ();

Host is about to close the window for the editor.

Example :

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;
}

idle

virtual void idle ();

Host has "idling" events for the editor.


update

virtual void update ();

Update your graphics during this call if you have flagged any updates. This gets called during idle ().


postUpdate

virtual void postUpdate ();

Here you can flag any updates that will later be actioned in update ().


Macintosh

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:


draw

virtual void draw (ERect *rect);

Host says this area of the editor window needs updating.


mouse

virtual long mouse (long x, long y);

Host says the mouse was clicked here. See AEffGUIEditor.


key

virtual long key (long keyCode);

Host says what key was pressed.


top

virtual void top ();

sleep

virtual void sleep ();

protected members :


AEffEditor ();

AudioEffect *effect;

void *systemWindow;

long updateFlag;

ERect

struct ERect;

Members are of type short and in the folowing order : top, left, bottom, right.



Copyright ©2003 Steinberg Media Technologies GmbH. All Rights Reserved.