diff options
author | falkTX <falktx@gmail.com> | 2015-05-03 02:25:29 +0200 |
---|---|---|
committer | falkTX <falktx@gmail.com> | 2015-05-03 02:25:29 +0200 |
commit | c6789d1889cfdb9fef784f19ab452ff70723ffc2 (patch) | |
tree | f7299a7dd334a93f2bf4575d83093fcd3b41da85 /dgl/NanoVG.hpp | |
parent | 3a77a1144f4cb53ded4fb9194eded380bdfa9316 (diff) |
Very raw, preliminar subwidgets implementation
Diffstat (limited to 'dgl/NanoVG.hpp')
-rw-r--r-- | dgl/NanoVG.hpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/dgl/NanoVG.hpp b/dgl/NanoVG.hpp index 248251bc..e16396a5 100644 --- a/dgl/NanoVG.hpp +++ b/dgl/NanoVG.hpp @@ -296,6 +296,11 @@ public: NanoVG(int flags = CREATE_ANTIALIAS); /** + Constructor reusing a NanoVG context, used for subwidgets. + */ + NanoVG(NanoWidget* groupWidget); + + /** Destructor. */ virtual ~NanoVG(); @@ -838,6 +843,7 @@ public: private: NVGcontext* const fContext; bool fInFrame; + bool fIsSubWidget; DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG) }; @@ -860,7 +866,7 @@ public: Constructor. @see CreateFlags */ - NanoWidget(Window& parent, int flags = CREATE_ANTIALIAS) + explicit NanoWidget(Window& parent, int flags = CREATE_ANTIALIAS) : Widget(parent), NanoVG(flags), leakDetector_NanoWidget() @@ -868,6 +874,31 @@ public: setNeedsScaling(true); } + /** + Constructor for a subwidget. + */ + explicit NanoWidget(Widget* groupWidget, int flags = CREATE_ANTIALIAS) + : Widget(groupWidget, true), + NanoVG(flags), + leakDetector_NanoWidget() + { + setNeedsScaling(true); + } + + /** + Constructor for a subwidget. + */ + explicit NanoWidget(NanoWidget* groupWidget) + : Widget(groupWidget, false), + NanoVG(groupWidget), + leakDetector_NanoWidget() + { + setNeedsScaling(true); + groupWidget->fNanoSubWidgets.push_back(this); + } + + // fNanoSubWidgets.clear(); + protected: /** New virtual onDisplay function. @@ -876,6 +907,8 @@ protected: virtual void onNanoDisplay() = 0; private: + std::vector<NanoWidget*> fNanoSubWidgets; + /** Widget display function. Implemented internally to wrap begin/endFrame() automatically. @@ -884,6 +917,13 @@ private: { beginFrame(getWidth(), getHeight()); onNanoDisplay(); + + for (std::vector<NanoWidget*>::iterator it = fNanoSubWidgets.begin(); it != fNanoSubWidgets.end(); ++it) + { + NanoWidget* const widget(*it); + widget->onNanoDisplay(); + } + endFrame(); } |