Browse Source

Fix build of vst3 with external uis

Signed-off-by: falkTX <falktx@falktx.com>
pull/344/head
falkTX 3 years ago
parent
commit
7bed00d806
3 changed files with 45 additions and 24 deletions
  1. +2
    -2
      distrho/src/DistrhoUIInternal.hpp
  2. +42
    -22
      distrho/src/DistrhoUIVST3.cpp
  3. +1
    -0
      examples/EmbedExternalUI/Makefile

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

@@ -254,7 +254,7 @@ public:


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


#if defined(DISTRHO_PLUGIN_TARGET_VST3) && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && defined(DISTRHO_PLUGIN_TARGET_VST3) && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
void addIdleCallbackForVST3(IdleCallback* const cb, const uint timerFrequencyInMs) void addIdleCallbackForVST3(IdleCallback* const cb, const uint timerFrequencyInMs)
{ {
uiData->window->addIdleCallback(cb, timerFrequencyInMs); uiData->window->addIdleCallback(cb, timerFrequencyInMs);
@@ -281,8 +281,8 @@ public:
{ {
ui->setSize(width, height); ui->setSize(width, height);
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI # if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
// NOTE in external uis, the ui and window refer to the same object
uiData->window->setSize(width, height); uiData->window->setSize(width, height);
// uiData->app.idle();
# endif # endif
} }
#endif #endif


+ 42
- 22
distrho/src/DistrhoUIVST3.cpp View File

@@ -125,7 +125,7 @@ static bool applyGeometryConstraints(const uint minimumWidth, const uint minimum
* The low-level VST3 stuff comes after. * The low-level VST3 stuff comes after.
*/ */
class UIVst3 class UIVst3
#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
: public IdleCallback : public IdleCallback
#endif #endif
{ {
@@ -162,7 +162,7 @@ public:


~UIVst3() ~UIVst3()
{ {
#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
fUI.removeIdleCallbackForVST3(this); fUI.removeIdleCallbackForVST3(this);
#endif #endif
if (fConnection != nullptr) if (fConnection != nullptr)
@@ -177,7 +177,7 @@ public:
if (fConnection != nullptr) if (fConnection != nullptr)
connect(fConnection); connect(fConnection);


#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
fUI.addIdleCallbackForVST3(this, DPF_VST3_TIMER_INTERVAL); fUI.addIdleCallbackForVST3(this, DPF_VST3_TIMER_INTERVAL);
#endif #endif
} }
@@ -185,6 +185,7 @@ public:
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// v3_plugin_view interface calls // v3_plugin_view interface calls


#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
v3_result onWheel(float /*distance*/) v3_result onWheel(float /*distance*/)
{ {
// TODO // TODO
@@ -207,17 +208,17 @@ public:
dglmods |= kModifierShift; dglmods |= kModifierShift;
if (modifiers & (1 << 1)) if (modifiers & (1 << 1))
dglmods |= kModifierAlt; dglmods |= kModifierAlt;
#ifdef DISTRHO_OS_MAC
# ifdef DISTRHO_OS_MAC
if (modifiers & (1 << 2)) if (modifiers & (1 << 2))
dglmods |= kModifierSuper; dglmods |= kModifierSuper;
if (modifiers & (1 << 3)) if (modifiers & (1 << 3))
dglmods |= kModifierControl; dglmods |= kModifierControl;
#else
# else
if (modifiers & (1 << 2)) if (modifiers & (1 << 2))
dglmods |= kModifierControl; dglmods |= kModifierControl;
if (modifiers & (1 << 3)) if (modifiers & (1 << 3))
dglmods |= kModifierSuper; dglmods |= kModifierSuper;
#endif
# endif


return fUI.handlePluginKeyboardVST3(true, static_cast<uint>(keychar), dglcode, dglmods) ? V3_TRUE : V3_FALSE; return fUI.handlePluginKeyboardVST3(true, static_cast<uint>(keychar), dglcode, dglmods) ? V3_TRUE : V3_FALSE;
} }
@@ -238,21 +239,28 @@ public:
dglmods |= kModifierShift; dglmods |= kModifierShift;
if (modifiers & (1 << 1)) if (modifiers & (1 << 1))
dglmods |= kModifierAlt; dglmods |= kModifierAlt;
#ifdef DISTRHO_OS_MAC
# ifdef DISTRHO_OS_MAC
if (modifiers & (1 << 2)) if (modifiers & (1 << 2))
dglmods |= kModifierSuper; dglmods |= kModifierSuper;
if (modifiers & (1 << 3)) if (modifiers & (1 << 3))
dglmods |= kModifierControl; dglmods |= kModifierControl;
#else
# else
if (modifiers & (1 << 2)) if (modifiers & (1 << 2))
dglmods |= kModifierControl; dglmods |= kModifierControl;
if (modifiers & (1 << 3)) if (modifiers & (1 << 3))
dglmods |= kModifierSuper; dglmods |= kModifierSuper;
#endif
# endif


return fUI.handlePluginKeyboardVST3(false, static_cast<uint>(keychar), dglcode, dglmods) ? V3_TRUE : V3_FALSE; return fUI.handlePluginKeyboardVST3(false, static_cast<uint>(keychar), dglcode, dglmods) ? V3_TRUE : V3_FALSE;
} }


v3_result onFocus(const bool state)
{
fUI.notifyFocusChanged(state);
return V3_OK;
}
#endif

v3_result getSize(v3_view_rect* const rect) const noexcept v3_result getSize(v3_view_rect* const rect) const noexcept
{ {
rect->left = rect->top = 0; rect->left = rect->top = 0;
@@ -281,18 +289,6 @@ public:
return V3_OK; return V3_OK;
} }


v3_result onFocus(const bool state)
{
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
fUI.notifyFocusChanged(state);
return V3_OK;
#else
return V3_NOT_IMPLEMENTED;
// unused
(void)state;
#endif
}

v3_result setFrame(v3_plugin_frame** const frame) noexcept v3_result setFrame(v3_plugin_frame** const frame) noexcept
{ {
fFrame = frame; fFrame = frame;
@@ -483,7 +479,7 @@ public:
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// special idle callback on macOS and Windows // special idle callback on macOS and Windows


#if defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS)
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && (defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WINDOWS))
void idleCallback() override void idleCallback() override
{ {
fUI.idleForVST3(); fUI.idleForVST3();
@@ -1205,6 +1201,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp {


static v3_result V3_API on_wheel(void* self, float distance) static v3_result V3_API on_wheel(void* self, float distance)
{ {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
d_stdout("dpf_plugin_view::on_wheel => %p %f", self, distance); d_stdout("dpf_plugin_view::on_wheel => %p %f", self, distance);
dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self); dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self);


@@ -1212,10 +1209,16 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED); DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED);


return uivst3->onWheel(distance); return uivst3->onWheel(distance);
#else
return V3_NOT_IMPLEMENTED;
// unused
(void)self; (void)distance;
#endif
} }


static v3_result V3_API on_key_down(void* self, int16_t key_char, int16_t key_code, int16_t modifiers) static v3_result V3_API on_key_down(void* self, int16_t key_char, int16_t key_code, int16_t modifiers)
{ {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
d_stdout("dpf_plugin_view::on_key_down => %p %i %i %i", self, key_char, key_code, modifiers); d_stdout("dpf_plugin_view::on_key_down => %p %i %i %i", self, key_char, key_code, modifiers);
dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self); dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self);


@@ -1223,10 +1226,16 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED); DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED);


return uivst3->onKeyDown(key_char, key_code, modifiers); return uivst3->onKeyDown(key_char, key_code, modifiers);
#else
return V3_NOT_IMPLEMENTED;
// unused
(void)self; (void)key_char; (void)key_code; (void)modifiers;
#endif
} }


