summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@gmail.com>2015-02-16 15:30:56 +0000
committerfalkTX <falktx@gmail.com>2015-02-16 15:30:56 +0000
commit9baf523196128b5c847a578d93b4e71cabdacaa6 (patch)
tree46a2c61a41940eb7de5c96923a2c33e54112ee6e
parent79b8c6215b6d057fd5b667a02cc7cb9975ad72da (diff)
Update distrho libs
This removes the NTK specific code, now a separate project. Misc cleanup and fixes.
-rw-r--r--libs/distrho/DistrhoUI.hpp22
-rw-r--r--libs/distrho/DistrhoUIMain.cpp25
-rw-r--r--libs/distrho/DistrhoUtils.hpp87
-rw-r--r--libs/distrho/src/DistrhoDefines.h18
-rw-r--r--libs/distrho/src/DistrhoPluginCarla.cpp58
-rw-r--r--libs/distrho/src/DistrhoPluginChecks.h4
-rw-r--r--libs/distrho/src/DistrhoPluginInternal.hpp4
-rw-r--r--libs/distrho/src/DistrhoPluginVST.cpp23
-rw-r--r--libs/distrho/src/DistrhoUI.cpp20
-rw-r--r--libs/distrho/src/DistrhoUIInternal.hpp69
-rw-r--r--libs/distrho/src/DistrhoUILV2.cpp18
11 files changed, 179 insertions, 169 deletions
diff --git a/libs/distrho/DistrhoUI.hpp b/libs/distrho/DistrhoUI.hpp
index b6b2402..e6c8311 100644
--- a/libs/distrho/DistrhoUI.hpp
+++ b/libs/distrho/DistrhoUI.hpp
@@ -20,13 +20,10 @@
#include "extra/d_leakdetector.hpp"
#include "src/DistrhoPluginChecks.h"
-#if DISTRHO_UI_USE_NTK
-# include "../dgl/ntk/NtkWidget.hpp"
-typedef DGL::NtkWidget UIWidget;
-#elif DISTRHO_UI_USE_NANOVG
+#if DISTRHO_UI_USE_NANOVG
# include "../dgl/NanoVG.hpp"
typedef DGL::NanoWidget UIWidget;
-# else
+#else
# include "../dgl/Widget.hpp"
typedef DGL::Widget UIWidget;
#endif
@@ -143,32 +140,22 @@ protected:
*/
virtual void d_uiIdle() {}
-#if ! DISTRHO_UI_USE_NTK
/**
OpenGL window reshape function, called when parent window is resized.
You can reimplement this function for a custom OpenGL state.
@see Window::onReshape(uint,uint)
*/
virtual void d_uiReshape(uint width, uint height);
-#endif
/* --------------------------------------------------------------------------------------------------------
* UI Resize Handling, internal */
-#if DISTRHO_UI_USE_NTK
- /**
- NTK widget resize function, called when the widget is resized.
- This is overriden here so the host knows when the UI is resized by you.
- */
- void resize(int x, int y, int w, int h) override;
-#else
/**
OpenGL widget resize function, called when the widget is resized.
This is overriden here so the host knows when the UI is resized by you.
@see Widget::onResize(const ResizeEvent&)
*/
void onResize(const ResizeEvent& ev) override;
-#endif
// -------------------------------------------------------------------------------------------------------
@@ -179,14 +166,11 @@ private:
friend class UIExporterWindow;
// these should not be used
- void position(int, int) noexcept {}
void setAbsoluteX(int) const noexcept {}
void setAbsoluteY(int) const noexcept {}
void setAbsolutePos(int, int) const noexcept {}
- void setNeedsFullViewport(bool) const noexcept {}
-#if ! DISTRHO_UI_USE_NTK
void setAbsolutePos(const DGL::Point<int>&) const noexcept {}
-#endif
+ void setNeedsFullViewport(bool) const noexcept {}
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI)
};
diff --git a/libs/distrho/DistrhoUIMain.cpp b/libs/distrho/DistrhoUIMain.cpp
index 3bc0971..cb1cb6e 100644
--- a/libs/distrho/DistrhoUIMain.cpp
+++ b/libs/distrho/DistrhoUIMain.cpp
@@ -27,28 +27,3 @@
#elif defined(DISTRHO_PLUGIN_TARGET_VST)
// nothing
#endif
-
-#ifdef DGL_NTK_APP_HPP_INCLUDED
-
-START_NAMESPACE_DGL
-
-void NtkApp::NextUI::run()
-{
- if (create)
- {
- d_stdout("Creating NTK UI in separate thread...");
- d_UI* const ui2 = (func)();
- ui = ui2;
- }
- else
- {
- d_stdout("Destroying NTK UI in separate thread...");
- d_UI* const ui2 = ui;
- ui = nullptr;
- delete ui2;
- }
-}
-
-END_NAMESPACE_DGL
-
-#endif
diff --git a/libs/distrho/DistrhoUtils.hpp b/libs/distrho/DistrhoUtils.hpp
index 2dd4195..b1391ef 100644
--- a/libs/distrho/DistrhoUtils.hpp
+++ b/libs/distrho/DistrhoUtils.hpp
@@ -24,6 +24,9 @@
#include <cstdlib>
#include <cstring>
+#include <cmath>
+#include <limits>
+
#ifdef DISTRHO_PROPER_CPP11_SUPPORT
# include <cstdint>
#else
@@ -32,17 +35,13 @@
#if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC)
namespace std {
-inline float
- fmin(float __x, float __y)
+inline float fmin(float __x, float __y)
{ return __builtin_fminf(__x, __y); }
-inline float
- fmax(float __x, float __y)
+inline float fmax(float __x, float __y)
{ return __builtin_fmaxf(__x, __y); }
-inline float
- rint(float __x)
+inline float rint(float __x)
{ return __builtin_rintf(__x); }
-inline float
- round(float __x)
+inline float round(float __x)
{ return __builtin_roundf(__x); }
}
#endif
@@ -50,18 +49,28 @@ inline float
// -----------------------------------------------------------------------
// misc functions
+/*
+ * Return a 64-bit number from 4 8-bit numbers.
+ */
static inline
-int64_t d_cconst(const int a, const int b, const int c, const int d) noexcept
+int64_t d_cconst(const uint8_t a, const uint8_t b, const uint8_t c, const uint8_t d) noexcept
{
return (a << 24) | (b << 16) | (c << 8) | (d << 0);
}
+/*
+ * Dummy function.
+ */
static inline
void d_pass() noexcept {}
// -----------------------------------------------------------------------
// string print functions
+/*
+ * Print a string to stdout with newline (gray color).
+ * Does nothing if DEBUG is not defined.
+ */
#ifndef DEBUG
# define d_debug(...)
#else
@@ -79,6 +88,9 @@ void d_debug(const char* const fmt, ...) noexcept
}
#endif
+/*
+ * Print a string to stdout with newline.
+ */
static inline
void d_stdout(const char* const fmt, ...) noexcept
{
@@ -91,6 +103,9 @@ void d_stdout(const char* const fmt, ...) noexcept
} catch (...) {}
}
+/*
+ * Print a string to stderr with newline.
+ */
static inline
void d_stderr(const char* const fmt, ...) noexcept
{
@@ -103,6 +118,9 @@ void d_stderr(const char* const fmt, ...) noexcept
} catch (...) {}
}
+/*
+ * Print a string to stderr with newline (red color).
+ */
static inline
void d_stderr2(const char* const fmt, ...) noexcept
{
@@ -116,12 +134,18 @@ void d_stderr2(const char* const fmt, ...) noexcept
} catch (...) {}
}
+/*
+ * Print a safe assertion error message.
+ */
static inline
void d_safe_assert(const char* const assertion, const char* const file, const int line) noexcept
{
d_stderr2("assertion failure: \"%s\" in file %s, line %i", assertion, file, line);
}
+/*
+ * Print a safe exception error message.
+ */
static inline
void d_safe_exception(const char* const exception, const char* const file, const int line) noexcept
{
@@ -129,5 +153,50 @@ void d_safe_exception(const char* const exception, const char* const file, const
}
// -----------------------------------------------------------------------
+// math functions
+
+/*
+ * Safely compare two floating point numbers.
+ * Returns true if they match.
+ */
+template<typename T>
+static inline
+bool d_isEqual(const T& v1, const T& v2)
+{
+ return std::abs(v1-v2) < std::numeric_limits<T>::epsilon();
+}
+
+/*
+ * Safely compare two floating point numbers.
+ * Returns true if they don't match.
+ */
+template<typename T>
+static inline
+bool d_isNotEqual(const T& v1, const T& v2)
+{
+ return std::abs(v1-v2) >= std::numeric_limits<T>::epsilon();
+}
+
+/*
+ * Safely check if a floating point number is zero.
+ */
+template<typename T>
+static inline
+bool d_isZero(const T& value)
+{
+ return std::abs(value) < std::numeric_limits<T>::epsilon();
+}
+
+/*
+ * Safely check if a floating point number is not zero.
+ */
+template<typename T>
+static inline
+bool d_isNotZero(const T& value)
+{
+ return std::abs(value) >= std::numeric_limits<T>::epsilon();
+}
+
+// -----------------------------------------------------------------------
#endif // DISTRHO_UTILS_HPP_INCLUDED
diff --git a/libs/distrho/src/DistrhoDefines.h b/libs/distrho/src/DistrhoDefines.h
index 501fc28..59e4c34 100644
--- a/libs/distrho/src/DistrhoDefines.h
+++ b/libs/distrho/src/DistrhoDefines.h
@@ -118,23 +118,17 @@ private: \
#endif
/* Define namespace */
-#ifndef DISTRHO_NO_NAMESPACE
-# ifndef DISTRHO_NAMESPACE
-# define DISTRHO_NAMESPACE DISTRHO
-# endif
-# define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
-# define END_NAMESPACE_DISTRHO }
-# define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
-#else
-# define START_NAMESPACE_DISTRHO
-# define END_NAMESPACE_DISTRHO
-# define USE_NAMESPACE_DISTRHO
+#ifndef DISTRHO_NAMESPACE
+# define DISTRHO_NAMESPACE DISTRHO
#endif
+#define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
+#define END_NAMESPACE_DISTRHO }
+#define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
/* Useful typedefs */
typedef unsigned char uchar;
-typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
+typedef unsigned long int ulong;
#endif // DISTRHO_DEFINES_H_INCLUDED
diff --git a/libs/distrho/src/DistrhoPluginCarla.cpp b/libs/distrho/src/DistrhoPluginCarla.cpp
index 3ba0b11..1f0a75e 100644
--- a/libs/distrho/src/DistrhoPluginCarla.cpp
+++ b/libs/distrho/src/DistrhoPluginCarla.cpp
@@ -45,22 +45,27 @@ public:
fPlugin(plugin),
fUI(this, 0, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, plugin->getInstancePointer())
{
- fUI.setTitle(host->uiName);
+ fUI.setWindowTitle(host->uiName);
if (host->uiParentId != 0)
- fUI.setTransientWinId(host->uiParentId);
+ fUI.setWindowTransientWinId(host->uiParentId);
+ }
+
+ ~UICarla()
+ {
+ fUI.quit();
}
// ---------------------------------------------
void carla_show(const bool yesNo)
{
- fUI.setVisible(yesNo);
+ fUI.setWindowVisible(yesNo);
}
- void carla_idle()
+ bool carla_idle()
{
- fUI.idle();
+ return fUI.idle();
}
void carla_setParameterValue(const uint32_t index, const float value)
@@ -84,7 +89,7 @@ public:
void carla_setUiTitle(const char* const uiTitle)
{
- fUI.setTitle(uiTitle);
+ fUI.setWindowTitle(uiTitle);
}
// ---------------------------------------------
@@ -112,7 +117,7 @@ protected:
void handleSetSize(const uint width, const uint height)
{
- fUI.setSize(width, height);
+ fUI.setWindowSize(width, height);
}
// ---------------------------------------------
@@ -205,25 +210,23 @@ protected:
static NativeParameter param;
- // reset
- param.hints = ::PARAMETER_IS_ENABLED;
param.scalePointCount = 0;
param.scalePoints = nullptr;
{
- int nativeParamHints = ::PARAMETER_IS_ENABLED;
+ int nativeParamHints = ::NATIVE_PARAMETER_IS_ENABLED;
const uint32_t paramHints = fPlugin.getParameterHints(index);
if (paramHints & kParameterIsAutomable)
- nativeParamHints |= ::PARAMETER_IS_AUTOMABLE;
+ nativeParamHints |= ::NATIVE_PARAMETER_IS_AUTOMABLE;
if (paramHints & kParameterIsBoolean)
- nativeParamHints |= ::PARAMETER_IS_BOOLEAN;
+ nativeParamHints |= ::NATIVE_PARAMETER_IS_BOOLEAN;
if (paramHints & kParameterIsInteger)
- nativeParamHints |= ::PARAMETER_IS_INTEGER;
+ nativeParamHints |= ::NATIVE_PARAMETER_IS_INTEGER;
if (paramHints & kParameterIsLogarithmic)
- nativeParamHints |= ::PARAMETER_IS_LOGARITHMIC;
+ nativeParamHints |= ::NATIVE_PARAMETER_IS_LOGARITHMIC;
if (paramHints & kParameterIsOutput)
- nativeParamHints |= ::PARAMETER_IS_OUTPUT;
+ nativeParamHints |= ::NATIVE_PARAMETER_IS_OUTPUT;
param.hints = static_cast<NativeParameterHints>(nativeParamHints);
}
@@ -329,7 +332,13 @@ protected:
realMidiEvent.frame = midiEvent.time;
realMidiEvent.size = midiEvent.size;
- carla_copy<uint8_t>(realMidiEvent.buf, midiEvent.data, midiEvent.size);
+ uint8_t j=0;
+ for (; j<midiEvent.size; ++j)
+ realMidiEvent.data[j] = midiEvent.data[j];
+ for (; j<midiEvent.size; ++j)
+ realMidiEvent.data[j] = midiEvent.data[j];
+
+ realMidiEvent.dataExt = nullptr;
}
fPlugin.run(const_cast<const float**>(inBuffer), outBuffer, frames, realMidiEvents, midiEventCount);
@@ -348,17 +357,30 @@ protected:
void uiShow(const bool show) override
{
if (show)
+ {
createUiIfNeeded();
+ CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,);
- if (fUiPtr != nullptr)
fUiPtr->carla_show(show);
+ }
+ else if (fUiPtr != nullptr)
+ {
+ delete fUiPtr;
+ fUiPtr = nullptr;
+ }
}
void uiIdle() override
{
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,);
- fUiPtr->carla_idle();
+ if (! fUiPtr->carla_idle())
+ {
+ uiClosed();
+
+ delete fUiPtr;
+ fUiPtr = nullptr;
+ }
}
void uiSetParameterValue(const uint32_t index, const float value) override
diff --git a/libs/distrho/src/DistrhoPluginChecks.h b/libs/distrho/src/DistrhoPluginChecks.h
index f556c06..16d6b43 100644
--- a/libs/distrho/src/DistrhoPluginChecks.h
+++ b/libs/distrho/src/DistrhoPluginChecks.h
@@ -93,10 +93,6 @@
# define DISTRHO_UI_USE_NANOVG 0
#endif
-#ifndef DISTRHO_UI_USE_NTK
-# define DISTRHO_UI_USE_NTK 0
-#endif
-
// -----------------------------------------------------------------------
// Define DISTRHO_UI_URI if needed
diff --git a/libs/distrho/src/DistrhoPluginInternal.hpp b/libs/distrho/src/DistrhoPluginInternal.hpp
index 7b4c04b..e9e2e23 100644
--- a/libs/distrho/src/DistrhoPluginInternal.hpp
+++ b/libs/distrho/src/DistrhoPluginInternal.hpp
@@ -83,7 +83,7 @@ struct Plugin::PrivateData {
sampleRate(d_lastSampleRate)
{
DISTRHO_SAFE_ASSERT(bufferSize != 0);
- DISTRHO_SAFE_ASSERT(sampleRate != 0.0);
+ DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));
}
~PrivateData() noexcept
@@ -433,7 +433,7 @@ public:
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,);
DISTRHO_SAFE_ASSERT(sampleRate > 0.0);
- if (fData->sampleRate == sampleRate)
+ if (d_isEqual(fData->sampleRate, sampleRate))
return;
fData->sampleRate = sampleRate;
diff --git a/libs/distrho/src/DistrhoPluginVST.cpp b/libs/distrho/src/DistrhoPluginVST.cpp
index 703ad79..57ea038 100644
--- a/libs/distrho/src/DistrhoPluginVST.cpp
+++ b/libs/distrho/src/DistrhoPluginVST.cpp
@@ -270,7 +270,7 @@ public:
: fAudioMaster(audioMaster),
fEffect(effect)
{
- std::memset(fProgramName, 0, sizeof(char)*(64+1));
+ std::memset(fProgramName, 0, sizeof(char)*(32+1));
std::strcpy(fProgramName, "Default");
#if DISTRHO_PLUGIN_HAS_MIDI_INPUT
@@ -339,7 +339,7 @@ public:
case effSetProgramName:
if (char* const programName = (char*)ptr)
{
- DISTRHO::strncpy(fProgramName, programName, 64);
+ DISTRHO::strncpy(fProgramName, programName, 32);
return 1;
}
break;
@@ -371,8 +371,10 @@ public:
case effSetSampleRate:
fPlugin.setSampleRate(opt, true);
+#if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr)
fVstUI->setSampleRate(opt);
+#endif
break;
case effSetBlockSize:
@@ -424,7 +426,6 @@ public:
# endif
d_lastUiSampleRate = fPlugin.getSampleRate();
- d_stdout("effEditOpen with ptr = %p", ptr);
fVstUI = new UIVst(fAudioMaster, fEffect, this, &fPlugin, (intptr_t)ptr);
# if DISTRHO_PLUGIN_WANT_STATE
@@ -584,7 +585,7 @@ public:
case effCanDo:
if (const char* const canDo = (const char*)ptr)
{
-# if DISTRHO_OS_MAC
+# if DISTRHO_OS_MAC && DISTRHO_PLUGIN_HAS_UI
if (std::strcmp(canDo, "hasCockosViewAsConfig") == 0)
{
fUsingNsView = true;
@@ -716,7 +717,7 @@ private:
PluginExporter fPlugin;
// Temporary data
- char fProgramName[64+1];
+ char fProgramName[32+1];
#if DISTRHO_PLUGIN_HAS_MIDI_INPUT
uint32_t fMidiEventCount;
@@ -903,25 +904,25 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
#endif
case effGetEffectName:
- if (ptr != nullptr)
+ if (char* const cptr = (char*)ptr)
{
- DISTRHO::strncpy((char*)ptr, plugin.getName(), 64);
+ DISTRHO::strncpy(cptr, plugin.getName(), 32);
return 1;
}
return 0;
case effGetVendorString:
- if (ptr != nullptr)
+ if (char* const cptr = (char*)ptr)
{
- DISTRHO::strncpy((char*)ptr, plugin.getMaker(), 64);
+ DISTRHO::strncpy(cptr, plugin.getMaker(), 32);
return 1;
}
return 0;
case effGetProductString:
- if (ptr != nullptr)
+ if (char* const cptr = (char*)ptr)
{
- DISTRHO::strncpy((char*)ptr, plugin.getLabel(), 64);
+ DISTRHO::strncpy(cptr, plugin.getLabel(), 32);
return 1;
}
return 0;
diff --git a/libs/distrho/src/DistrhoUI.cpp b/libs/distrho/src/DistrhoUI.cpp
index eda57b0..82ea7a5 100644
--- a/libs/distrho/src/DistrhoUI.cpp
+++ b/libs/distrho/src/DistrhoUI.cpp
@@ -21,9 +21,9 @@ START_NAMESPACE_DISTRHO
/* ------------------------------------------------------------------------------------------------------------
* Static data, see DistrhoUIInternal.hpp */
-double d_lastUiSampleRate = 0.0;
-void* d_lastUiDspPtr = nullptr;
-UIWindow* d_lastUiWindow = nullptr;
+double d_lastUiSampleRate = 0.0;
+void* d_lastUiDspPtr = nullptr;
+Window* d_lastUiWindow = nullptr;
/* ------------------------------------------------------------------------------------------------------------
* UI */
@@ -90,35 +90,25 @@ void UI::d_sampleRateChanged(double) {}
/* ------------------------------------------------------------------------------------------------------------
* UI Callbacks (optional) */
-#if ! DISTRHO_UI_USE_NTK
void UI::d_uiReshape(uint width, uint height)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0, width, height, 0, 0.0f, 1.0f);
- glViewport(0, 0, width, height);
+ glOrtho(0.0, static_cast<GLdouble>(width), static_cast<GLdouble>(height), 0.0, 0.0, 1.0);
+ glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
-#endif
/* ------------------------------------------------------------------------------------------------------------
* UI Resize Handling, internal */
-#if DISTRHO_UI_USE_NTK
-void UI::resize(int x, int y, int w, int h)
-{
- UIWidget::resize(x, y, w, h);
- pData->setSizeCallback(w, h);
-}
-#else
void UI::onResize(const ResizeEvent& ev)
{
pData->setSizeCallback(ev.size.getWidth(), ev.size.getHeight());
}
-#endif
// -----------------------------------------------------------------------------------------------------------
diff --git a/libs/distrho/src/DistrhoUIInternal.hpp b/libs/distrho/src/DistrhoUIInternal.hpp
index 6bd421c..a17e2aa 100644
--- a/libs/distrho/src/DistrhoUIInternal.hpp
+++ b/libs/distrho/src/DistrhoUIInternal.hpp
@@ -18,29 +18,21 @@
#define DISTRHO_UI_INTERNAL_HPP_INCLUDED
#include "../DistrhoUI.hpp"
+#include "../../dgl/App.hpp"
+#include "../../dgl/Window.hpp"
-#if DISTRHO_UI_USE_NTK
-# include "../../dgl/ntk/NtkApp.hpp"
-# include "../../dgl/ntk/NtkWindow.hpp"
-typedef DGL::NtkApp App;
-typedef DGL::NtkWindow UIWindow;
-#else
-# include "../../dgl/App.hpp"
-# include "../../dgl/Window.hpp"
-typedef DGL::App App;
-typedef DGL::Window UIWindow;
-#endif
-
+using DGL::App;
using DGL::IdleCallback;
+using DGL::Window;
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
// Static data, see DistrhoUI.cpp
-extern double d_lastUiSampleRate;
-extern void* d_lastUiDspPtr;
-extern UIWindow* d_lastUiWindow;
+extern double d_lastUiSampleRate;
+extern void* d_lastUiDspPtr;
+extern Window* d_lastUiWindow;
// -----------------------------------------------------------------------
// UI callbacks
@@ -83,7 +75,7 @@ struct UI::PrivateData {
setSizeCallbackFunc(nullptr),
ptr(nullptr)
{
- DISTRHO_SAFE_ASSERT(sampleRate != 0.0);
+ DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));
#if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
@@ -137,25 +129,21 @@ struct UI::PrivateData {
// Plugin Window, needed to take care of resize properly
static inline
-UI* createUiWrapper(void* const dspPtr, UIWindow* const window)
+UI* createUiWrapper(void* const dspPtr, Window* const window)
{
d_lastUiDspPtr = dspPtr;
d_lastUiWindow = window;
-#if DISTRHO_UI_USE_NTK
- UI* const ret = window->getApp().createUI((void*)createUI);
-#else
UI* const ret = createUI();
-#endif
d_lastUiDspPtr = nullptr;
d_lastUiWindow = nullptr;
return ret;
}
-class UIExporterWindow : public UIWindow
+class UIExporterWindow : public Window
{
public:
UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr)
- : UIWindow(app, winId),
+ : Window(app, winId),
fUI(createUiWrapper(dspPtr, this)),
fIsReady(false)
{
@@ -168,11 +156,7 @@ public:
~UIExporterWindow()
{
-#if DISTRHO_UI_USE_NTK
- getApp().deleteUI(fUI);
-#else
delete fUI;
-#endif
}
UI* getUI() const noexcept
@@ -185,14 +169,7 @@ public:
return fIsReady;
}
-//protected:
-#if DISTRHO_UI_USE_NTK
- void resize(int x, int y, int width, int height) override
- {
- UIWindow::resize(x, y, width, height);
- fIsReady = true;
- }
-#else
+protected:
void onReshape(uint width, uint height) override
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
@@ -202,7 +179,6 @@ public:
fIsReady = true;
}
-#endif
private:
UI* const fUI;
@@ -254,6 +230,13 @@ public:
// -------------------------------------------------------------------
+ intptr_t getWindowId() const noexcept
+ {
+ return glWindow.getWindowId();
+ }
+
+ // -------------------------------------------------------------------
+
uint32_t getParameterOffset() const noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0);
@@ -306,8 +289,6 @@ public:
{
if (glWindow.isReady())
fUI->d_uiIdle();
-
- fChangingSize = false;
}
bool idle()
@@ -319,8 +300,6 @@ public:
if (glWindow.isReady())
fUI->d_uiIdle();
- fChangingSize = false;
-
return ! glApp.isQuiting();
}
@@ -335,9 +314,7 @@ public:
void setWindowSize(const uint width, const uint height, const bool updateUI = false)
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
-
- if (fChangingSize)
- return;
+ DISTRHO_SAFE_ASSERT_RETURN(! fChangingSize,);
fChangingSize = true;
@@ -345,6 +322,8 @@ public:
fUI->setSize(width, height);
glWindow.setSize(width, height);
+
+ fChangingSize = false;
}
void setWindowTitle(const char* const uiTitle)
@@ -352,7 +331,7 @@ public:
glWindow.setTitle(uiTitle);
}
- void setWindowTransientWinId(const intptr_t winId)
+ void setWindowTransientWinId(const uintptr_t winId)
{
glWindow.setTransientWinId(winId);
}
@@ -372,7 +351,7 @@ public:
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
DISTRHO_SAFE_ASSERT(sampleRate > 0.0);
- if (fData->sampleRate == sampleRate)
+ if (d_isEqual(fData->sampleRate, sampleRate))
return;
fData->sampleRate = sampleRate;
diff --git a/libs/distrho/src/DistrhoUILV2.cpp b/libs/distrho/src/DistrhoUILV2.cpp
index 4de5346..2aa6565 100644
--- a/libs/distrho/src/DistrhoUILV2.cpp
+++ b/libs/distrho/src/DistrhoUILV2.cpp
@@ -37,7 +37,8 @@ class UiLv2
public:
UiLv2(const intptr_t winId,
const LV2_Options_Option* options, const LV2_URID_Map* const uridMap, const LV2UI_Resize* const uiResz, const LV2UI_Touch* uiTouch,
- const LV2UI_Controller controller, const LV2UI_Write_Function writeFunc, void* const dspPtr)
+ const LV2UI_Controller controller, const LV2UI_Write_Function writeFunc,
+ LV2UI_Widget* const widget, void* const dspPtr)
: fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, dspPtr),
fUridMap(uridMap),
fUiResize(uiResz),
@@ -51,6 +52,9 @@ public:
if (fUiResize != nullptr && winId != 0)
fUiResize->ui_resize(fUiResize->handle, fUI.getWidth(), fUI.getHeight());
+ if (widget != nullptr)
+ *widget = (LV2UI_Widget*)fUI.getWindowId();
+
#if DISTRHO_PLUGIN_WANT_STATE
// tell the DSP we're ready to receive msgs
setState("__dpf_ui_data__", "");
@@ -59,7 +63,7 @@ public:
if (winId != 0)
return;
- // if winId != 0 then options must not be null
+ // if winId == 0 then options must not be null
DISTRHO_SAFE_ASSERT_RETURN(options != nullptr,);
const LV2_URID uridWindowTitle(uridMap->map(uridMap->handle, LV2_UI__windowTitle));
@@ -106,10 +110,8 @@ public:
{
const uint32_t parameterOffset(fUI.getParameterOffset());
- if (rindex < parameterOffset)
- return;
- if (bufferSize != sizeof(float))
- return;
+ DISTRHO_SAFE_ASSERT_RETURN(rindex >= parameterOffset,)
+ DISTRHO_SAFE_ASSERT_RETURN(bufferSize == sizeof(float),)
const float value(*(const float*)buffer);
fUI.parameterChanged(rindex-parameterOffset, value);
@@ -391,8 +393,6 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri,
}
#endif
- *widget = parentId;
-
const intptr_t winId((intptr_t)parentId);
if (options != nullptr)
@@ -419,7 +419,7 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri,
d_lastUiSampleRate = 44100.0;
}
- return new UiLv2(winId, options, uridMap, uiResize, uiTouch, controller, writeFunction, instance);
+ return new UiLv2(winId, options, uridMap, uiResize, uiTouch, controller, writeFunction, widget, instance);
}
#define uiPtr ((UiLv2*)ui)