Browse Source

Add width/height as parameters of embed-ext-ui for easier testing

Signed-off-by: falkTX <falktx@falktx.com>
pull/318/head
falkTX 3 years ago
parent
commit
c1f2d7f47a
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 75 additions and 28 deletions
  1. +1
    -1
      distrho/extra/ExternalWindow.hpp
  2. +2
    -1
      examples/EmbedExternalUI/DistrhoPluginInfo.h
  3. +41
    -18
      examples/EmbedExternalUI/EmbedExternalExamplePlugin.cpp
  4. +31
    -8
      examples/EmbedExternalUI/EmbedExternalExampleUI.cpp

+ 1
- 1
distrho/extra/ExternalWindow.hpp View File

@@ -297,7 +297,7 @@ public:
{ {
DISTRHO_SAFE_ASSERT_UINT2_RETURN(width > 1 && height > 1, width, height,); DISTRHO_SAFE_ASSERT_UINT2_RETURN(width > 1 && height > 1, width, height,);


if (pData.width == width || pData.height == height)
if (pData.width == width && pData.height == height)
return; return;


pData.width = width; pData.width = width;


+ 2
- 1
examples/EmbedExternalUI/DistrhoPluginInfo.h View File

@@ -30,7 +30,8 @@
#define DISTRHO_UI_USER_RESIZABLE 1 #define DISTRHO_UI_USER_RESIZABLE 1


enum Parameters { enum Parameters {
kParameterLevel = 0,
kParameterWidth = 0,
kParameterHeight,
kParameterCount kParameterCount
}; };




+ 41
- 18
examples/EmbedExternalUI/EmbedExternalExamplePlugin.cpp View File

@@ -28,7 +28,8 @@ class EmbedExternalExamplePlugin : public Plugin
public: public:
EmbedExternalExamplePlugin() EmbedExternalExamplePlugin()
: Plugin(kParameterCount, 0, 0), : Plugin(kParameterCount, 0, 0),
fValue(0.0f)
fWidth(512.0f),
fHeight(256.0f)
{ {
} }
@@ -104,15 +105,27 @@ protected:
*/ */
void initParameter(uint32_t index, Parameter& parameter) override void initParameter(uint32_t index, Parameter& parameter) override
{ {
if (index != 0)
return;
parameter.hints = kParameterIsAutomable|kParameterIsInteger;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 100.0f;
parameter.name = "Value";
parameter.symbol = "value";
switch (index)
{
case kParameterWidth:
parameter.hints = kParameterIsAutomable|kParameterIsInteger;
parameter.ranges.def = 512.0f;
parameter.ranges.min = 256.0f;
parameter.ranges.max = 4096.0f;
parameter.name = "Width";
parameter.symbol = "width";
parameter.unit = "px";
break;
case kParameterHeight:
parameter.hints = kParameterIsAutomable|kParameterIsInteger;
parameter.ranges.def = 256.0f;
parameter.ranges.min = 256.0f;
parameter.ranges.max = 4096.0f;
parameter.name = "Height";
parameter.symbol = "height";
parameter.unit = "px";
break;
}
} }
/* -------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------
@@ -124,10 +137,15 @@ protected:
*/ */
float getParameterValue(uint32_t index) const override float getParameterValue(uint32_t index) const override
{ {
if (index != 0)
return 0.0f;
switch (index)
{
case kParameterWidth:
return fWidth;
case kParameterHeight:
return fHeight;
}
return fValue;
return 0.0f;
} }
@@ -139,10 +157,15 @@ protected:
*/ */
void setParameterValue(uint32_t index, float value) override void setParameterValue(uint32_t index, float value) override
{ {
if (index != 0)
return;
fValue = value;
switch (index)
{
case kParameterWidth:
fWidth = value;
break;
case kParameterHeight:
fHeight = value;
break;
}
} }
/* -------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------
@@ -169,7 +192,7 @@ protected:
private: private:
// Parameters // Parameters
float fValue;
float fWidth, fHeight;
/** /**
Set our plugin class as non-copyable and add a leak detector just in case. Set our plugin class as non-copyable and add a leak detector just in case.


+ 31
- 8
examples/EmbedExternalUI/EmbedExternalExampleUI.cpp View File

@@ -61,6 +61,7 @@ class EmbedExternalExampleUI : public UI
NSView* fView; NSView* fView;
NSExternalWindow* fWindow; NSExternalWindow* fWindow;
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
::HWND fWindow;
#else #else
::Display* fDisplay; ::Display* fDisplay;
::Window fWindow; ::Window fWindow;
@@ -71,13 +72,13 @@ public:
: UI(512, 256), : UI(512, 256),
#if defined(DISTRHO_OS_MAC) #if defined(DISTRHO_OS_MAC)
fView(nullptr), fView(nullptr),
fWindow(nullptr),
fWindow(nullptr)
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
fWindow(nullptr)
#else #else
fDisplay(nullptr), fDisplay(nullptr),
fWindow(0),
fWindow(0)
#endif #endif
fValue(0.0f)
{ {
const bool standalone = isStandalone(); const bool standalone = isStandalone();
d_stdout("isStandalone %d", (int)standalone); d_stdout("isStandalone %d", (int)standalone);
@@ -222,10 +223,17 @@ protected:
*/ */
void parameterChanged(uint32_t index, float value) override void parameterChanged(uint32_t index, float value) override
{ {
if (index != 0)
return;
d_stdout("parameterChanged %u %f", index, value);


fValue = value;
switch (index)
{
case kParameterWidth:
setWidth(static_cast<int>(value + 0.5f));
break;
case kParameterHeight:
setHeight(static_cast<int>(value + 0.5f));
break;
}
} }


/* -------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------
@@ -257,6 +265,19 @@ protected:
return 0; return 0;
} }


void sizeChanged(uint width, uint height) override
{
d_stdout("sizeChanged %u %u", width, height);
UI::sizeChanged(width, height);

#if defined(DISTRHO_OS_MAC)
#elif defined(DISTRHO_OS_WINDOWS)
#else
if (fWindow != 0)
XResizeWindow(fDisplay, fWindow, width, height);
#endif
}

void titleChanged(const char* const title) override void titleChanged(const char* const title) override
{ {
d_stdout("titleChanged %s", title); d_stdout("titleChanged %s", title);
@@ -347,7 +368,8 @@ protected:


[pool release]; [pool release];
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
/*MSG msg;
/*
MSG msg;
if (! ::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) if (! ::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
return true; return true;


@@ -358,7 +380,8 @@ protected:


//TranslateMessage(&msg); //TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
}*/
}
*/
#else #else
if (fDisplay == nullptr) if (fDisplay == nullptr)
return; return;


Loading…
Cancel
Save