Browse Source

Misc fixing; Add DISTRHO_UI_USE_NANOVG macro, for NanoVG plugin UIs

gh-pages
falkTX 8 years ago
parent
commit
d1f8cd904e
9 changed files with 50 additions and 20 deletions
  1. +1
    -0
      dgl/ImageSlider.hpp
  2. +3
    -2
      dgl/NanoVG.hpp
  3. +8
    -2
      dgl/StandaloneWindow.hpp
  4. +8
    -6
      dgl/Widget.hpp
  5. +3
    -3
      dgl/src/ImageSlider.cpp
  6. +5
    -5
      dgl/src/Widget.cpp
  7. +15
    -1
      distrho/DistrhoUI.hpp
  8. +4
    -0
      distrho/src/DistrhoPluginChecks.h
  9. +3
    -1
      distrho/src/DistrhoUI.cpp

+ 1
- 0
dgl/ImageSlider.hpp View File

@@ -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)
};


+ 3
- 2
dgl/NanoVG.hpp View File

@@ -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


+ 8
- 2
dgl/StandaloneWindow.hpp View File

@@ -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);
}



+ 8
- 6
dgl/Widget.hpp View File

@@ -159,12 +159,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.
*/
@@ -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;


+ 3
- 3
dgl/src/ImageSlider.cpp View File

@@ -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


+ 5
- 5
dgl/src/Widget.cpp View File

@@ -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

+ 15
- 1
distrho/DistrhoUI.hpp View File

@@ -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)
};



+ 4
- 0
distrho/src/DistrhoPluginChecks.h View File

@@ -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

+ 3
- 1
distrho/src/DistrhoUI.cpp View File

@@ -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()


Loading…
Cancel
Save