Browse Source

Clear up UI size stuff

gh-pages
falkTX 9 years ago
parent
commit
05384270a8
8 changed files with 58 additions and 44 deletions
  1. +2
    -1
      distrho/DistrhoUI.hpp
  2. +4
    -4
      distrho/src/DistrhoPluginCarla.cpp
  3. +4
    -4
      distrho/src/DistrhoPluginJack.cpp
  4. +4
    -4
      distrho/src/DistrhoPluginVST.cpp
  5. +2
    -2
      distrho/src/DistrhoUI.cpp
  6. +4
    -4
      distrho/src/DistrhoUIDSSI.cpp
  7. +34
    -21
      distrho/src/DistrhoUIInternal.hpp
  8. +4
    -4
      distrho/src/DistrhoUILV2.cpp

+ 2
- 1
distrho/DistrhoUI.hpp View File

@@ -49,7 +49,7 @@ public:
// -------------------------------------------------------------------
// Host UI State

void d_uiResize(uint width, uint height);
void d_setSize(uint width, uint height);

#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
// -------------------------------------------------------------------
@@ -89,6 +89,7 @@ private:
struct PrivateData;
PrivateData* const pData;
friend class UIExporter;
friend class UIExporterWindow;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI)
};


+ 4
- 4
distrho/src/DistrhoPluginCarla.cpp View File

@@ -43,7 +43,7 @@ public:
UICarla(const NativeHostDescriptor* const host, PluginExporter* const plugin)
: fHost(host),
fPlugin(plugin),
fUI(this, 0, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback, plugin->getInstancePointer())
fUI(this, 0, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, plugin->getInstancePointer())
{
fUI.setTitle(host->uiName);

@@ -110,7 +110,7 @@ protected:
// TODO
}

void handleUiResize(const uint width, const uint height)
void handleSetSize(const uint width, const uint height)
{
fUI.setSize(width, height);
}
@@ -154,9 +154,9 @@ private:
}
#endif

static void uiResizeCallback(void* ptr, uint width, uint height)
static void setSizeCallback(void* ptr, uint width, uint height)
{
handlePtr->handleUiResize(width, height);
handlePtr->handleSetSize(width, height);
}

#undef handlePtr


+ 4
- 4
distrho/src/DistrhoPluginJack.cpp View File

@@ -37,7 +37,7 @@ class PluginJack
public:
PluginJack(jack_client_t* const client)
: fPlugin(),
fUI(this, 0, nullptr, nullptr, nullptr, nullptr, uiResizeCallback, fPlugin.getInstancePointer()),
fUI(this, 0, nullptr, nullptr, nullptr, nullptr, setSizeCallback, fPlugin.getInstancePointer()),
fClient(client)
{
char strBuf[0xff+1];
@@ -217,7 +217,7 @@ protected:
fUI.quit();
}

void uiResize(const uint width, const uint height)
void setSize(const uint width, const uint height)
{
fUI.setSize(width, height);
}
@@ -271,9 +271,9 @@ private:
uiPtr->jackShutdown();
}

static void uiResizeCallback(void* ptr, uint width, uint height)
static void setSizeCallback(void* ptr, uint width, uint height)
{
uiPtr->uiResize(width, height);
uiPtr->setSize(width, height);
}

#undef uiPtr


+ 4
- 4
distrho/src/DistrhoPluginVST.cpp View File

@@ -119,7 +119,7 @@ public:
fEffect(effect),
fUiHelper(uiHelper),
fPlugin(plugin),
fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback, plugin->getInstancePointer())
fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, plugin->getInstancePointer())
{
}

@@ -215,7 +215,7 @@ protected:
#endif
}

void uiResize(const uint width, const uint height)
void setSize(const uint width, const uint height)
{
fUI.setSize(width, height);
hostCallback(audioMasterSizeWindow, width, height, nullptr, 0.0f);
@@ -256,9 +256,9 @@ private:
handlePtr->sendNote(channel, note, velocity);
}

static void uiResizeCallback(void* ptr, uint width, uint height)
static void setSizeCallback(void* ptr, uint width, uint height)
{
handlePtr->uiResize(width, height);
handlePtr->setSize(width, height);
}

#undef handlePtr


+ 2
- 2
distrho/src/DistrhoUI.cpp View File

@@ -79,9 +79,9 @@ void UI::d_sendNote(uint8_t channel, uint8_t note, uint8_t velocity)
// -----------------------------------------------------------------------
// Host UI State

void UI::d_uiResize(uint width, uint height)
void UI::d_setSize(uint width, uint height)
{
pData->uiResizeCallback(width, height);
pData->setSizeCallback(width, height);
}

#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS


+ 4
- 4
distrho/src/DistrhoUIDSSI.cpp View File

@@ -93,7 +93,7 @@ class UIDssi
{
public:
UIDssi(const OscData& oscData, const char* const uiTitle)
: fUI(this, 0, nullptr, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback),
: fUI(this, 0, nullptr, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback),
fHostClosed(false),
fOscData(oscData)
{
@@ -188,7 +188,7 @@ protected:
fOscData.send_midi(mdata);
}

void uiResize(const uint width, const uint height)
void setSize(const uint width, const uint height)
{
fUI.setSize(width, height);
}
@@ -219,9 +219,9 @@ private:
uiPtr->sendNote(channel, note, velocity);
}

