Browse Source

Initial code for host-side resize, not enabled

gh-pages
falkTX 10 years ago
parent
commit
c9c3c98912
2 changed files with 40 additions and 8 deletions
  1. +21
    -6
      distrho/src/DistrhoUIInternal.hpp
  2. +19
    -2
      distrho/src/DistrhoUILV2.cpp

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

@@ -177,7 +177,7 @@ public:
return fIsReady;
}

protected:
//protected:
#if DISTRHO_UI_USE_NTK
void resize(int x, int y, int width, int height) override
{
@@ -189,10 +189,6 @@ protected:
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);

// report size change to plugin UI
// TESTING is this needed?
//fUI->setSize(width, height);

// custom window reshape
fUI->d_uiReshape(width, height);

@@ -216,6 +212,7 @@ public:
void* const dspPtr = nullptr)
: glApp(),
glWindow(glApp, winId, dspPtr),
fChangingSize(false),
fUI(glWindow.getUI()),
fData((fUI != nullptr) ? fUI->pData : nullptr)
{
@@ -323,9 +320,24 @@ public:

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

void setWindowSize(const uint width, const uint height)
void setWindowSize(const uint width, const uint height, const bool updateUI = false)
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);

if (fChangingSize)
return;

fChangingSize = true;

if (updateUI)
fUI->setSize(width, height);

glWindow.setSize(width, height);
glWindow.onReshape(width, height); // FIXME

glApp.idle();

fChangingSize = false;
}

void setWindowTitle(const char* const uiTitle)
@@ -369,6 +381,9 @@ private:
App glApp;
UIExporterWindow glWindow;

// prevent recursion
bool fChangingSize;

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



+ 19
- 2
distrho/src/DistrhoUILV2.cpp View File

@@ -27,8 +27,6 @@
#include "lv2/urid.h"
#include "lv2/lv2_programs.h"

// TODO - UI setSampleRate changes

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
@@ -147,6 +145,12 @@ public:
return fUI.setWindowVisible(false) ? 0 : 1;
}

int lv2ui_resize(uint width, uint height)
{
fUI.setWindowSize(width, height, true);
return 0;
}

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

uint32_t lv2_get_options(LV2_Options_Option* const /*options*/)
@@ -436,6 +440,16 @@ static int lv2ui_hide(LV2UI_Handle ui)
return uiPtr->lv2ui_hide();
}

static int lv2ui_resize(LV2UI_Handle ui, int width, int height)
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, 1);
DISTRHO_SAFE_ASSERT_RETURN(width > 0, 1);
DISTRHO_SAFE_ASSERT_RETURN(height > 0, 1);

return 1; // This needs more testing
//return uiPtr->lv2ui_resize(width, height);
}

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

static uint32_t lv2_get_options(LV2UI_Handle ui, LV2_Options_Option* options)
@@ -464,6 +478,7 @@ static const void* lv2ui_extension_data(const char* uri)
static const LV2_Options_Interface options = { lv2_get_options, lv2_set_options };
static const LV2UI_Idle_Interface uiIdle = { lv2ui_idle };
static const LV2UI_Show_Interface uiShow = { lv2ui_show, lv2ui_hide };
static const LV2UI_Resize uiResz = { nullptr, lv2ui_resize };

if (std::strcmp(uri, LV2_OPTIONS__interface) == 0)
return &options;
@@ -471,6 +486,8 @@ static const void* lv2ui_extension_data(const char* uri)
return &uiIdle;
if (std::strcmp(uri, LV2_UI__showInterface) == 0)
return &uiShow;
if (std::strcmp(uri, LV2_UI__resize) == 0)
return &uiResz;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
static const LV2_Programs_UI_Interface uiPrograms = { lv2ui_select_program };


Loading…
Cancel
Save