In the beginning of VST the Plug-In's GUI was attached at the left-top corner without a mechanism for the host to move it. This and the evolution of the macintosh platform makes it necessary to change this old behaviour. The modern way on Mac OS X to do UI design with C/C++ is to use HIViews and window compositing.
The VST SDK 2.4 requires the Plug-In to attach one HIView to the window and that this HIView can be moved around and that it can be embedded into other subviews.
Hosts which implement VST 2.4 need to provide a window to the Plug-In which is composited if the Plug-In itself uses 2.4. If the Plug-In uses an earlier VST SDK it should provide a non composited window.
As before the ptr in effEditOpen is a WindowRef. You need to add one HIView to the content view of this window.
HIViewRef contentView;
if (HIViewFindByID (HIViewGetRoot ((WindowRef)ptr), kHIViewWindowContentID, &contentView) == noErr)
HIViewAddSubview (contentView, myPluginView);
When effEditClose is called you should remove your HIView from the window.
HIViewRemoveFromSuperview (myPluginView);
Don't do anything with the window. It is not your window.
If you want to resize your view, just do it, but don't resize the host window.
HIRect pluginBounds;
HIViewGetFrame (myPluginView, &pluginBounds);
pluginBounds.size.width = newWidth;
pluginBounds.size.height = newHeight;
HIViewSetFrame (myPluginView, &pluginBounds);
The host needs to listen to bounds changes on the Plug-In view and resize its window accordingly.
You need to use Carbon Events now, which you register on the HIView, not on the window if possible. But don't remove these opcodes from your editor yet, if you want your Plug-In to work in 2.3 hosts.
Now there is a conflict situation that some VST 2.3 hosts may not work with HIViews and window compositing. You should map the mac specific effEdit* opcodes internaly to the same functions you call if you receive one of the appropriate Carbon Events (VSTGUI does this automatically). You also need to define VST_FORCE_DEPRECATED=0 as a preprocessor definition to get the effEdit* opcodes.
With revision 1 of SDK 2.4 the default value for VST_FORCE_DEPRECATED is zero, if you build for ppc machines.
- See also:
- Apple HIView Programming Guide
Empty