diff --git a/dgl/App.hpp b/dgl/App.hpp index 0e77e1b1..b6fce019 100644 --- a/dgl/App.hpp +++ b/dgl/App.hpp @@ -57,6 +57,7 @@ public: /** Run the application event-loop until all Windows are closed. idle() is called at regular intervals. + @note: This function is meant for standalones only, *never* call this from plugins. */ void exec(); diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 157a9c9b..3901067d 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -20,15 +20,14 @@ #include "extra/d_leakdetector.hpp" #include "src/DistrhoPluginChecks.h" -#include "../dgl/Widget.hpp" - -#if DISTRHO_UI_USE_NANOVG +#if DISTRHO_UI_USE_NTK +# include "../dgl/ntk/NtkWidget.hpp" +typedef DGL::NtkWidget UIWidget; +#elif DISTRHO_UI_USE_NANOVG # include "../dgl/NanoVG.hpp" typedef DGL::NanoWidget UIWidget; -#elif DISTRHO_UI_USE_NTK -# include "FL/Fl_Double_Window.H" -typedef Fl_Double_Window UIWidget; -#else +# else +# include "../dgl/Widget.hpp" typedef DGL::Widget UIWidget; #endif diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 2e9f6201..7d2951ff 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/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; -Window* d_lastUiWindow = nullptr; +double d_lastUiSampleRate = 0.0; +void* d_lastUiDspPtr = nullptr; +UIWindow* d_lastUiWindow = nullptr; // ----------------------------------------------------------------------- // UI @@ -32,7 +32,7 @@ UI::UI() : UIWidget(*d_lastUiWindow), pData(new PrivateData()) { - Widget::setNeedsFullViewport(true); + UIWidget::setNeedsFullViewport(true); } UI::~UI() @@ -100,6 +100,7 @@ void UI::d_sampleRateChanged(double) {} void UI::d_uiReshape(int width, int height) { +#if ! DISTRHO_UI_USE_NTK glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); @@ -108,6 +109,9 @@ void UI::d_uiReshape(int width, int height) glViewport(0, 0, width, height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); +#else + (void)width; (void)height; +#endif } // ----------------------------------------------------------------------- diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index b65c0e9d..1eaca647 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -20,24 +20,27 @@ #include "../DistrhoUI.hpp" #if DISTRHO_UI_USE_NTK -# include "FL/Fl_Double_Window.H" -typedef Fl_Double_Window Window; +# 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" -using DGL::App; -using DGL::IdleCallback; -using DGL::Window; +typedef DGL::App App; +typedef DGL::Window UIWindow; #endif +using DGL::IdleCallback; + START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- // Static data, see DistrhoUI.cpp -extern double d_lastUiSampleRate; -extern void* d_lastUiDspPtr; -extern Window* d_lastUiWindow; +extern double d_lastUiSampleRate; +extern void* d_lastUiDspPtr; +extern UIWindow* d_lastUiWindow; // ----------------------------------------------------------------------- // UI callbacks @@ -134,7 +137,7 @@ struct UI::PrivateData { // Plugin Window, needed to take care of resize properly static inline -UI* createUiWrapper(void* const dspPtr, Window* const window) +UI* createUiWrapper(void* const dspPtr, UIWindow* const window) { d_lastUiDspPtr = dspPtr; d_lastUiWindow = window; @@ -144,23 +147,27 @@ UI* createUiWrapper(void* const dspPtr, Window* const window) return ret; } -class UIExporterWindow : public Window +class UIExporterWindow : public UIWindow { public: UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr) - : Window(app, winId), + : UIWindow(app, winId), fUI(createUiWrapper(dspPtr, this)), fIsReady(false) { DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); +#if ! DISTRHO_UI_USE_NTK const int width = fUI->d_getWidth(); const int height = fUI->d_getHeight(); + // set widget size fUI->setSize(width, height); + // set this window size setResizable(false); setSize(width, height); +#endif } ~UIExporterWindow() @@ -178,16 +185,21 @@ public: return fIsReady; } +#if ! DISTRHO_UI_USE_NTK protected: void onReshape(int width, int height) override { DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); + // report size change to plugin UI fUI->setSize(width, height); + + // update openGL state fUI->d_uiReshape(width, height); fIsReady = true; } +#endif private: UI* const fUI; @@ -280,6 +292,7 @@ public: } #endif +#if ! DISTRHO_UI_USE_NTK // ------------------------------------------------------------------- void exec(IdleCallback* const cb) @@ -342,6 +355,7 @@ public: return ! glApp.isQuiting(); } +#endif void setSampleRate(const double sampleRate, const bool doCallback = false) {