static void uiResizeCallback(void* ptr, uint width, uint height)
static void setSizeCallback(void* ptr, uint width, uint height)
{
uiPtr->uiResize(width, height);
uiPtr->setSize(width, height);
}

#undef uiPtr


+ 34
- 21
distrho/src/DistrhoUIInternal.hpp View File

@@ -40,7 +40,7 @@ typedef void (*editParamFunc) (void* ptr, uint32_t rindex, bool started);
typedef void (*setParamFunc) (void* ptr, uint32_t rindex, float value);
typedef void (*setStateFunc) (void* ptr, const char* key, const char* value);
typedef void (*sendNoteFunc) (void* ptr, uint8_t channel, uint8_t note, uint8_t velo);
typedef void (*uiResizeFunc) (void* ptr, uint width, uint height);
typedef void (*setSizeFunc) (void* ptr, uint width, uint height);

// -----------------------------------------------------------------------
// UI private data
@@ -58,7 +58,7 @@ struct UI::PrivateData {
setParamFunc setParamCallbackFunc;
setStateFunc setStateCallbackFunc;
sendNoteFunc sendNoteCallbackFunc;
uiResizeFunc uiResizeCallbackFunc;
setSizeFunc setSizeCallbackFunc;
void* ptr;

PrivateData() noexcept
@@ -71,7 +71,7 @@ struct UI::PrivateData {
setParamCallbackFunc(nullptr),
setStateCallbackFunc(nullptr),
sendNoteCallbackFunc(nullptr),
uiResizeCallbackFunc(nullptr),
setSizeCallbackFunc(nullptr),
ptr(nullptr)
{
DISTRHO_SAFE_ASSERT(sampleRate != 0.0);
@@ -117,26 +117,31 @@ struct UI::PrivateData {
sendNoteCallbackFunc(ptr, channel, note, velocity);
}

void uiResizeCallback(const uint width, const uint height)
void setSizeCallback(const uint width, const uint height)
{
if (uiResizeCallbackFunc != nullptr)
uiResizeCallbackFunc(ptr, width, height);
if (setSizeCallbackFunc != nullptr)
setSizeCallbackFunc(ptr, width, height);
}
};

// -----------------------------------------------------------------------
// Plugin Window, needed to take care of resize properly

class PluginWindow : public Window
class UIExporterWindow : public Window
{
public:
PluginWindow(App& app, const intptr_t winId)
UIExporterWindow(App& app, const intptr_t winId)
: Window(app, winId),
fUi(createUI())
fUi(createUI()),
fIsReady(false)
{
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);

setResizable(false);
setSize(fUi->d_getWidth(), fUi->d_getHeight());
}

~PluginWindow()
~UIExporterWindow()
{
delete fUi;
}
@@ -146,17 +151,25 @@ public:
return fUi;
}

bool isReady() const noexcept
{
return fIsReady;
}

protected:
void onReshape(const int width, const int height) override
void onReshape(int width, int height) override
{
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);

fIsReady = true;

fUi->setSize(width, height);
fUi->d_uiResize(width, height);
fUi->d_uiReshape(width, height);
}

private:
UI* const fUi;
bool fIsReady;
};

// -----------------------------------------------------------------------
@@ -166,7 +179,7 @@ class UIExporter : public IdleCallback
{
public:
UIExporter(void* const ptr, const intptr_t winId,
const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const uiResizeFunc uiResizeCall,
const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const setSizeFunc setSizeCall,
void* const dspPtr = nullptr)
: glApp(),
glWindow(glApp, winId),
@@ -181,10 +194,7 @@ public:
fData->setParamCallbackFunc = setParamCall;
fData->setStateCallbackFunc = setStateCall;
fData->sendNoteCallbackFunc = sendNoteCall;
fData->uiResizeCallbackFunc = uiResizeCall;

glWindow.setResizable(false);
glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight());
fData->setSizeCallbackFunc = setSizeCall;

#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
fData->dspPtr = dspPtr;
@@ -270,7 +280,9 @@ public:
{
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, false);

fUi->d_uiIdle();
if (glWindow.isReady())
fUi->d_uiIdle();

glApp.idle();

return ! glApp.isQuiting();
@@ -312,15 +324,16 @@ public:
protected:
void idleCallback() override
{
fUi->d_uiIdle();
if (glWindow.isReady())
fUi->d_uiIdle();
}

private:
// -------------------------------------------------------------------
// DGL Application and Window for this widget

App glApp;
PluginWindow glWindow;
App glApp;
UIExporterWindow glWindow;

// -------------------------------------------------------------------
// Widget and DistrhoUI data


+ 4
- 4
distrho/src/DistrhoUILV2.cpp View File

@@ -37,7 +37,7 @@ 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)
: fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback, dspPtr),
: fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, dspPtr),
fUridMap(uridMap),
fUiResize(uiResz),
fUiTouch(uiTouch),
@@ -193,7 +193,7 @@ protected:
{
}

void uiResize(const uint width, const uint height)
void setSize(const uint width, const uint height)
{
fUI.setSize(width, height);

@@ -245,9 +245,9 @@ private:
uiPtr->sendNote(channel, note, velocity);
}

static void uiResizeCallback(void* ptr, uint width, uint height)
static void setSizeCallback(void* ptr, uint width, uint height)
{
uiPtr->uiResize(width, height);
uiPtr->setSize(width, height);
}

#undef uiPtr


Loading…
Cancel
Save