21#include <vstgui4/vstgui/lib/iviewlistener.h>
22#include <vstgui4/vstgui/lib/cview.h>
23#include <pongasoft/logging/logging.h>
27using namespace VSTGUI;
99 template<
typename T,
typename ...Args>
100 static std::shared_ptr<T>
create(CView *iView, Args&& ...iArgs)
103 static_assert(std::is_convertible<T *, SelfContainedViewListener*>::value,
"T must be a subclass of SelfContainedViewListener");
105 auto res = std::make_shared<T>(std::forward<Args>(iArgs)...);
106 res->registerView(iView);
119 fView->unregisterViewListener(
this);
135 virtual std::shared_ptr<SelfContainedViewListener>
registerView(CView *iView)
137 DCHECK_F(iView !=
nullptr);
143 fView->registerViewListener(
this);
144 fThis = shared_from_this();
157 DCHECK_F(iView ==
fView);
163 std::shared_ptr<SelfContainedViewListener>
fThis{};
static std::shared_ptr< T > create(CView *iView, Args &&...iArgs)
This is the main method that should be used to create an instance of this class.
Definition SelfContainedViewListener.h:100
SelfContainedViewListener()=default
The constructor which unfortunately has to be declared public for the purpose of a creating a shared ...
CView * fView
Definition SelfContainedViewListener.h:164
virtual std::shared_ptr< SelfContainedViewListener > registerView(CView *iView)
Registers this class as a view listener.
Definition SelfContainedViewListener.h:135
void viewWillDelete(CView *iView) override
Called by the view itself when it is going to be deleted.
Definition SelfContainedViewListener.h:155
virtual void unregister()
You can call this method at anytime to unregister this class as the listener to the view that was pre...
Definition SelfContainedViewListener.h:115
std::shared_ptr< SelfContainedViewListener > fThis
Definition SelfContainedViewListener.h:163
Definition CustomController.h:25