static v3_result V3_API on_key_up(void* self, int16_t key_char, int16_t key_code, int16_t modifiers) static v3_result V3_API on_key_up(void* self, int16_t key_char, int16_t key_code, int16_t modifiers)
{ {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
d_stdout("dpf_plugin_view::on_key_up => %p %i %i %i", self, key_char, key_code, modifiers); d_stdout("dpf_plugin_view::on_key_up => %p %i %i %i", self, key_char, key_code, modifiers);
dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self); dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self);


@@ -1234,6 +1243,11 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED); DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED);


return uivst3->onKeyUp(key_char, key_code, modifiers); return uivst3->onKeyUp(key_char, key_code, modifiers);
#else
return V3_NOT_IMPLEMENTED;
// unused
(void)self; (void)key_char; (void)key_code; (void)modifiers;
#endif
} }


static v3_result V3_API get_size(void* self, v3_view_rect* rect) static v3_result V3_API get_size(void* self, v3_view_rect* rect)
@@ -1268,6 +1282,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp {


static v3_result V3_API on_focus(void* self, v3_bool state) static v3_result V3_API on_focus(void* self, v3_bool state)
{ {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
d_stdout("dpf_plugin_view::on_focus => %p %u", self, state); d_stdout("dpf_plugin_view::on_focus => %p %u", self, state);
dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self); dpf_plugin_view* const view = *static_cast<dpf_plugin_view**>(self);


@@ -1275,6 +1290,11 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED); DISTRHO_SAFE_ASSERT_RETURN(uivst3 != nullptr, V3_NOT_INITIALIZED);


return uivst3->onFocus(state); return uivst3->onFocus(state);
#else
return V3_NOT_IMPLEMENTED;
// unused
(void)self; (void)state;
#endif
} }


static v3_result V3_API set_frame(void* self, v3_plugin_frame** frame) static v3_result V3_API set_frame(void* self, v3_plugin_frame** frame)


+ 1
- 0
examples/EmbedExternalUI/Makefile View File

@@ -35,6 +35,7 @@ TARGETS += jack
TARGETS += dssi TARGETS += dssi
TARGETS += lv2_sep TARGETS += lv2_sep
TARGETS += vst2 TARGETS += vst2
TARGETS += vst3


all: $(TARGETS) all: $(TARGETS)




Loading…
Cancel
Save