commit 11837263c53025f1d0992b4c54b4ff573eccd0e6
parent d7382324edbe5e24db5a5ad327e292e999d8c16c
Author: falkTX <falktx@falktx.com>
Date: Sun, 30 May 2021 00:03:24 +0100
Allow subwidgets to skip drawing entirely
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
6 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dgl/NanoVG.hpp b/dgl/NanoVG.hpp
@@ -35,7 +35,6 @@ START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names
-class BlendishWidget;
class NanoVG;
// -----------------------------------------------------------------------
@@ -862,7 +861,6 @@ private:
NVGcontext* const fContext;
bool fInFrame;
bool fIsSubWidget;
- friend class BlendishWidget;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG)
};
diff --git a/dgl/SubWidget.hpp b/dgl/SubWidget.hpp
@@ -126,6 +126,11 @@ public:
*/
void setNeedsFullViewportDrawing(bool needsFullViewportForDrawing = true);
+ /**
+ Indicate that this subwidget should not be drawn on screen, typically because it is managed by something else.
+ */
+ void setSkipDrawing(bool skipDrawing = true);
+
protected:
/**
A function called when the subwidget's absolute position is changed.
diff --git a/dgl/src/OpenGL.cpp b/dgl/src/OpenGL.cpp
@@ -570,6 +570,9 @@ template class ImageBaseSwitch<OpenGLImage>;
void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
{
+ if (skipDrawing)
+ return;
+
bool needsDisableScissor = false;
if (needsFullViewportForDrawing || (absolutePos.isZero() && self->getSize() == Size<uint>(width, height)))
diff --git a/dgl/src/SubWidget.cpp b/dgl/src/SubWidget.cpp
@@ -123,6 +123,11 @@ void SubWidget::setNeedsFullViewportDrawing(const bool needsFullViewportForDrawi
pData->needsFullViewportForDrawing = needsFullViewportForDrawing;
}
+void SubWidget::setSkipDrawing(const bool skipDrawing)
+{
+ pData->skipDrawing = skipDrawing;
+}
+
void SubWidget::onPositionChanged(const PositionChangedEvent&)
{
}
diff --git a/dgl/src/SubWidgetPrivateData.cpp b/dgl/src/SubWidgetPrivateData.cpp
@@ -27,7 +27,8 @@ SubWidget::PrivateData::PrivateData(SubWidget* const s, Widget* const pw)
parentWidget(pw),
absolutePos(),
needsFullViewportForDrawing(false),
- needsViewportScaling(false)
+ needsViewportScaling(false),
+ skipDrawing(false)
{
parentWidget->pData->subWidgets.push_back(self);
}
diff --git a/dgl/src/SubWidgetPrivateData.hpp b/dgl/src/SubWidgetPrivateData.hpp
@@ -30,6 +30,7 @@ struct SubWidget::PrivateData {
Point<int> absolutePos;
bool needsFullViewportForDrawing; // needed for widgets drawing out of bounds
bool needsViewportScaling; // needed for NanoVG
+ bool skipDrawing;
explicit PrivateData(SubWidget* const s, Widget* const pw);
~PrivateData();