DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 8a1c6cdb728b95223501943012bdca23f1051f1a
parent 8d8af85953661c305c96610b7106bb87112357dd
Author: falkTX <falktx@gmail.com>
Date:   Wed, 28 May 2014 06:53:39 +0100

Remove hacky lastUiParent in DGL; use similar inside distrho only

Diffstat:
Mdgl/src/Window.cpp | 5-----
Mdistrho/src/DistrhoUI.cpp | 14++++----------
Mdistrho/src/DistrhoUIInternal.hpp | 30++++++++++++++++++------------
3 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp @@ -55,8 +55,6 @@ extern "C" { START_NAMESPACE_DGL -Window* dgl_lastUiParent = nullptr; - // ----------------------------------------------------------------------- // Window Private @@ -162,12 +160,9 @@ struct Window::PrivateData { if (fSelf == nullptr || fView == nullptr) { DBG("Failed!\n"); - dgl_lastUiParent = nullptr; return; } - dgl_lastUiParent = fSelf; - puglInitResizable(fView, fResizable); puglSetHandle(fView, this); diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp @@ -16,28 +16,22 @@ #include "DistrhoUIInternal.hpp" -START_NAMESPACE_DGL -extern Window* dgl_lastUiParent; -END_NAMESPACE_DGL - START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- // Static data, see DistrhoUIInternal.hpp -double d_lastUiSampleRate = 0.0; +double d_lastUiSampleRate = 0.0; +void* d_lastUiDspPtr = nullptr; +Window* d_lastUiWindow = nullptr; // ----------------------------------------------------------------------- // UI UI::UI() - : UIWidget(*DGL::dgl_lastUiParent), + : UIWidget(*d_lastUiWindow), pData(new PrivateData()) { - DISTRHO_SAFE_ASSERT(DGL::dgl_lastUiParent != nullptr); - - DGL::dgl_lastUiParent = nullptr; - Widget::setNeedsFullViewport(true); } diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -31,7 +31,9 @@ START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- // Static data, see DistrhoUI.cpp -extern double d_lastUiSampleRate; +extern double d_lastUiSampleRate; +extern void* d_lastUiDspPtr; +extern Window* d_lastUiWindow; // ----------------------------------------------------------------------- // UI callbacks @@ -65,7 +67,7 @@ struct UI::PrivateData { : sampleRate(d_lastUiSampleRate), parameterOffset(0), #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS - dspPtr(nullptr), + dspPtr(d_lastUiDspPtr), #endif editParamCallbackFunc(nullptr), setParamCallbackFunc(nullptr), @@ -127,12 +129,23 @@ struct UI::PrivateData { // ----------------------------------------------------------------------- // Plugin Window, needed to take care of resize properly +static inline +UI* createUiWrapper(void* const dspPtr, Window* const window) +{ + d_lastUiDspPtr = dspPtr; + d_lastUiWindow = window; + UI* const ret = createUI(); + d_lastUiDspPtr = nullptr; + d_lastUiWindow = nullptr; + return ret; +} + class UIExporterWindow : public Window { public: - UIExporterWindow(App& app, const intptr_t winId) + UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr) : Window(app, winId), - fUi(createUI()), + fUi(createUiWrapper(dspPtr, this)), fIsReady(false) { DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,); @@ -182,7 +195,7 @@ public: const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const setSizeFunc setSizeCall, void* const dspPtr = nullptr) : glApp(), - glWindow(glApp, winId), + glWindow(glApp, winId, dspPtr), fUi(glWindow.getUI()), fData((fUi != nullptr) ? fUi->pData : nullptr) { @@ -195,13 +208,6 @@ public: fData->setStateCallbackFunc = setStateCall; fData->sendNoteCallbackFunc = sendNoteCall; fData->setSizeCallbackFunc = setSizeCall; - -#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS - fData->dspPtr = dspPtr; -#else - return; // unused - (void)dspPtr; -#endif } // -------------------------------------------------------------------