@@ -90,48 +90,48 @@ static const uint32_t kParameterIsOutput = 0x10; | |||||
When changing this struct values you must ensure maximum > minimum and default is within range. | When changing this struct values you must ensure maximum > minimum and default is within range. | ||||
*/ | */ | ||||
struct ParameterRanges { | struct ParameterRanges { | ||||
/** | |||||
Default value. | |||||
*/ | |||||
/** | |||||
Default value. | |||||
*/ | |||||
float def; | float def; | ||||
/** | |||||
Minimum value. | |||||
*/ | |||||
/** | |||||
Minimum value. | |||||
*/ | |||||
float min; | float min; | ||||
/** | |||||
Maximum value. | |||||
*/ | |||||
/** | |||||
Maximum value. | |||||
*/ | |||||
float max; | float max; | ||||
/** | |||||
Default constructor. | |||||
*/ | |||||
/** | |||||
Default constructor. | |||||
*/ | |||||
ParameterRanges() noexcept | ParameterRanges() noexcept | ||||
: def(0.0f), | : def(0.0f), | ||||
min(0.0f), | min(0.0f), | ||||
max(1.0f) {} | max(1.0f) {} | ||||
/** | |||||
Constructor using custom values. | |||||
*/ | |||||
/** | |||||
Constructor using custom values. | |||||
*/ | |||||
ParameterRanges(const float df, const float mn, const float mx) noexcept | ParameterRanges(const float df, const float mn, const float mx) noexcept | ||||
: def(df), | : def(df), | ||||
min(mn), | min(mn), | ||||
max(mx) {} | max(mx) {} | ||||
/** | |||||
Fix the default value within range. | |||||
*/ | |||||
/** | |||||
Fix the default value within range. | |||||
*/ | |||||
void fixDefault() noexcept | void fixDefault() noexcept | ||||
{ | { | ||||
fixValue(def); | fixValue(def); | ||||
} | } | ||||
/** | |||||
Fix a value within range. | |||||
*/ | |||||
/** | |||||
Fix a value within range. | |||||
*/ | |||||
void fixValue(float& value) const noexcept | void fixValue(float& value) const noexcept | ||||
{ | { | ||||
if (value < min) | if (value < min) | ||||
@@ -140,9 +140,9 @@ struct ParameterRanges { | |||||
value = max; | value = max; | ||||
} | } | ||||
/** | |||||
Get a fixed value within range. | |||||
*/ | |||||
/** | |||||
Get a fixed value within range. | |||||
*/ | |||||
const float& getFixedValue(const float& value) const noexcept | const float& getFixedValue(const float& value) const noexcept | ||||
{ | { | ||||
if (value <= min) | if (value <= min) | ||||
@@ -152,9 +152,9 @@ struct ParameterRanges { | |||||
return value; | return value; | ||||
} | } | ||||
/** | |||||
Get a value normalized to 0.0<->1.0. | |||||
*/ | |||||
/** | |||||
Get a value normalized to 0.0<->1.0. | |||||
*/ | |||||
float getNormalizedValue(const float& value) const noexcept | float getNormalizedValue(const float& value) const noexcept | ||||
{ | { | ||||
const float normValue((value - min) / (max - min)); | const float normValue((value - min) / (max - min)); | ||||
@@ -166,9 +166,9 @@ struct ParameterRanges { | |||||
return normValue; | return normValue; | ||||
} | } | ||||
/** | |||||
Get a value normalized to 0.0<->1.0, fixed within range. | |||||
*/ | |||||
/** | |||||
Get a value normalized to 0.0<->1.0, fixed within range. | |||||
*/ | |||||
float getFixedAndNormalizedValue(const float& value) const noexcept | float getFixedAndNormalizedValue(const float& value) const noexcept | ||||
{ | { | ||||
if (value <= min) | if (value <= min) | ||||
@@ -186,9 +186,9 @@ struct ParameterRanges { | |||||
return normValue; | return normValue; | ||||
} | } | ||||
/** | |||||
Get a proper value previously normalized to 0.0<->1.0. | |||||
*/ | |||||
/** | |||||
Get a proper value previously normalized to 0.0<->1.0. | |||||
*/ | |||||
float getUnnormalizedValue(const float& value) const noexcept | float getUnnormalizedValue(const float& value) const noexcept | ||||
{ | { | ||||
if (value <= 0.0f) | if (value <= 0.0f) | ||||
@@ -204,43 +204,43 @@ struct ParameterRanges { | |||||
Parameter. | Parameter. | ||||
*/ | */ | ||||
struct Parameter { | struct Parameter { | ||||
/** | |||||
Hints describing this parameter. | |||||
@see ParameterHints | |||||
*/ | |||||
/** | |||||
Hints describing this parameter. | |||||
@see ParameterHints | |||||
*/ | |||||
uint32_t hints; | uint32_t hints; | ||||
/** | |||||
The name of this parameter. | |||||
A parameter name can contain any character, but hosts might have a hard time with non-ascii ones. | |||||
The name doesn't have to be unique within a plugin instance, but it's recommended. | |||||
*/ | |||||
/** | |||||
The name of this parameter. | |||||
A parameter name can contain any character, but hosts might have a hard time with non-ascii ones. | |||||
The name doesn't have to be unique within a plugin instance, but it's recommended. | |||||
*/ | |||||
d_string name; | d_string name; | ||||
/** | |||||
The symbol of this parameter. | |||||
A parameter symbol is a short restricted name used as a machine and human readable identifier. | |||||
The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9. | |||||
@note: Parameter symbols MUST be unique within a plugin instance. | |||||
*/ | |||||
/** | |||||
The symbol of this parameter. | |||||
A parameter symbol is a short restricted name used as a machine and human readable identifier. | |||||
The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9. | |||||
@note: Parameter symbols MUST be unique within a plugin instance. | |||||
*/ | |||||
d_string symbol; | d_string symbol; | ||||
/** | |||||
The unit of this parameter. | |||||
This means something like "dB", "kHz" and "ms". | |||||
Can be left blank if units do not apply to this parameter. | |||||
*/ | |||||
/** | |||||
The unit of this parameter. | |||||
This means something like "dB", "kHz" and "ms". | |||||
Can be left blank if units do not apply to this parameter. | |||||
*/ | |||||
d_string unit; | d_string unit; | ||||
/** | |||||
Ranges of this parameter. | |||||
The ranges describe the default, minimum and maximum values. | |||||
*/ | |||||
/** | |||||
Ranges of this parameter. | |||||
The ranges describe the default, minimum and maximum values. | |||||
*/ | |||||
ParameterRanges ranges; | ParameterRanges ranges; | ||||
/** | |||||
Default constructor for a null parameter. | |||||
*/ | |||||
/** | |||||
Default constructor for a null parameter. | |||||
*/ | |||||
Parameter() noexcept | Parameter() noexcept | ||||
: hints(0x0), | : hints(0x0), | ||||
name(), | name(), | ||||
@@ -253,25 +253,25 @@ struct Parameter { | |||||
MIDI event. | MIDI event. | ||||
*/ | */ | ||||
struct MidiEvent { | struct MidiEvent { | ||||
/** | |||||
Size of internal data. | |||||
*/ | |||||
/** | |||||
Size of internal data. | |||||
*/ | |||||
static const uint32_t kDataSize = 4; | static const uint32_t kDataSize = 4; | ||||
/** | |||||
Time offset in frames. | |||||
*/ | |||||
/** | |||||
Time offset in frames. | |||||
*/ | |||||
uint32_t frame; | uint32_t frame; | ||||
/** | |||||
Number of bytes used. | |||||
*/ | |||||
/** | |||||
Number of bytes used. | |||||
*/ | |||||
uint32_t size; | uint32_t size; | ||||
/** | |||||
MIDI data. | |||||
If size > kDataSize, dataExt is used (otherwise null). | |||||
*/ | |||||
/** | |||||
MIDI data. | |||||
If size > kDataSize, dataExt is used (otherwise null). | |||||
*/ | |||||
uint8_t data[kDataSize]; | uint8_t data[kDataSize]; | ||||
const uint8_t* dataExt; | const uint8_t* dataExt; | ||||
}; | }; | ||||
@@ -366,9 +366,9 @@ struct TimePosition { | |||||
beatsPerMinute(0.0) {} | beatsPerMinute(0.0) {} | ||||
} bbt; | } bbt; | ||||
/** | |||||
Default constructor for a time position. | |||||
*/ | |||||
/** | |||||
Default constructor for a time position. | |||||
*/ | |||||
TimePosition() noexcept | TimePosition() noexcept | ||||
: playing(false), | : playing(false), | ||||
frame(0), | frame(0), | ||||
@@ -627,7 +627,7 @@ private: | |||||
*/ | */ | ||||
extern Plugin* createPlugin(); | extern Plugin* createPlugin(); | ||||
// ----------------------------------------------------------------------- | |||||
// ----------------------------------------------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO | END_NAMESPACE_DISTRHO | ||||
@@ -41,9 +41,7 @@ START_NAMESPACE_DISTRHO | |||||
TODO. | TODO. | ||||
you should not have to call setSize during construction, | |||||
that is handled by d_initSize | |||||
if you want to change size later on you should use setSize and then d_setSize to report to host | |||||
must call setSize during construction, | |||||
*/ | */ | ||||
class UI : public UIWidget | class UI : public UIWidget | ||||
{ | { | ||||
@@ -59,7 +57,7 @@ public: | |||||
virtual ~UI(); | virtual ~UI(); | ||||
/* -------------------------------------------------------------------------------------------------------- | /* -------------------------------------------------------------------------------------------------------- | ||||
* Host DSP state */ | |||||
* Host state */ | |||||
/** | /** | ||||
Get the current sample rate used in plugin processing. | Get the current sample rate used in plugin processing. | ||||
@@ -91,15 +89,6 @@ public: | |||||
void d_sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity); | void d_sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity); | ||||
#endif | #endif | ||||
/* -------------------------------------------------------------------------------------------------------- | |||||
* Host UI state */ | |||||
/** | |||||
TODO: Document this. | |||||
never call this from the constructor | |||||
*/ | |||||
void d_setSize(const uint width, const uint height); | |||||
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | ||||
/* -------------------------------------------------------------------------------------------------------- | /* -------------------------------------------------------------------------------------------------------- | ||||
* Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!! */ | * Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!! */ | ||||
@@ -111,16 +100,6 @@ public: | |||||
#endif | #endif | ||||
protected: | protected: | ||||
/* -------------------------------------------------------------------------------------------------------- | |||||
* Init */ | |||||
/** | |||||
Set the initial UI size. | |||||
This function will be called once, shortly after the UI is created. | |||||
@see d_setSize(uint,uint) | |||||
*/ | |||||
virtual void d_initSize(uint& width, uint& height) = 0; | |||||
/* -------------------------------------------------------------------------------------------------------- | /* -------------------------------------------------------------------------------------------------------- | ||||
* DSP/Plugin Callbacks */ | * DSP/Plugin Callbacks */ | ||||
@@ -165,13 +144,31 @@ protected: | |||||
#if ! DISTRHO_UI_USE_NTK | #if ! DISTRHO_UI_USE_NTK | ||||
/** | /** | ||||
OpenGL reshape function, called when the host window is resized. | |||||
OpenGL window reshape function, called when parent window is resized. | |||||
You can reimplement this function for a custom OpenGL state. | You can reimplement this function for a custom OpenGL state. | ||||
@see Window::onReshape(uint,uint) | @see Window::onReshape(uint,uint) | ||||
*/ | */ | ||||
virtual void d_uiReshape(uint width, uint height); | virtual void d_uiReshape(uint width, uint height); | ||||
#endif | #endif | ||||
/* -------------------------------------------------------------------------------------------------------- | |||||
* UI Resize Handling, internal */ | |||||
#if DISTRHO_UI_USE_NTK | |||||
/** | |||||
NTK widget resize function, called when the widget is resized. | |||||
This is overriden here so the host knows when the UI is resized by you. | |||||
*/ | |||||
void resize(int x, int y, int w, int h) override; | |||||
#else | |||||
/** | |||||
OpenGL widget resize function, called when the widget is resized. | |||||
This is overriden here so the host knows when the UI is resized by you. | |||||
@see Widget::onResize(const ResizeEvent&) | |||||
*/ | |||||
void onResize(const ResizeEvent& ev) override; | |||||
#endif | |||||
// ------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------- | ||||
private: | private: | ||||
@@ -51,7 +51,7 @@ inline float | |||||
// misc functions | // misc functions | ||||
static inline | static inline | ||||
long d_cconst(const int a, const int b, const int c, const int d) noexcept | |||||
int64_t d_cconst(const int a, const int b, const int c, const int d) noexcept | |||||
{ | { | ||||
return (a << 24) | (b << 16) | (c << 8) | (d << 0); | return (a << 24) | (b << 16) | (c << 8) | (d << 0); | ||||
} | } | ||||
@@ -18,20 +18,20 @@ | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
// ----------------------------------------------------------------------- | |||||
// Static data, see DistrhoPluginInternal.hpp | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Static data, see DistrhoPluginInternal.hpp */ | |||||
uint32_t d_lastBufferSize = 0; | uint32_t d_lastBufferSize = 0; | ||||
double d_lastSampleRate = 0.0; | double d_lastSampleRate = 0.0; | ||||
// ----------------------------------------------------------------------- | |||||
// Static fallback data, see DistrhoPluginInternal.hpp | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Static fallback data, see DistrhoPluginInternal.hpp */ | |||||
const d_string PluginExporter::sFallbackString; | const d_string PluginExporter::sFallbackString; | ||||
const ParameterRanges PluginExporter::sFallbackRanges; | const ParameterRanges PluginExporter::sFallbackRanges; | ||||
// ----------------------------------------------------------------------- | |||||
// Plugin | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Plugin */ | |||||
Plugin::Plugin(const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount) | Plugin::Plugin(const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount) | ||||
: pData(new PrivateData()) | : pData(new PrivateData()) | ||||
@@ -68,8 +68,8 @@ Plugin::~Plugin() | |||||
delete pData; | delete pData; | ||||
} | } | ||||
// ----------------------------------------------------------------------- | |||||
// Host state | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Host state */ | |||||
uint32_t Plugin::d_getBufferSize() const noexcept | uint32_t Plugin::d_getBufferSize() const noexcept | ||||
{ | { | ||||
@@ -84,9 +84,6 @@ double Plugin::d_getSampleRate() const noexcept | |||||
#if DISTRHO_PLUGIN_WANT_TIMEPOS | #if DISTRHO_PLUGIN_WANT_TIMEPOS | ||||
const TimePos& Plugin::d_getTimePos() const noexcept | const TimePos& Plugin::d_getTimePos() const noexcept | ||||
{ | { | ||||
// timePos outside run() may not be valid | |||||
DISTRHO_SAFE_ASSERT(pData->isProcessing); | |||||
return pData->timePos; | return pData->timePos; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -106,12 +103,12 @@ bool Plugin::d_writeMidiEvent(const MidiEvent& /*midiEvent*/) noexcept | |||||
} | } | ||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | |||||
// Callbacks (optional) | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Callbacks (optional) */ | |||||
void Plugin::d_bufferSizeChanged(uint32_t) {} | void Plugin::d_bufferSizeChanged(uint32_t) {} | ||||
void Plugin::d_sampleRateChanged(double) {} | void Plugin::d_sampleRateChanged(double) {} | ||||
// ----------------------------------------------------------------------- | |||||
// ----------------------------------------------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO | END_NAMESPACE_DISTRHO |
@@ -105,9 +105,9 @@ public: | |||||
jack_activate(fClient); | jack_activate(fClient); | ||||
if (const char* const name = jack_get_client_name(fClient)) | if (const char* const name = jack_get_client_name(fClient)) | ||||
fUI.setTitle(name); | |||||
fUI.setWindowTitle(name); | |||||
else | else | ||||
fUI.setTitle(fPlugin.getName()); | |||||
fUI.setWindowTitle(fPlugin.getName()); | |||||
fUI.exec(this); | fUI.exec(this); | ||||
} | } | ||||
@@ -295,7 +295,7 @@ protected: | |||||
void setSize(const uint width, const uint height) | void setSize(const uint width, const uint height) | ||||
{ | { | ||||
fUI.setSize(width, height); | |||||
fUI.setWindowSize(width, height); | |||||
} | } | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -217,7 +217,7 @@ protected: | |||||
void setSize(const uint width, const uint height) | void setSize(const uint width, const uint height) | ||||
{ | { | ||||
fUI.setSize(width, height); | |||||
fUI.setWindowSize(width, height); | |||||
hostCallback(audioMasterSizeWindow, width, height, nullptr, 0.0f); | hostCallback(audioMasterSizeWindow, width, height, nullptr, 0.0f); | ||||
} | } | ||||
@@ -18,15 +18,15 @@ | |||||
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; | void* d_lastUiDspPtr = nullptr; | ||||
UIWindow* d_lastUiWindow = nullptr; | UIWindow* d_lastUiWindow = nullptr; | ||||
// ----------------------------------------------------------------------- | |||||
// UI | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* UI */ | |||||
UI::UI() | UI::UI() | ||||
: UIWidget(*d_lastUiWindow), | : UIWidget(*d_lastUiWindow), | ||||
@@ -40,8 +40,8 @@ UI::~UI() | |||||
delete pData; | delete pData; | ||||
} | } | ||||
// ----------------------------------------------------------------------- | |||||
// Host DSP State | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Host state */ | |||||
double UI::d_getSampleRate() const noexcept | double UI::d_getSampleRate() const noexcept | ||||
{ | { | ||||
@@ -72,17 +72,9 @@ void UI::d_sendNote(const uint8_t channel, const uint8_t note, const uint8_t vel | |||||
} | } | ||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | |||||
// Host UI State | |||||
void UI::d_setSize(const uint width, const uint height) | |||||
{ | |||||
pData->setSizeCallback(width, height); | |||||
} | |||||
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | ||||
// ----------------------------------------------------------------------- | |||||
// Direct DSP access | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* Direct DSP access */ | |||||
void* UI::d_getPluginInstancePointer() const noexcept | void* UI::d_getPluginInstancePointer() const noexcept | ||||
{ | { | ||||
@@ -90,13 +82,13 @@ void* UI::d_getPluginInstancePointer() const noexcept | |||||
} | } | ||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | |||||
// DSP Callbacks (optional) | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* DSP/Plugin Callbacks (optional) */ | |||||
void UI::d_sampleRateChanged(double) {} | void UI::d_sampleRateChanged(double) {} | ||||
// ----------------------------------------------------------------------- | |||||
// UI Callbacks (optional) | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* UI Callbacks (optional) */ | |||||
#if ! DISTRHO_UI_USE_NTK | #if ! DISTRHO_UI_USE_NTK | ||||
void UI::d_uiReshape(uint width, uint height) | void UI::d_uiReshape(uint width, uint height) | ||||
@@ -112,6 +104,22 @@ void UI::d_uiReshape(uint width, uint height) | |||||
} | } | ||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | |||||
/* ------------------------------------------------------------------------------------------------------------ | |||||
* UI Resize Handling, internal */ | |||||
#if DISTRHO_UI_USE_NTK | |||||
void UI::resize(int x, int y, int w, int h) | |||||
{ | |||||
UIWidget::resize(x, y w, h); | |||||
pData->setSizeCallback(w, h); | |||||
} | |||||
#else | |||||
void UI::onResize(const ResizeEvent& ev) | |||||
{ | |||||
pData->setSizeCallback(ev.size.getWidth(), ev.size.getHeight()); | |||||
} | |||||
#endif | |||||
// ----------------------------------------------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO | END_NAMESPACE_DISTRHO |
@@ -97,7 +97,7 @@ public: | |||||
fHostClosed(false), | fHostClosed(false), | ||||
fOscData(oscData) | fOscData(oscData) | ||||
{ | { | ||||
fUI.setTitle(uiTitle); | |||||
fUI.setWindowTitle(uiTitle); | |||||
} | } | ||||
~UIDssi() | ~UIDssi() | ||||
@@ -147,12 +147,12 @@ public: | |||||
void dssiui_show() | void dssiui_show() | ||||
{ | { | ||||
fUI.setVisible(true); | |||||
fUI.setWindowVisible(true); | |||||
} | } | ||||
void dssiui_hide() | void dssiui_hide() | ||||
{ | { | ||||
fUI.setVisible(false); | |||||
fUI.setWindowVisible(false); | |||||
} | } | ||||
void dssiui_quit() | void dssiui_quit() | ||||
@@ -195,7 +195,7 @@ protected: | |||||
void setSize(const uint width, const uint height) | void setSize(const uint width, const uint height) | ||||
{ | { | ||||
fUI.setSize(width, height); | |||||
fUI.setWindowSize(width, height); | |||||
} | } | ||||
private: | private: | ||||
@@ -62,10 +62,6 @@ struct UI::PrivateData { | |||||
void* dspPtr; | void* dspPtr; | ||||
#endif | #endif | ||||
// UI | |||||
uint initialWidth; | |||||
uint initialHeight; | |||||
// Callbacks | // Callbacks | ||||
editParamFunc editParamCallbackFunc; | editParamFunc editParamCallbackFunc; | ||||
setParamFunc setParamCallbackFunc; | setParamFunc setParamCallbackFunc; | ||||
@@ -80,8 +76,6 @@ struct UI::PrivateData { | |||||
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS | ||||
dspPtr(d_lastUiDspPtr), | dspPtr(d_lastUiDspPtr), | ||||
#endif | #endif | ||||
initialWidth(0), | |||||
initialHeight(0), | |||||
editParamCallbackFunc(nullptr), | editParamCallbackFunc(nullptr), | ||||
setParamCallbackFunc(nullptr), | setParamCallbackFunc(nullptr), | ||||
setStateCallbackFunc(nullptr), | setStateCallbackFunc(nullptr), | ||||
@@ -134,9 +128,6 @@ struct UI::PrivateData { | |||||
void setSizeCallback(const uint width, const uint height) | void setSizeCallback(const uint width, const uint height) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(initialWidth != 0,); | |||||
DISTRHO_SAFE_ASSERT_RETURN(initialHeight != 0,); | |||||
if (setSizeCallbackFunc != nullptr) | if (setSizeCallbackFunc != nullptr) | ||||
setSizeCallbackFunc(ptr, width, height); | setSizeCallbackFunc(ptr, width, height); | ||||
} | } | ||||
@@ -166,15 +157,9 @@ public: | |||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | ||||
uint width = 0, height = 0; | |||||
fUI->d_initSize(width, height); | |||||
// set widget size | |||||
fUI->setSize(width, height); | |||||
// set window size | // set window size | ||||
setResizable(false); | setResizable(false); | ||||
setSize(width, height); | |||||
setSize(fUI->getWidth(), fUI->getHeight()); | |||||
} | } | ||||
~UIExporterWindow() | ~UIExporterWindow() | ||||
@@ -205,9 +190,10 @@ protected: | |||||
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); | ||||
// report size change to plugin UI | // report size change to plugin UI | ||||
fUI->setSize(width, height); | |||||
// TESTING is this needed? | |||||
//fUI->setSize(width, height); | |||||
// update openGL state | |||||
// custom window reshape | |||||
fUI->d_uiReshape(width, height); | fUI->d_uiReshape(width, height); | ||||
fIsReady = true; | fIsReady = true; | ||||
@@ -256,6 +242,11 @@ public: | |||||
return glWindow.getHeight(); | return glWindow.getHeight(); | ||||
} | } | ||||
bool isVisible() const noexcept | |||||
{ | |||||
return glWindow.isVisible(); | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
uint32_t getParameterOffset() const noexcept | uint32_t getParameterOffset() const noexcept | ||||
@@ -324,39 +315,38 @@ public: | |||||
return ! glApp.isQuiting(); | return ! glApp.isQuiting(); | ||||
} | } | ||||
bool isVisible() const noexcept | |||||
{ | |||||
return glWindow.isVisible(); | |||||
} | |||||
void quit() | void quit() | ||||
{ | { | ||||
glWindow.close(); | glWindow.close(); | ||||
glApp.quit(); | glApp.quit(); | ||||
} | } | ||||
void setSize(const uint width, const uint height) | |||||
// ------------------------------------------------------------------- | |||||
void setWindowSize(const uint width, const uint height) | |||||
{ | { | ||||
glWindow.setSize(width, height); | glWindow.setSize(width, height); | ||||
} | } | ||||
void setTitle(const char* const uiTitle) | |||||
void setWindowTitle(const char* const uiTitle) | |||||
{ | { | ||||
glWindow.setTitle(uiTitle); | glWindow.setTitle(uiTitle); | ||||
} | } | ||||
void setTransientWinId(const intptr_t winId) | |||||
void setWindowTransientWinId(const intptr_t winId) | |||||
{ | { | ||||
glWindow.setTransientWinId(winId); | glWindow.setTransientWinId(winId); | ||||
} | } | ||||
bool setVisible(const bool yesNo) | |||||
bool setWindowVisible(const bool yesNo) | |||||
{ | { | ||||
glWindow.setVisible(yesNo); | glWindow.setVisible(yesNo); | ||||
return ! glApp.isQuiting(); | return ! glApp.isQuiting(); | ||||
} | } | ||||
// ------------------------------------------------------------------- | |||||
void setSampleRate(const double sampleRate, const bool doCallback = false) | void setSampleRate(const double sampleRate, const bool doCallback = false) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,); | ||||
@@ -70,7 +70,7 @@ public: | |||||
if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Long)) | if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Long)) | ||||
{ | { | ||||
if (const int64_t frontendWinId = *(const int64_t*)options[i].value) | if (const int64_t frontendWinId = *(const int64_t*)options[i].value) | ||||
fUI.setTransientWinId(static_cast<intptr_t>(frontendWinId)); | |||||
fUI.setWindowTransientWinId(static_cast<intptr_t>(frontendWinId)); | |||||
} | } | ||||
else | else | ||||
d_stderr("Host provides frontendWinId but has wrong value type"); | d_stderr("Host provides frontendWinId but has wrong value type"); | ||||
@@ -82,7 +82,7 @@ public: | |||||
if (const char* const windowTitle = (const char*)options[i].value) | if (const char* const windowTitle = (const char*)options[i].value) | ||||
{ | { | ||||
hasTitle = true; | hasTitle = true; | ||||
fUI.setTitle(windowTitle); | |||||
fUI.setWindowTitle(windowTitle); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -91,7 +91,7 @@ public: | |||||
} | } | ||||
if (! hasTitle) | if (! hasTitle) | ||||
fUI.setTitle(DISTRHO_PLUGIN_NAME); | |||||
fUI.setWindowTitle(DISTRHO_PLUGIN_NAME); | |||||
} | } | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -138,12 +138,12 @@ public: | |||||
int lv2ui_show() | int lv2ui_show() | ||||
{ | { | ||||
return fUI.setVisible(true) ? 0 : 1; | |||||
return fUI.setWindowVisible(true) ? 0 : 1; | |||||
} | } | ||||
int lv2ui_hide() | int lv2ui_hide() | ||||
{ | { | ||||
return fUI.setVisible(false) ? 0 : 1; | |||||
return fUI.setWindowVisible(false) ? 0 : 1; | |||||
} | } | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -211,7 +211,7 @@ protected: | |||||
void setSize(const uint width, const uint height) | void setSize(const uint width, const uint height) | ||||
{ | { | ||||
fUI.setSize(width, height); | |||||
fUI.setWindowSize(width, height); | |||||
if (fUiResize != nullptr && ! fWinIdWasNull) | if (fUiResize != nullptr && ! fWinIdWasNull) | ||||
fUiResize->ui_resize(fUiResize->handle, width, height); | fUiResize->ui_resize(fUiResize->handle, width, height); | ||||