Control interaction in VSTGUI4

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Control interaction in VSTGUI4

Post by .rhavin »

Hi all,

The GUI for my plugin is defined in an XML-file called EOSX.uidesc and is created like this:

Code: Select all

// --------------------------------------------------------------------------
// create a new view
IPlugView* PLUGIN_API EOSXController::createView(FIDString name)
{
	if (ConstString(name) == ViewType::kEditor)
		return new VST3Editor(this, "EOSXEditor", "EOSX.uidesc");
	return nullptr;
}
Part of this XML-file are two buttons defined like this:

Code: Select all

<view background-offset="0, 0" bitmap="connect" class="COnOffButton" control-tag="connect" default-value="0" disabled-bitmap="connected" max-value="1" min-value="0" mouse-enabled="true" opacity="1" origin="310, 40" size="90, 31" tooltip="(dis-)connect" transparent="false" wheel-inc-value="1"/>
<view background-offset="0, 0" bitmap="go" class="COnOffButton" control-tag="fire" default-value="0.5" disabled-bitmap="go" max-value="1" min-value="0" mouse-enabled="true" opacity="1" origin="310, 95" size="90, 31" transparent="false" wheel-inc-value="0.1"/>
Now I need to know inside EOSXController when the user clicks on the buttons, and im pretty sure this is what listeners are meant for, but how do I get the COnOfButton* from the GUI to apply the listener?

Also, i'd like to have different PNGs for mouse-hovering on the buttons, is this possible?

Arne Scheffler
Posts: 383
Joined: Mon Jun 20, 2016 7:53 am

Re: Control interaction in VSTGUI4

Post by Arne Scheffler »

See VST3EditorDelegate:: createSubController(..) this will be called if you set the 'sub-controller' attribute of a view or view container. The controller is then used to control all the included views/controls.

User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Re: Control interaction in VSTGUI4

Post by .rhavin »

Does not work as i'd expect it todo. I did the following:

Code: Select all

// from EOSXController.h
class EOSXController : public EditController, VSTGUI::VST3EditorDelegate,
	IController
{
	// … //
	virtual IController* createSubController(UTF8StringPtr name,
		const IUIDescription* description, VST3Editor* editor) SMTG_OVERRIDE
		{return this;}
	virtual void valueChanged(CControl* pControl) SMTG_OVERRIDE;
}
My controller now derives from VST3EditorDelegate and IController. I implemented valueChanged like this:

Code: Select all

// from EOSXController.cpp
void EOSXController::valueChanged(CControl* pControl)
{
	COnOffButton* pBtn = dynamic_cast<COnOffButton*>(pControl);
	if (pBtn == nullptr)
		return;
	pBtn->setBackground(pBtn->getDisabledBackground());
	pBtn->setDirty(true);
}
So when clicking on the button, the bitmap should change to DisabledBackground. But nothing happens.

Arne Scheffler
Posts: 383
Joined: Mon Jun 20, 2016 7:53 am

Re: Control interaction in VSTGUI4

Post by Arne Scheffler »

You should use a specialised controller for your UI. You should do something like this:

Code: Select all

class MyUIController : public DelegationController
{
public:
    MyUIController (IController* parent) : DelegationController (parent) {}
    
	IControlListener* getControlListener (UTF8StringPtr controlTagName) override { return this; }

    void valueChanged (CControl* pControl)
    {
    }
};
And for your EOSXController :

Code: Select all

IController* EOSXController::createSubController (UTF8StringPtr name, const IUIDescription* description, VST3Editor* editor)
{
    return new MyUIController (editor);
}

User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Re: Control interaction in VSTGUI4

Post by .rhavin »

Im not sure if I understand this fully:

I already have a "specialized" UI- controller: its the EOSXcontroller-class, supposed to do the UI-interaction:

Code: Select all

class EOSXController : public EditController, VSTGUI::VST3EditorDelegate,
	IController
The other class is this, supposed to do the actual work:

Code: Select all

class EOSX : public AudioEffect
What would be the purpose of a third class?

BTW, I tried to do what you suggested, it still does not work.


See full source here:

http://shadowtec.de/xd/EOSX_V0.2.2.7.rar

Arne Scheffler
Posts: 383
Joined: Mon Jun 20, 2016 7:53 am

Re: Control interaction in VSTGUI4

Post by Arne Scheffler »

If my suggestion does not work, you have something else wrong. Did you set the 'sub-controller' attribute in the UIDescription-Editor ?

And by the way, using zip as archive format would be easier, as all platforms support this format without installing extra software these days.

User avatar
.rhavin
Posts: 6
Joined: Mon Jul 24, 2017 7:23 am

Re: Control interaction in VSTGUI4

Post by .rhavin »

Arne Scheffler wrote:If my suggestion does not work, you have something else wrong. Did you set the 'sub-controller' attribute in the UIDescription-Editor ?
Yes, I did. It – BTW – crashes constantly if I try to add another Bitmap!
Arne Scheffler wrote:And by the way, using zip as archive format would be easier, as all platforms support this format without installing extra software these days.
EOSX_V0.2.2.7.zip
You do not have the required permissions to view the files attached to this post.

Arne Scheffler
Posts: 383
Joined: Mon Jun 20, 2016 7:53 am

Re: Control interaction in VSTGUI4

Post by Arne Scheffler »

Put your buttons into a CViewContainer and set the sub-controller attribute on the CViewContainer, not the buttons itself. This should get you going.

Arne Scheffler
Posts: 383
Joined: Mon Jun 20, 2016 7:53 am

Re: Control interaction in VSTGUI4

Post by Arne Scheffler »

And regarding the crash, call stack ?

Post Reply