Browse Source

Initial work for NTK plugin UIs

gh-pages
falkTX 10 years ago
parent
commit
807aee7910
4 changed files with 40 additions and 22 deletions
  1. +1
    -0
      dgl/App.hpp
  2. +6
    -7
      distrho/DistrhoUI.hpp
  3. +8
    -4
      distrho/src/DistrhoUI.cpp
  4. +25
    -11
      distrho/src/DistrhoUIInternal.hpp

+ 1
- 0
dgl/App.hpp View File

@@ -57,6 +57,7 @@ public:
/** /**
Run the application event-loop until all Windows are closed. Run the application event-loop until all Windows are closed.
idle() is called at regular intervals. idle() is called at regular intervals.
@note: This function is meant for standalones only, *never* call this from plugins.
*/ */
void exec(); void exec();




+ 6
- 7
distrho/DistrhoUI.hpp View File

@@ -20,15 +20,14 @@
#include "extra/d_leakdetector.hpp" #include "extra/d_leakdetector.hpp"
#include "src/DistrhoPluginChecks.h" #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" # include "../dgl/NanoVG.hpp"
typedef DGL::NanoWidget UIWidget; 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; typedef DGL::Widget UIWidget;
#endif #endif




+ 8
- 4
distrho/src/DistrhoUI.cpp View File

@@ -21,9 +21,9 @@ START_NAMESPACE_DISTRHO
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Static data, see DistrhoUIInternal.hpp // 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 // UI
@@ -32,7 +32,7 @@ UI::UI()
: UIWidget(*d_lastUiWindow), : UIWidget(*d_lastUiWindow),
pData(new PrivateData()) pData(new PrivateData())
{ {
Widget::setNeedsFullViewport(true);
UIWidget::setNeedsFullViewport(true);
} }


UI::~UI() UI::~UI()
@@ -100,6 +100,7 @@ void UI::d_sampleRateChanged(double) {}


void UI::d_uiReshape(int width, int height) void UI::d_uiReshape(int width, int height)
{ {
#if ! DISTRHO_UI_USE_NTK
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@@ -108,6 +109,9 @@ void UI::d_uiReshape(int width, int height)
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
#else
(void)width; (void)height;
#endif
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


+ 25
- 11
distrho/src/DistrhoUIInternal.hpp View File

@@ -20,24 +20,27 @@
#include "../DistrhoUI.hpp" #include "../DistrhoUI.hpp"


#if DISTRHO_UI_USE_NTK #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 #else
# include "../../dgl/App.hpp" # include "../../dgl/App.hpp"
# include "../../dgl/Window.hpp" # include "../../dgl/Window.hpp"
using DGL::App;
using DGL::IdleCallback;
using DGL::Window;
typedef DGL::App App;
typedef DGL::Window UIWindow;
#endif #endif


using DGL::IdleCallback;

START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Static data, see DistrhoUI.cpp // 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 // UI callbacks
@@ -134,7 +137,7 @@ struct UI::PrivateData {
// Plugin Window, needed to take care of resize properly // Plugin Window, needed to take care of resize properly


static inline static inline
UI* createUiWrapper(void* const dspPtr, Window* const window)
UI* createUiWrapper(void* const dspPtr, UIWindow* const window)
{ {
d_lastUiDspPtr = dspPtr; d_lastUiDspPtr = dspPtr;
d_lastUiWindow = window; d_lastUiWindow = window;
@@ -144,23 +147,27 @@ UI* createUiWrapper(void* const dspPtr, Window* const window)
return ret; return ret;
} }


class UIExporterWindow : public Window
class UIExporterWindow : public UIWindow
{ {
public: public:
UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr) UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr)
: Window(app, winId),
: UIWindow(app, winId),
fUI(createUiWrapper(dspPtr, this)), fUI(createUiWrapper(dspPtr, this)),
fIsReady(false) fIsReady(false)
{ {
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);


#if ! DISTRHO_UI_USE_NTK
const int width = fUI->d_getWidth(); const int width = fUI->d_getWidth();
const int height = fUI->d_getHeight(); const int height = fUI->d_getHeight();


// set widget size
fUI->setSize(width, height); fUI->setSize(width, height);


// set this window size
setResizable(false); setResizable(false);
setSize(width, height); setSize(width, height);
#endif
} }


~UIExporterWindow() ~UIExporterWindow()
@@ -178,16 +185,21 @@ public:
return fIsReady; return fIsReady;
} }


#if ! DISTRHO_UI_USE_NTK
protected: protected:
void onReshape(int width, int height) override void onReshape(int width, int height) override
{ {
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);


// report size change to plugin UI
fUI->setSize(width, height); fUI->setSize(width, height);

// update openGL state
fUI->d_uiReshape(width, height); fUI->d_uiReshape(width, height);


fIsReady = true; fIsReady = true;
} }
#endif


private: private:
UI* const fUI; UI* const fUI;
@@ -280,6 +292,7 @@ public:
} }
#endif #endif


#if ! DISTRHO_UI_USE_NTK
// ------------------------------------------------------------------- // -------------------------------------------------------------------


void exec(IdleCallback* const cb) void exec(IdleCallback* const cb)
@@ -342,6 +355,7 @@ public:


return ! glApp.isQuiting(); return ! glApp.isQuiting();
} }
#endif


void setSampleRate(const double sampleRate, const bool doCallback = false) void setSampleRate(const double sampleRate, const bool doCallback = false)
{ {


Loading…
Cancel
Save