Browse Source

Share some VST3 code with CLAP

pull/321/merge
falkTX 3 years ago
parent
commit
1e77b51272
5 changed files with 28 additions and 23 deletions
  1. +2
    -2
      distrho/src/DistrhoPluginVST2.cpp
  2. +5
    -5
      distrho/src/DistrhoUI.cpp
  3. +11
    -11
      distrho/src/DistrhoUIInternal.hpp
  4. +3
    -3
      distrho/src/DistrhoUIPrivateData.hpp
  5. +7
    -2
      distrho/src/DistrhoUIVST3.cpp

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

@@ -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]))


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

@@ -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



+ 11
- 11
distrho/src/DistrhoUIInternal.hpp View File

@@ -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)
{


+ 3
- 3
distrho/src/DistrhoUIPrivateData.hpp View File

@@ -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);
}


+ 7
- 2
distrho/src/DistrhoUIVST3.cpp View File

@@ -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;
}



Loading…
Cancel
Save