diff --git a/.gitmodules b/.gitmodules index 7850d1b81..7c9ca8e25 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,7 +18,7 @@ [submodule "vst/external/VST_SDK/VST3_SDK/vstgui4"] path = plugins/editor/external/vstgui4 url = https://github.com/sfztools/vstgui.git - shallow = true + branch = vstgui4_10_2-hotfix [submodule "external/st_audiofile/thirdparty/dr_libs"] path = external/st_audiofile/thirdparty/dr_libs url = https://github.com/mackron/dr_libs.git diff --git a/plugins/editor/cmake/Vstgui.cmake b/plugins/editor/cmake/Vstgui.cmake index 8f7ebe252..77c2d5811 100644 --- a/plugins/editor/cmake/Vstgui.cmake +++ b/plugins/editor/cmake/Vstgui.cmake @@ -1,3 +1,11 @@ +# Find vstgui version +FILE(READ ${VSTGUI_BASEDIR}/vstgui/lib/vstguibase.h VSTGUIBASE_HEADER) +string(REGEX MATCH "\#define VSTGUI_VERSION_MAJOR ([0-9]*)" _ ${VSTGUIBASE_HEADER}) +set(VSTGUI_VERSION_MAJOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "\#define VSTGUI_VERSION_MINOR ([0-9]*)" _ ${VSTGUIBASE_HEADER}) +set(VSTGUI_VERSION_MINOR ${CMAKE_MATCH_1}) +set(VSTGUI_VERSION "${VSTGUI_VERSION_MAJOR}.${VSTGUI_VERSION_MINOR}") + add_library(sfizz_vstgui STATIC EXCLUDE_FROM_ALL "${VSTGUI_BASEDIR}/vstgui/lib/animation/animations.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/animation/animator.cpp" @@ -39,7 +47,6 @@ add_library(sfizz_vstgui STATIC EXCLUDE_FROM_ALL "${VSTGUI_BASEDIR}/vstgui/lib/cfileselector.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cfont.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cframe.cpp" - "${VSTGUI_BASEDIR}/vstgui/lib/cgradient.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cgradientview.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cgraphicspath.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/clayeredviewcontainer.cpp" @@ -58,12 +65,17 @@ add_library(sfizz_vstgui STATIC EXCLUDE_FROM_ALL "${VSTGUI_BASEDIR}/vstgui/lib/cview.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cviewcontainer.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/cvstguitimer.cpp" - "${VSTGUI_BASEDIR}/vstgui/lib/events.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/genericstringlistdatabrowsersource.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/pixelbuffer.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/vstguidebug.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/vstguiinit.cpp") +if(${VSTGUI_VERSION} VERSION_GREATER "4.10") + target_sources(sfizz_vstgui PRIVATE + ${VSTGUI_BASEDIR}/vstgui/lib/cgradient.cpp + ${VSTGUI_BASEDIR}/vstgui/lib/events.cpp) +endif() + add_library(sfizz::vstgui ALIAS sfizz_vstgui) if(WIN32) @@ -71,7 +83,6 @@ if(WIN32) "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dbitmap.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2ddrawcontext.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dfont.cpp" - "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dgradient.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dgraphicspath.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/win32datapackage.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/win32dragging.cpp" @@ -85,6 +96,10 @@ if(WIN32) "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/winfileselector.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/winstring.cpp" "${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/wintimer.cpp") + if(${VSTGUI_VERSION} VERSION_GREATER "4.10") + target_sources(sfizz_vstgui PRIVATE + ${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dgradient.cpp) + endif() elseif(APPLE) target_sources(sfizz_vstgui PRIVATE "${VSTGUI_BASEDIR}/vstgui/lib/platform/mac/carbon/hiviewframe.cpp" diff --git a/plugins/editor/external/vstgui4 b/plugins/editor/external/vstgui4 index 0db8738ae..c1d411b86 160000 --- a/plugins/editor/external/vstgui4 +++ b/plugins/editor/external/vstgui4 @@ -1 +1 @@ -Subproject commit 0db8738ae73ff76842eb0bfe90cdf2039690a5b5 +Subproject commit c1d411b86c42ef0502a10509d540999f3e617252 diff --git a/plugins/editor/src/editor/GUIHelpers.cpp b/plugins/editor/src/editor/GUIHelpers.cpp index 901891b5c..634101726 100644 --- a/plugins/editor/src/editor/GUIHelpers.cpp +++ b/plugins/editor/src/editor/GUIHelpers.cpp @@ -5,9 +5,12 @@ // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz #include "GUIHelpers.h" +#define VSTGUI_MORE_THAN_4_10 ((VSTGUI_VERSION_MAJOR > 4) || (VSTGUI_VERSION_MAJOR == 4 && VSTGUI_VERSION_MINOR > 10)) +#if VSTGUI_MORE_THAN_4_10 #include "utility/vstgui_before.h" #include #include "utility/vstgui_after.h" +#endif class SFrameDisabler::KeyAndMouseHook : public CBaseObject, public IKeyboardHook, @@ -16,10 +19,17 @@ class SFrameDisabler::KeyAndMouseHook : public CBaseObject, void setEnabled(bool value) { enabled_ = value; } protected: + void onMouseEntered(CView*, CFrame*) override {} + void onMouseExited(CView*, CFrame*) override {} +#if VSTGUI_MORE_THAN_4_10 void onKeyboardEvent(KeyboardEvent& event, CFrame* frame) override; - void onMouseEntered(CView* view, CFrame* frame) override {} - void onMouseExited(CView* view, CFrame* frame) override {} void onMouseEvent(MouseEvent& event, CFrame* frame) override; +#else + int32_t onKeyDown(const VstKeyCode&, CFrame*) { return enabled_ ? -1 : 1; } + int32_t onKeyUp(const VstKeyCode&, CFrame*) { return enabled_ ? -1 : 1; } + CMouseEventResult onMouseMoved(CFrame*, const CPoint&, const CButtonState&) { return enabled_ ? kMouseEventNotHandled : kMouseEventHandled; } + CMouseEventResult onMouseDown(CFrame*, const CPoint&, const CButtonState&) { return enabled_ ? kMouseEventNotHandled : kMouseEventHandled; } +#endif private: bool enabled_ = true; @@ -53,6 +63,7 @@ void SFrameDisabler::disable() delayedEnabler_->stop(); } +#if VSTGUI_MORE_THAN_4_10 void SFrameDisabler::KeyAndMouseHook::onKeyboardEvent(KeyboardEvent& event, CFrame* frame) { if (!enabled_) @@ -64,3 +75,4 @@ void SFrameDisabler::KeyAndMouseHook::onMouseEvent(MouseEvent& event, CFrame* fr if (!enabled_) event.consumed = true; } +#endif