Control interaction in VSTGUI4

Hi all,

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

// --------------------------------------------------------------------------
// 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:

<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?

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.

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

// 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:

// 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.

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

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 :

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

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:

class EOSXController : public EditController, VSTGUI::VST3EditorDelegate,
	IController

The other class is this, supposed to do the actual work:

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

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.

Yes, I did. It – BTW – crashes constantly if I try to add another Bitmap!

EOSX_V0.2.2.7.zip (455 KB)

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

And regarding the crash, call stack ?