Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
How do you resize VST window?
No permission to create posts
March 5, 2016
3:22 am
Avatar
Derek
Member
Members
Forum Posts: 41
Member Since:
November 19, 2015
sp_UserOfflineSmall Offline

Hi all,

I'm working on a custom VSTGUI interface, like project Custom Views Five, and I'm trying to figure out how to resize the entire VST window. I can resize the CFrame no problem but the surrounding window does not re-adjust. I want to let the user choose the window size scale (e.g. 100%, 125%, 150%, etc.) Is it just an extra call the window container? If so how is that done?

code to resize the frame located in ::idle() based on a button click
if (doResize)
{
frame->setSize(newWidth, newHeight);
frame->invalid();
}

I suppose you could send a command back to the plugin and tell it to close the window then reopen with a new size, but that seems more like a hack than a proper design.

Any help would be appreciated as the VSTGUI documentation is quite lacking.

thanks

March 6, 2016
3:50 am
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

I don't think it can be done.

I thought you could use the platform frame code which calls SetWindowPos( ):

IPlatformFrame* platformFrame = frame->getPlatformFrame();

// --- get the rect
CRect rect;
platformFrame->getSize(rect);

// --- make 50% skinnier
rect.setWidth(rect.getWidth()*0.5);

// --- set new size
frame->setViewSize(rect);
platformFrame->setSize(rect);

However, this only changes the client area of the window and does not resize the outer Window itself. Stepping into the platformFrame->setSize( ) function reveals a comment that reads, in part,

"...In VST2 this was not the case, we also resized the parent window. This must be done upstream now."

"Upstream" means that the client needs to do the resizing.

If anyone knows how to resize the actual GUI window (not just the client area inside it) please let us know, though I am guessing that it might be an undesirable coding issue.

- Will

March 6, 2016
7:53 pm
Avatar
Tom
Admin
Forum Posts: 65
Member Since:
April 3, 2014
sp_UserOfflineSmall Offline

Hi,

the resize functionality is part of the host, so it is not part of VSTGUI directly but the VST3 SDK. You have to signal the host that you can/want to resize the window by returning kResultTrue from canResize(). Then, iff the host supports it, it will give you the IPlugFrame object in setFrame(). On this objecet you can call setSize. If you have constriants regarding the size, you need to correct the size in checkSizeConstraint. That's the VST3 part - you may take a look at VSTGUI for their default implementation for IPlugView.

See IPlugView.h from the VST3 SDK:

/** Sets IPlugFrame object to allow the Plug-in to inform the host about resizing. */
virtual tresult PLUGIN_API setFrame (IPlugFrame* frame) = 0;

/** Is view sizable by user. */
virtual tresult PLUGIN_API canResize () = 0;

/** On live resize this is called to check if the view can be resized to the given rect, if not adjust the rect to the allowed size. */
virtual tresult PLUGIN_API checkSizeConstraint (ViewRect* rect) = 0;

Regards
Tom

March 6, 2016
11:00 pm
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

Thanks Tom, but I was actually referring to this as host-independent -- i.e. using VSTGUI4 (directly) for non-VST3 hosts, like for RackAFX, AU and AAX.

- Will

March 7, 2016
12:41 am
Avatar
Derek
Member
Members
Forum Posts: 41
Member Since:
November 19, 2015
sp_UserOfflineSmall Offline

Hi guys,

Looking around the web it seems like the host does need to support re-sizing. If that's the way it has to be, that's fine.
Let me first clarify that I am using the "Make VST" button from RackAFX to create my project.

Looking at the IPlugView class it states

Sizing of a view
Usually the size of a Plug-in view is fixed. But both the host and the Plug-in can cause a view to be resized:
Host : If IPlugView::canResize() returns kResultTrue the host will setup the window so that the user can resize it. While the user resizes the window IPlugView::checkSizeConstraint () is called, allowing the Plug-in to change the size to a valid rect. The host then resizes the window to this rect and calls IPlugView::onSize().
Plug-in : The Plug-in can call IPlugFrame::resizeView () and cause the host to resize the window. Afterwards IPlugView::onSize() is called.
Please only resize the platform representation of the view when IPlugView::onSize() is called.

