| @@ -20,7 +20,6 @@ | |||
| #include "ImageBase.hpp" | |||
| #include "ImageBaseWidgets.hpp" | |||
| #include "SubWidget.hpp" | |||
| #include "TopLevelWidget.hpp" | |||
| #include <cairo/cairo.h> | |||
| @@ -86,49 +85,66 @@ public: | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| /** | |||
| Cairo SubWidget, handy class that takes graphics context during onDisplay and passes it in a new function. | |||
| CairoWidget, handy class that takes graphics context during onDisplay and passes it in a new function. | |||
| */ | |||
| class CairoSubWidget : public SubWidget | |||
| template <class BaseWidget> | |||
| class CairoWidget : public BaseWidget | |||
| { | |||
| public: | |||
| CairoSubWidget(Widget* widgetToGroupTo) | |||
| : SubWidget(widgetToGroupTo) {} | |||
| protected: | |||
| void onDisplay() override | |||
| { | |||
| const CairoGraphicsContext& context((const CairoGraphicsContext&)getGraphicsContext()); | |||
| onCairoDisplay(context); | |||
| } | |||
| /** | |||
| Constructor for a CairoSubWidget. | |||
| @see CreateFlags | |||
| */ | |||
| explicit CairoWidget(Widget* const parentGroupWidget); | |||
| virtual void onCairoDisplay(const CairoGraphicsContext& context) = 0; | |||
| /** | |||
| Constructor for a CairoTopLevelWidget. | |||
| @see CreateFlags | |||
| */ | |||
| explicit CairoWidget(Window& windowToMapTo); | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoSubWidget); | |||
| }; | |||
| /** | |||
| Constructor for a CairoStandaloneWindow without parent window. | |||
| @see CreateFlags | |||
| */ | |||
| explicit CairoWidget(Application& app); | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| /** | |||
| Constructor for a CairoStandaloneWindow with parent window. | |||
| @see CreateFlags | |||
| */ | |||
| explicit CairoWidget(Application& app, Window& parentWindow); | |||
| /** | |||
| Cairo TopLevelWidget, handy class that takes graphics context during onDisplay and passes it in a new function. | |||
| */ | |||
| class CairoTopLevelWidget : public TopLevelWidget | |||
| { | |||
| public: | |||
| CairoTopLevelWidget(Window& windowToMapTo) | |||
| : TopLevelWidget(windowToMapTo) {} | |||
| /** | |||
| Destructor. | |||
| */ | |||
| virtual ~CairoWidget() {} | |||
| protected: | |||
| /** | |||
| New virtual onDisplay function. | |||
| @see onDisplay | |||
| */ | |||
| virtual void onCairoDisplay(const CairoGraphicsContext& context) = 0; | |||
| private: | |||
| /** | |||
| Widget display function. | |||
| Implemented internally to wrap begin/endFrame() automatically. | |||
| */ | |||
| void onDisplay() override | |||
| { | |||
| const CairoGraphicsContext& context((const CairoGraphicsContext&)getGraphicsContext()); | |||
| const CairoGraphicsContext& context((const CairoGraphicsContext&)BaseWidget::getGraphicsContext()); | |||
| onCairoDisplay(context); | |||
| } | |||
| virtual void onCairoDisplay(const CairoGraphicsContext& context) = 0; | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoTopLevelWidget); | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoWidget); | |||
| }; | |||
| typedef CairoWidget<SubWidget> CairoSubWidget; | |||
| typedef CairoWidget<TopLevelWidget> CairoTopLevelWidget; | |||
| typedef CairoWidget<StandaloneWindow> CairoStandaloneWindow; | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| typedef ImageBaseAboutWindow<CairoImage> CairoImageAboutWindow; | |||
| @@ -895,11 +895,17 @@ public: | |||
| explicit NanoWidget(Window& windowToMapTo, int flags = CREATE_ANTIALIAS); | |||
| /** | |||
| Constructor for a NanoStandaloneWindow. | |||
| Constructor for a NanoStandaloneWindow without parent window. | |||
| @see CreateFlags | |||
| */ | |||
| explicit NanoWidget(Application& app, int flags = CREATE_ANTIALIAS); | |||
| /** | |||
| Constructor for a NanoStandaloneWindow with parent window. | |||
| @see CreateFlags | |||
| */ | |||
| explicit NanoWidget(Application& app, Window& parentWindow, int flags = CREATE_ANTIALIAS); | |||
| /** | |||
| Destructor. | |||
| */ | |||
| @@ -38,8 +38,8 @@ public: | |||
| /** | |||
| Constructor with parent window, typically used to run as modal. | |||
| */ | |||
| StandaloneWindow(Application& app, Window& parent) | |||
| : Window(app, parent), | |||
| StandaloneWindow(Application& app, Window& parentWindow) | |||
| : Window(app, parentWindow), | |||
| TopLevelWidget((Window&)*this) {} | |||
| /** | |||
| @@ -144,6 +144,37 @@ void CairoImage::drawAt(const GraphicsContext&, const Point<int>&) | |||
| { | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // CairoSubWidget | |||
| template <> | |||
| CairoWidget<SubWidget>::CairoWidget(Widget* const parent) | |||
| : SubWidget(parent) {} | |||
| template class CairoWidget<SubWidget>; | |||
| // ----------------------------------------------------------------------- | |||
| // CairoTopLevelWidget | |||
| template <> | |||
| CairoWidget<TopLevelWidget>::CairoWidget(Window& windowToMapTo) | |||
| : TopLevelWidget(windowToMapTo) {} | |||
| template class CairoWidget<TopLevelWidget>; | |||
| // ----------------------------------------------------------------------- | |||
| // CairoStandaloneWindow | |||
| template <> | |||
| CairoWidget<StandaloneWindow>::CairoWidget(Application& app) | |||
| : StandaloneWindow(app) {} | |||
| template <> | |||
| CairoWidget<StandaloneWindow>::CairoWidget(Application& app, Window& parentWindow) | |||
| : StandaloneWindow(app, parentWindow) {} | |||
| template class CairoWidget<StandaloneWindow>; | |||
| // ----------------------------------------------------------------------- | |||
| template <> | |||
| @@ -943,7 +943,7 @@ bool NanoVG::loadSharedResources() | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // SubWidget | |||
| // NanoSubWidget | |||
| template <> | |||
| NanoWidget<SubWidget>::NanoWidget(Widget* const parent, int flags) | |||
| @@ -956,26 +956,27 @@ NanoWidget<SubWidget>::NanoWidget(Widget* const parent, int flags) | |||
| template class NanoWidget<SubWidget>; | |||
| // ----------------------------------------------------------------------- | |||
| // TopLevelWidget | |||
| // NanoTopLevelWidget | |||
| template <> | |||
| NanoWidget<TopLevelWidget>::NanoWidget(Window& windowToMapTo, int flags) | |||
| : TopLevelWidget(windowToMapTo), | |||
| NanoVG(flags) | |||
| { | |||
| } | |||
| NanoVG(flags) {} | |||
| template class NanoWidget<TopLevelWidget>; | |||
| // ----------------------------------------------------------------------- | |||
| // StandaloneWindow | |||
| // NanoStandaloneWindow | |||
| template <> | |||
| NanoWidget<StandaloneWindow>::NanoWidget(Application& app, int flags) | |||
| : StandaloneWindow(app), | |||
| NanoVG(flags) | |||
| { | |||
| } | |||
| NanoVG(flags) {} | |||
| template <> | |||
| NanoWidget<StandaloneWindow>::NanoWidget(Application& app, Window& parentWindow, int flags) | |||
| : StandaloneWindow(app, parentWindow), | |||
| NanoVG(flags) {} | |||
| template class NanoWidget<StandaloneWindow>; | |||