View Single Post
Old 09-06-2020, 02:23 AM   #15
Human being with feelings
stw's Avatar
Join Date: Apr 2012
Posts: 263

Yes, this very likely seems to be the root of your problem. IMHO it's not a good idea to trigger drawings that way.
For controls that need a regular draw update i have a dedicated control that triggers all drawings on the GUI thread (similar to your IControl approach - mDirty always true, but only for that 'trigger' control) thru a function pointer. So only the added controls inside that function are redrawed at fps rate.
Implementation here looks like this:
// Trigger Control Template in my ctrls.h

template <class T>
class DrawDummy : public IControl
	typedef void (T::*void_Ptr)();
	void_Ptr voidPtr;
	T   *parent;
	DrawDummy(IPlugBase *pPlug)
	: IControl(pPlug, IRECT(0,0,0,0)){}
	void setPtr(T *_Parent, void (T::*f)())
		voidPtr = f;
		parent = _Parent;
	bool IsDirty()
		return true;
	bool Draw(IGraphics* pGraphics) { return true;};
Attach and set drawing function in the GUI init section:
pGraphics->AttachControl(MyDrawdummy = new DrawDummy<MyPlug>(this));
MyDrawdummy->setPtr(this, &MyPlug::DoGraphics);
and then doing all the drawing stuff inside the DoGraphics function:
void MyPlug::DoGraphics()

Maybe you can try it this way.
stw is offline   Reply With Quote