That's all well and good but there's a few things I'm confused about.
In my project the VSTProcessor extends SingleComponentEffect. This combines the VST 3 processor and controller parts together and that is where the IPlugView is created. (Looks like IPlugView created is Will's class VST3EditorWP?)
Then there's also the VSTGUIController which sets up all the VSTGUI controls and has the CFrame that opens the main window.

So how do these two classes interact? To resize the window it seems you need to resize both the IPlugFrame in VSTProcessor and the CFrame in VSTGUIController, but I don't see any communication links between these classes. Confused

March 7, 2016
1:43 am
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

When you use Make VST and you have implemented your own custom GUI, I use a custom VSTGUIEditor object

class CRafxCustomView: public VSTGUIEditor

which is declared at the bottom of the processor.h file, and the (few) implementation functions are at the bottom of the processor.cpp file.

If you look in the open( ) function, you can see me calling showGUI( ) on your plugin to create your custom GUI:

void* hasCustomGUI = m_pPlugIn->showGUI((void*)&info);

The VST plugin carries a pointer to this VSTGUIEditor object m_pRafxCustomView; see the creation in Processor::createView( )

if(info.bHasUserCustomView)
{
// CRafxCustomView creates the frame, populates with plugin view, then resizes frame
m_pRafxCustomView = new CRafxCustomView(this);
m_pRafxCustomView->setPlugIn(m_pRAFXPlugIn);
return m_pRafxCustomView;
}

m_pRafxCustomView is the connecting object between your VSTGUIController and the VSTGUIEditor.

NOTE: there is a difference in my implementation to be aware of:

VSTGUIEditor inherits from CPluginView, NOT IPluginView but if you check the base class, you will see that CPluginView also implements the same functions as IPluginView (canResize() and checkResizeConstraints()).

The reason I do this is that the CPluginView object was put in VSTGUI4 for non-VST3 plugins and I reuse the identical code in the Make AU ports as well. IPluginView would not work there.

If you absolutely must use IPluginView then you can hack the code a bit by changing the custom editor's base class to VST3Editor:

class CRafxCustomView: public VST3Editor

You should only need to change the constructor's base class to VST3Editor:

CRafxCustomView::CRafxCustomView(Steinberg::Vst::EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile)
: VST3Editor(controller, templateName, xmlFile)

- Will

March 7, 2016
6:24 am
Avatar
Derek
Member
Members
Forum Posts: 41
Member Since:
November 19, 2015
sp_UserOfflineSmall Offline

Thanks Will,

that helps a lot!

However, and sorry if I'm being dense, I get how Processor has access to RafxCustomView that has access to the RafxPlugin that has access to VSTGUIController. I can hard code window changes inside RafxCustomView and they resize my window. But.. I don't get how I access RafxCustomView (or Processor if there is a link) from the RafxPlugIn. Do I need to pass a pointer to RafxCustomView and store that in RafxPlugIn?

e.g. in Processor::createView
if(info.bHasUserCustomView)
{
// CRafxCustomView creates the frame, populates with plugin view, then resizes frame
m_pRafxCustomView = new CRafxCustomView(this);
m_pRafxCustomView->setPlugIn(m_pRAFXPlugIn);
m_pRAFXPlugIn->SetCustomViewPtr(m_pRafxCustomView);
return m_pRafxCustomView;
}

I appreciate your help and patience!

March 7, 2016
8:59 pm
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

The reason for the layers of objects is that the SingleComponentEffect (or the Controller in a dual-component version) is a VST3EditorDelegate so it responds to the createView( ) function by creating the editor as required - it does not implement a GUI editor itself. I subclassed my own VST3Editor for the normal GUI, and subclassed the VSTGUIEditor for those with custom editors. The goal was to make sure that your VSTGUIController object you write in RackAFX is platform and host independent and will work as-is in the AU versions, so it is "pure" VSTGUI and is not derived from any VST-specific objects.

Next, the way to pass the VSTGUIEditor pointer to your plugin is via the VSTGUI_VIEW_INFO struct. If you look at the definition, you will see that I placed a variable in there for advanced users:

// --- pointer to VST3Editor, if you know how to use it!
void* editor; // editor

So, you can do the following:

in VSTGUIController.h

#include "public.sdk/source/vst/vstguieditor.h"

Then, declare the pointer, I made it protected, and note the namespacing required:

Steinberg::Vst::VSTGUIEditor* m_pEditor;

Next the set function:
void setEditor(void* pEditor)
{
m_pEditor = (Steinberg::Vst::VSTGUIEditor*)pEditor;
}

Now, in the open( ) method for the GUI Editor near the bottom of processor.cpp add info.editor = (void*)this:

VSTGUI_VIEW_INFO info;
info.message = GUI_USER_CUSTOM_OPEN;
info.window = (void*)parent;
info.hPlugInInstance = moduleHandle;
info.hRAFXInstance = NULL;
info.size.width = 0;
info.size.height = 0;
info.editor = (void*)this; // ------- that is the editor pointer!

void* hasCustomGUI = m_pPlugIn->showGUI((void*)&info);

Finally, in your showGUI( ) method:

if(m_pGUIController)
{

m_pGUIController->open(info->window, this, info->size.width, info->size.height, info->hPlugInInstance);

if(info->editor)
m_pGUIController->setEditor(info->editor);

}

Of course you need to add some code for initializing your pointer to NULL in the constructor and always checking validity before using it. Also, your VSTGUIController object will be VST-specific at that point so it won't port to AU, but that's OK because you are working in the Make VST project, not the RackAFX version.

- Will

March 8, 2016
2:28 am
Avatar
Derek
Member
Members
Forum Posts: 41
Member Since:
November 19, 2015
sp_UserOfflineSmall Offline

Thanks Will,

that's exactly what I was looking for.

After getting that setup I was still having trouble getting the window to change size. (i.e. m_pEditor->getFrame()->setSize() was supposedly changing the window size as I stepped through the debugger but it would never redraw to the new size.)

However, I got things working by calling checkSizeConstraint to force the size change.

in CVSTGUIController::idle()

if (m_doResize)
{
if (m_pEditor)
{
// resize the top window frame
Steinberg::ViewRect vr(0, 0, newWidth, newHeight);
m_pEditor->checkSizeConstraint(&vr);
m_doResize = false;
}
// resize the VSTGUIController frame
frame->setSize(newWidth, newHeight);
frame->invalid();
}

where m_pEditor is the VSTGUIEditor pointer

Inside CRafxCustomView
I overloaded setFrame and saved off the IPlugFrame pointer. This is called when the GUI window first opens.
tresult PLUGIN_API CRafxCustomView::setFrame(IPlugFrame * frame)
{
if (frame)
{
m_plugFrame = frame;
}
return kResultOk;
}

And in checkSizeConstraint, I use that iPlugFrame to set the passed in rect

tresult PLUGIN_API CRafxCustomView::checkSizeConstraint(ViewRect *rect)
{
if (m_plugFrame)
{
m_plugFrame->resizeView(this, rect);
}

return kResultTrue;
}

Also, return true for canResize
tresult PLUGIN_API CRafxCustomView::canResize()
{
return kResultTrue;
}

Thanks for your help!

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online: W Pirkle
3 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Derek: 41

Peter: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 478

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 29

Topics: 479

Posts: 1870

Newest Members:

certvalue111, sobhana s, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 140

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 140