DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 1e77b5127220429839a07af6019d544dead73bd2
parent ca3e8b775abeb2e2158ddc3e7c09bfd9082defc4
Author: falkTX <falktx@falktx.com>
Date:   Tue,  6 Sep 2022 16:02:05 +0100

Share some VST3 code with CLAP

Diffstat:
Mdistrho/src/DistrhoPluginVST2.cpp | 4++--
Mdistrho/src/DistrhoUI.cpp | 10+++++-----
Mdistrho/src/DistrhoUIInternal.hpp | 22+++++++++++-----------
Mdistrho/src/DistrhoUIPrivateData.hpp | 6+++---
Mdistrho/src/DistrhoUIVST3.cpp | 9+++++++--
5 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp @@ -65,7 +65,7 @@ START_NAMESPACE_DISTRHO typedef std::map<const String, String> StringMap; -static const int kVstMidiEventSize = static_cast<int>(sizeof(VstMidiEvent)); +static constexpr const int kVstMidiEventSize = static_cast<int>(sizeof(VstMidiEvent)); #if ! DISTRHO_PLUGIN_WANT_MIDI_OUTPUT static const writeMidiFunc writeMidiCallback = nullptr; @@ -1139,7 +1139,7 @@ private: { if (fPlugin.isParameterOutput(i)) { - // NOTE: no output parameter support in VST, simulate it here + // NOTE: no output parameter support in VST2, simulate it here curValue = fPlugin.getParameterValue(i); if (d_isEqual(curValue, parameterValues[i])) diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp @@ -415,19 +415,19 @@ void UI::onResize(const ResizeEvent& ev) #endif } -// NOTE: only used for VST3 +// NOTE: only used for VST3 and CLAP void UI::requestSizeChange(const uint width, const uint height) { -# ifdef DISTRHO_PLUGIN_TARGET_VST3 + #if defined(DISTRHO_PLUGIN_TARGET_VST3) || defined(DISTRHO_PLUGIN_TARGET_CLAP) if (uiData->initializing) - uiData->window->setSizeForVST3(width, height); + uiData->window->setSizeFromHost(width, height); else uiData->setSizeCallback(width, height); -# else + #else // unused (void)width; (void)height; -# endif + #endif } #endif diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -288,24 +288,24 @@ public: void setWindowOffset(const int x, const int y) { -#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI + #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI // TODO (void)x; (void)y; -#else + #else uiData->window->setOffset(x, y); -#endif + #endif } -#ifdef DISTRHO_PLUGIN_TARGET_VST3 - void setWindowSizeForVST3(const uint width, const uint height) + #if defined(DISTRHO_PLUGIN_TARGET_VST3) || defined(DISTRHO_PLUGIN_TARGET_CLAP) + void setWindowSizeFromHost(const uint width, const uint height) { -# if DISTRHO_PLUGIN_HAS_EXTERNAL_UI + #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI ui->setSize(width, height); -# else - uiData->window->setSizeForVST3(width, height); -# endif + #else + uiData->window->setSizeFromHost(width, height); + #endif } -#endif + #endif void setWindowTitle(const char* const uiTitle) { diff --git a/distrho/src/DistrhoUIPrivateData.hpp b/distrho/src/DistrhoUIPrivateData.hpp @@ -215,7 +215,7 @@ public: puglBackendLeave(pData->view); } - // used for temporary windows (VST2/3 get size without active/visible view) + // used for temporary windows (VST/CLAP get size without active/visible view) void setIgnoreIdleCallbacks(const bool ignore = true) { pData->ignoreIdleCallbacks = ignore; @@ -228,8 +228,8 @@ public: puglBackendEnter(pData->view); } - #ifdef DISTRHO_PLUGIN_TARGET_VST3 - void setSizeForVST3(const uint width, const uint height) + #if defined(DISTRHO_PLUGIN_TARGET_VST3) || defined(DISTRHO_PLUGIN_TARGET_CLAP) + void setSizeFromHost(const uint width, const uint height) { puglSetSizeAndDefault(pData->view, width, height); } diff --git a/distrho/src/DistrhoUIVST3.cpp b/distrho/src/DistrhoUIVST3.cpp @@ -80,6 +80,11 @@ static void applyGeometryConstraints(const uint minimumWidth, if (keepAspectRatio) { + if (rect->right < 1) + rect->right = 1; + if (rect->bottom < 1) + rect->bottom = 1; + const double ratio = static_cast<double>(minWidth) / static_cast<double>(minHeight); const double reqRatio = static_cast<double>(rect->right) / static_cast<double>(rect->bottom); @@ -367,7 +372,7 @@ public: if (fUI.getWidth() != nextWidth || fUI.getHeight() != nextHeight) { d_debug("postInit sets new size as %u %u", nextWidth, nextHeight); - fUI.setWindowSizeForVST3(nextWidth, nextHeight); + fUI.setWindowSizeFromHost(nextWidth, nextHeight); } } else if (fNeedsResizeFromPlugin) @@ -475,7 +480,7 @@ public: } fIsResizingFromHost = true; - fUI.setWindowSizeForVST3(rect.right - rect.left, rect.bottom - rect.top); + fUI.setWindowSizeFromHost(rect.right - rect.left, rect.bottom - rect.top); return V3_OK; }