When user resizes plugin window, the complete inside of the window isn't redrawn

Hello

I have the following code in my controller .h file

namespace SBN
{

class SatuController : public Steinberg::Vst::EditControllerEx1, public VSTGUI::VST3EditorDelegate, public VSTGUI::ViewListenerAdapter
{
public:
	using UTF8StringPtr = VSTGUI::UTF8StringPtr;
	using IUIDescription = VSTGUI::IUIDescription;
	using IController = VSTGUI::IController;
	using VST3Editor = VSTGUI::VST3Editor;
	using CView = VSTGUI::CView;
	using UIAttributes = VSTGUI::UIAttributes;

//------------------------------------------------------------------------
	SatuController () = default;
	~SatuController () SMTG_OVERRIDE = default;

    // Create function
	static Steinberg::FUnknown* createInstance (void* /*context*/)
	{
		return (Steinberg::Vst::IEditController*)new SatuController;
	}

	// IPluginBase
	Steinberg::tresult PLUGIN_API initialize (Steinberg::FUnknown* context) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API terminate () SMTG_OVERRIDE;

	// EditController
	Steinberg::tresult PLUGIN_API setComponentState (Steinberg::IBStream* state) SMTG_OVERRIDE;
	Steinberg::IPlugView* PLUGIN_API createView (Steinberg::FIDString name) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API setState (Steinberg::IBStream* state) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API getState (Steinberg::IBStream* state) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API setParamNormalized (Steinberg::Vst::ParamID tag,
                                                      Steinberg::Vst::ParamValue value) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API getParamStringByValue (Steinberg::Vst::ParamID tag,
                                                         Steinberg::Vst::ParamValue valueNormalized,
                                                         Steinberg::Vst::String128 string) SMTG_OVERRIDE;
	Steinberg::tresult PLUGIN_API getParamValueByString (Steinberg::Vst::ParamID tag,
                                                         Steinberg::Vst::TChar* string,
                                                         Steinberg::Vst::ParamValue& valueNormalized) SMTG_OVERRIDE;

	VSTGUI::CView* verifyView(CView* view, const UIAttributes& attributes,
		const IUIDescription* description, VST3Editor* editor) override;

	//--- from IViewListenerAdapter ----------------------
	//--- is called when a view will be deleted: the editor is closed -----
	void viewWillDelete(VSTGUI::CView* view) override;

	//---from VST3EditorDelegate-----------
	IController* createSubController(UTF8StringPtr name, const IUIDescription* description,
		VST3Editor* editor) SMTG_OVERRIDE;

 	//---Interface---------
	DEFINE_INTERFACES
	END_DEFINE_INTERFACES (EditController)
    DELEGATE_REFCOUNT (EditController)

//------------------------------------------------------------------------
protected:
	
	SBN::GUIEditor* mGUIEditor = NULL;
};

//------------------------------------------------------------------------
} // namespace SBN

And in my Controller’s .cpp file I have

//------------------------------------------------------------------------
IPlugView* PLUGIN_API SatuController::createView(FIDString name)
{
	// Here the Host wants to open your editor (if you have one)
	if (FIDStringsEqual(name, Vst::ViewType::kEditor))
	{
		// create your editor here and return a IPlugView ptr of it
		auto* view = new SBN::GUIEditor(this, "view", "editor.uidesc");
		this->mGUIEditor = view;
		return view;
	}
	return nullptr;
}

Where the GUIEditor is my custom VSTGUI::VST3Editor that looks like this in the .h file

class GUIEditor : public VSTGUI::VST3Editor
	{
	public:
		using UTF8StringPtr = VSTGUI::UTF8StringPtr;
		using EditController = Steinberg::Vst::EditController;
		
		GUIEditor(EditController* controller, UTF8StringPtr templateName, UTF8StringPtr xmlFile) : VSTGUI::VST3Editor(controller, templateName, xmlFile)
		{

		}

		Steinberg::tresult PLUGIN_API canResize() override;
		Steinberg::tresult PLUGIN_API checkSizeConstraint(Steinberg::ViewRect* rect) override;
		Steinberg::tresult PLUGIN_API onSize(Steinberg::ViewRect* newSize) override;

		PluginGUI* mPluginGUI = NULL;
	};
}

And like this in the GUIEditor .cpp file

namespace SBN
{	
	Steinberg::tresult PLUGIN_API GUIEditor::canResize()
	{
		return Steinberg::kResultTrue;
	}
	Steinberg::tresult PLUGIN_API GUIEditor::checkSizeConstraint(Steinberg::ViewRect* rect)
	{
		return VSTGUIEditor::checkSizeConstraint(rect);
	}
	Steinberg::tresult PLUGIN_API GUIEditor::onSize(Steinberg::ViewRect* newSize)
	{
		return VSTGUIEditor::onSize(newSize);
	}
}

The problem here is if I set the canResize to true and change the size of the plugin window the whole window will not redraw and leave artifacts as lines from the border of the plugin window.
But if I set it to return false, everything looks like it should if I resize the plugin window, because Reaper allows the plugin window to be resized no matter if I set it to return false or true.

Why are there artifacts, ugly lines?

Thanks in advance

Most likely because there’s nothing that draws. You need to design your UI to adapt to the size change.

Hi

I see, so if I understands this right I must change the size of the parents also not just my custom CControl as I’m doing now, because my custom control are placed in a Container View and my Container View is in a root View.
Without making every parent view custom so that I can draw and set sizes just like I would like,
where do I set the sizes so that they will redraw, without access violation?
I would rather not make the parents custom just for this.

Thanks in advance

Edit: I made all the parents and all views to resize but that wasn’t enough, seems that I will need to make all of them custom to really understand what is going on…

Hello again Arne, I have just found out how to do it by looking at the SDK code for the VST3Editor.
Thanks for all the help :slightly_smiling_face:

1 Like