- Main Page
- Classes
- Files
- Related Pages

# Macintosh Editor as HIViewRef

## Introduction

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.

## Adding an HIView on effEditOpen

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

## Closing on effEditClose

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.

## Resizing the Plug-In

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.

## No more effEditDraw, effEditIdle, effEditMouse, effEditTop, effEditSleep

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.

## VST 2.4 Plug-Ins and VST 2.3 Hosts

Now there is a conflict situation that VST 2.3 hosts may not work with HIViews and window compositing. Therefore you need at least support effEditDraw, so that your Plug-In draws correctly in these hosts. Mouse, idle and activation events can be handled via Carbon Events.

See also:
  Apple HIView Programming Guide

Empty

Copyright ©2006 Steinberg Media Technologies. All Rights Reserved.