Browse Source

Remove hacky lastUiParent in DGL; use similar inside distrho only

gh-pages
falkTX 11 years ago
parent
commit
8a1c6cdb72
3 changed files with 22 additions and 27 deletions
  1. +0
    -5
      dgl/src/Window.cpp
  2. +4
    -10
      distrho/src/DistrhoUI.cpp
  3. +18
    -12
      distrho/src/DistrhoUIInternal.hpp

+ 0
- 5
dgl/src/Window.cpp View File

@@ -55,8 +55,6 @@ extern "C" {


START_NAMESPACE_DGL START_NAMESPACE_DGL


Window* dgl_lastUiParent = nullptr;

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Window Private // Window Private


@@ -162,12 +160,9 @@ struct Window::PrivateData {
if (fSelf == nullptr || fView == nullptr) if (fSelf == nullptr || fView == nullptr)
{ {
DBG("Failed!\n"); DBG("Failed!\n");
dgl_lastUiParent = nullptr;
return; return;
} }


dgl_lastUiParent = fSelf;

puglInitResizable(fView, fResizable); puglInitResizable(fView, fResizable);


puglSetHandle(fView, this); puglSetHandle(fView, this);


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

@@ -16,28 +16,22 @@


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"


START_NAMESPACE_DGL
extern Window* dgl_lastUiParent;
END_NAMESPACE_DGL

START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Static data, see DistrhoUIInternal.hpp // 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::UI() UI::UI()
: UIWidget(*DGL::dgl_lastUiParent),
: UIWidget(*d_lastUiWindow),
pData(new PrivateData()) pData(new PrivateData())
{ {
DISTRHO_SAFE_ASSERT(DGL::dgl_lastUiParent != nullptr);

DGL::dgl_lastUiParent = nullptr;

Widget::setNeedsFullViewport(true); Widget::setNeedsFullViewport(true);
} }




+ 18
- 12
distrho/src/DistrhoUIInternal.hpp View File

@@ -31,7 +31,9 @@ START_NAMESPACE_DISTRHO
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Static data, see DistrhoUI.cpp // Static data, see DistrhoUI.cpp


extern double d_lastUiSampleRate;
extern double d_lastUiSampleRate;
extern void* d_lastUiDspPtr;
extern Window* d_lastUiWindow;


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// UI callbacks // UI callbacks
@@ -65,7 +67,7 @@ struct UI::PrivateData {
: sampleRate(d_lastUiSampleRate), : sampleRate(d_lastUiSampleRate),
parameterOffset(0), parameterOffset(0),
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
dspPtr(nullptr),
dspPtr(d_lastUiDspPtr),
#endif #endif
editParamCallbackFunc(nullptr), editParamCallbackFunc(nullptr),
setParamCallbackFunc(nullptr), setParamCallbackFunc(nullptr),
@@ -127,12 +129,23 @@ struct UI::PrivateData {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Plugin Window, needed to take care of resize properly // 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 class UIExporterWindow : public Window
{ {
public: public:
UIExporterWindow(App& app, const intptr_t winId)
UIExporterWindow(App& app, const intptr_t winId, void* const dspPtr)
: Window(app, winId), : Window(app, winId),
fUi(createUI()),
fUi(createUiWrapper(dspPtr, this)),
fIsReady(false) fIsReady(false)
{ {
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,); 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, const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const setSizeFunc setSizeCall,
void* const dspPtr = nullptr) void* const dspPtr = nullptr)
: glApp(), : glApp(),
glWindow(glApp, winId),
glWindow(glApp, winId, dspPtr),
fUi(glWindow.getUI()), fUi(glWindow.getUI()),
fData((fUi != nullptr) ? fUi->pData : nullptr) fData((fUi != nullptr) ? fUi->pData : nullptr)
{ {
@@ -195,13 +208,6 @@ public:
fData->setStateCallbackFunc = setStateCall; fData->setStateCallbackFunc = setStateCall;
fData->sendNoteCallbackFunc = sendNoteCall; fData->sendNoteCallbackFunc = sendNoteCall;
fData->setSizeCallbackFunc = setSizeCall; fData->setSizeCallbackFunc = setSizeCall;

#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
fData->dspPtr = dspPtr;
#else
return; // unused
(void)dspPtr;
#endif
} }


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


Loading…
Cancel
Save