commit d1f8cd904eec3aa36093d2933165622b901a5b8b
parent 568b765007958ba86bed1553b7f34dcc1bb2ed3f
Author: falkTX <falktx@gmail.com>
Date: Sun, 25 May 2014 21:55:40 +0100
Misc fixing; Add DISTRHO_UI_USE_NANOVG macro, for NanoVG plugin UIs
Diffstat:
9 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/dgl/ImageSlider.hpp b/dgl/ImageSlider.hpp
@@ -89,6 +89,7 @@ private:
void setAbsoluteY(int) const noexcept {}
void setAbsolutePos(int, int) const noexcept {}
void setAbsolutePos(const Point<int>&) const noexcept {}
+ void setNeedsFullViewport(bool) const noexcept {}
DISTRHO_LEAK_DETECTOR(ImageSlider)
};
diff --git a/dgl/NanoVG.hpp b/dgl/NanoVG.hpp
@@ -770,7 +770,7 @@ public:
int textBreakLines(const char* string, const char* end, float breakRowWidth, TextRow* rows, int maxRows);
private:
- NVGcontext* fContext;
+ NVGcontext* const fContext;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG)
};
@@ -782,7 +782,8 @@ private:
NanoVG Widget class.
This class implements the NanoVG drawing API inside a DGL Widget.
- onDisplay is implemented internally.
+ The drawing function onDisplay() is implemented internally but a
+ new onNanoDisplay() needs to be overridden instead.
*/
class NanoWidget : public Widget,
public NanoVG
diff --git a/dgl/StandaloneWindow.hpp b/dgl/StandaloneWindow.hpp
@@ -51,17 +51,23 @@ protected:
private:
Widget* fWidget;
- void _addWidget(Widget* const widget) override
+ void _addWidget(Widget* widget) override
{
if (fWidget == nullptr)
+ {
fWidget = widget;
+ fWidget->setNeedsFullViewport(true);
+ }
Window::_addWidget(widget);
}
- void _removeWidget(Widget* const widget) override
+ void _removeWidget(Widget* widget) override
{
if (fWidget == widget)
+ {
+ fWidget->setNeedsFullViewport(false);
fWidget = nullptr;
+ }
Window::_removeWidget(widget);
}
diff --git a/dgl/Widget.hpp b/dgl/Widget.hpp
@@ -160,12 +160,6 @@ public:
void hide();
/**
- Tell the parent window this widget this the full viewport.
- When enabled, the local widget coordinates are ignored.
- */
- void setNeedsFullViewport(bool yesNo) noexcept;
-
- /**
Get width.
*/
int getWidth() const noexcept;
@@ -302,6 +296,14 @@ protected:
*/
virtual void onResize(const ResizeEvent&);
+ /**
+ Tell the parent window this widget this the full viewport.
+ When enabled, the local widget coordinates are ignored.
+ @note: This is an internal function;
+ You do not need it under normal circumstances.
+ */
+ void setNeedsFullViewport(bool yesNo) noexcept;
+
private:
Window& fParent;
bool fNeedsFullViewport;
diff --git a/dgl/src/ImageSlider.cpp b/dgl/src/ImageSlider.cpp
@@ -37,7 +37,7 @@ ImageSlider::ImageSlider(Window& parent, const Image& image, int id) noexcept
fStartedY(0),
fCallback(nullptr)
{
- setNeedsFullViewport(true);
+ Widget::setNeedsFullViewport(true);
}
ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept
@@ -55,7 +55,7 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept
fStartedY(0),
fCallback(nullptr)
{
- setNeedsFullViewport(true);
+ Widget::setNeedsFullViewport(true);
}
ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept
@@ -76,7 +76,7 @@ ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept
fEndPos(imageSlider.fEndPos),
fSliderArea(imageSlider.fSliderArea)
{
- setNeedsFullViewport(true);
+ Widget::setNeedsFullViewport(true);
}
int ImageSlider::getId() const noexcept
diff --git a/dgl/src/Widget.cpp b/dgl/src/Widget.cpp
@@ -59,11 +59,6 @@ void Widget::hide()
setVisible(false);
}
-void Widget::setNeedsFullViewport(bool yesNo) noexcept
-{
- fNeedsFullViewport = yesNo;
-}
-
int Widget::getWidth() const noexcept
{
return fArea.getWidth();
@@ -230,6 +225,11 @@ void Widget::onResize(const ResizeEvent&)
{
}
+void Widget::setNeedsFullViewport(bool yesNo) noexcept
+{
+ fNeedsFullViewport = yesNo;
+}
+
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp
@@ -22,12 +22,19 @@
#include "../dgl/Widget.hpp"
+#if DISTRHO_UI_USE_NANOVG
+# include "../dgl/NanoVG.hpp"
+typedef DGL::NanoWidget UIWidget;
+#else
+typedef DGL::Widget UIWidget;
+#endif
+
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
// UI
-class UI : public DGL::Widget
+class UI : public UIWidget
{
public:
UI();
@@ -91,6 +98,13 @@ private:
friend class UIExporter;
friend class UIExporterWindow;
+ // these should not be used
+ void setAbsoluteX(int) const noexcept {}
+ void setAbsoluteY(int) const noexcept {}
+ void setAbsolutePos(int, int) const noexcept {}
+ void setAbsolutePos(const DGL::Point<int>&) const noexcept {}
+ void setNeedsFullViewport(bool) const noexcept {}
+
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI)
};
diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h
@@ -63,6 +63,10 @@
# define DISTRHO_PLUGIN_IS_RT_SAFE 1
#endif
+#ifndef DISTRHO_UI_USE_NANOVG
+# define DISTRHO_UI_USE_NANOVG 0
+#endif
+
#define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"
#endif // DISTRHO_PLUGIN_CHECKS_H_INCLUDED
diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp
@@ -31,12 +31,14 @@ double d_lastUiSampleRate = 0.0;
// UI
UI::UI()
- : DGL::Widget(*DGL::dgl_lastUiParent),
+ : UIWidget(*DGL::dgl_lastUiParent),
pData(new PrivateData())
{
DISTRHO_SAFE_ASSERT(DGL::dgl_lastUiParent != nullptr);
DGL::dgl_lastUiParent = nullptr;
+
+ Widget::setNeedsFullViewport(true);
}
UI::~UI()