From ac4c4faadc679d6953132e70aea3a4611f3bcad0 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Thu, 16 Jul 2015 14:30:04 -0500 Subject: [PATCH] Round 8 of wx3 changes VST control working on Windows...further changes will be required --- mac/Audacity.xcodeproj/project.pbxproj | 12 ++-- src/effects/VST/VSTControl.h | 11 +-- src/effects/VST/VSTControlMSW.cpp | 69 +++++++++++++++++++ src/effects/VST/VSTControlMSW.h | 39 +++++++++++ .../VST/{VSTControlMac.h => VSTControlOSX.h} | 0 .../{VSTControlMac.mm => VSTControlOSX.mm} | 7 +- src/effects/VST/VSTEffect.cpp | 22 ++++-- src/effects/VST/VSTEffect.h | 30 +------- src/effects/VST/aeffectx.h | 11 +++ win/Projects/Audacity/Audacity.vcxproj | 2 + .../Audacity/Audacity.vcxproj.filters | 6 ++ win/configwin.h | 2 +- 12 files changed, 160 insertions(+), 51 deletions(-) create mode 100644 src/effects/VST/VSTControlMSW.cpp create mode 100644 src/effects/VST/VSTControlMSW.h rename src/effects/VST/{VSTControlMac.h => VSTControlOSX.h} (100%) rename src/effects/VST/{VSTControlMac.mm => VSTControlOSX.mm} (99%) diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj index a214223bb..8f443d329 100644 --- a/mac/Audacity.xcodeproj/project.pbxproj +++ b/mac/Audacity.xcodeproj/project.pbxproj @@ -876,7 +876,7 @@ 2897F6F80AB3DB5A003C20C5 /* ToolsToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2897F6EC0AB3DB5A003C20C5 /* ToolsToolBar.cpp */; }; 2897F6F90AB3DB5A003C20C5 /* TranscriptionToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2897F6EE0AB3DB5A003C20C5 /* TranscriptionToolBar.cpp */; }; 2897F6FE0AB3DCD0003C20C5 /* Grabber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2897F6FC0AB3DCD0003C20C5 /* Grabber.cpp */; }; - 289D127A1B44D57F00B5B6AA /* VSTControlMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 289D12791B44D57F00B5B6AA /* VSTControlMac.mm */; }; + 289D127A1B44D57F00B5B6AA /* VSTControlOSX.mm in Sources */ = {isa = PBXBuildFile; fileRef = 289D12791B44D57F00B5B6AA /* VSTControlOSX.mm */; }; 289E750A1006D0BD00CEF79B /* MixerBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 289E75081006D0BD00CEF79B /* MixerBoard.cpp */; }; 289F9C7E0AC671BB00797DC1 /* DeviceToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 289F9C7C0AC671BB00797DC1 /* DeviceToolBar.cpp */; }; 28A4E2AC0F60319300E9E7F2 /* fftext.c in Sources */ = {isa = PBXBuildFile; fileRef = 28A4E2A40F60319300E9E7F2 /* fftext.c */; }; @@ -2607,8 +2607,8 @@ 2897F6FC0AB3DCD0003C20C5 /* Grabber.cpp */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = Grabber.cpp; sourceTree = ""; tabWidth = 3; }; 2897F6FD0AB3DCD0003C20C5 /* Grabber.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = Grabber.h; sourceTree = ""; tabWidth = 3; }; 289D12771B44D57F00B5B6AA /* VSTControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSTControl.h; path = VST/VSTControl.h; sourceTree = ""; }; - 289D12781B44D57F00B5B6AA /* VSTControlMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSTControlMac.h; path = VST/VSTControlMac.h; sourceTree = ""; }; - 289D12791B44D57F00B5B6AA /* VSTControlMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VSTControlMac.mm; path = VST/VSTControlMac.mm; sourceTree = ""; }; + 289D12781B44D57F00B5B6AA /* VSTControlOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSTControlOSX.h; path = VST/VSTControlOSX.h; sourceTree = ""; }; + 289D12791B44D57F00B5B6AA /* VSTControlOSX.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VSTControlOSX.mm; path = VST/VSTControlOSX.mm; sourceTree = ""; }; 289E75081006D0BD00CEF79B /* MixerBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = MixerBoard.cpp; sourceTree = ""; tabWidth = 3; }; 289E75091006D0BD00CEF79B /* MixerBoard.h */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = MixerBoard.h; sourceTree = ""; tabWidth = 3; }; 289F9C7C0AC671BB00797DC1 /* DeviceToolBar.cpp */ = {isa = PBXFileReference; fileEncoding = 5; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceToolBar.cpp; sourceTree = ""; tabWidth = 3; }; @@ -5302,8 +5302,8 @@ isa = PBXGroup; children = ( 289D12771B44D57F00B5B6AA /* VSTControl.h */, - 289D12781B44D57F00B5B6AA /* VSTControlMac.h */, - 289D12791B44D57F00B5B6AA /* VSTControlMac.mm */, + 289D12781B44D57F00B5B6AA /* VSTControlOSX.h */, + 289D12791B44D57F00B5B6AA /* VSTControlOSX.mm */, 28B97B850FBF771A0076CF28 /* VSTEffect.cpp */, 28B97B860FBF771A0076CF28 /* VSTEffect.h */, 2885BFF10FC108F800128165 /* aeffectx.h */, @@ -7584,7 +7584,7 @@ 2888496F131B6CF600B59735 /* tr.po in Sources */, 28884970131B6CF600B59735 /* uk.po in Sources */, 28884971131B6CF600B59735 /* vi.po in Sources */, - 289D127A1B44D57F00B5B6AA /* VSTControlMac.mm in Sources */, + 289D127A1B44D57F00B5B6AA /* VSTControlOSX.mm in Sources */, 28884972131B6CF600B59735 /* zh_TW.po in Sources */, 28884973131B6CF600B59735 /* zh.po in Sources */, EDF3B7B01588C0D50032D35F /* Paulstretch.cpp in Sources */, diff --git a/src/effects/VST/VSTControl.h b/src/effects/VST/VSTControl.h index 61b5dec41..1c5d2f373 100644 --- a/src/effects/VST/VSTControl.h +++ b/src/effects/VST/VSTControl.h @@ -12,6 +12,7 @@ #define AUDACITY_VSTCONTROL_H #include +#include #include "aeffectx.h" @@ -27,6 +28,8 @@ class VSTControlBase : public wxControl public: VSTControlBase() { + mParent = NULL; + mLink = NULL; } virtual ~VSTControlBase() @@ -37,8 +40,8 @@ public: { mParent = parent; mLink = link; - - if (!wxControl::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxEmptyString)) + + if (!wxControl::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxDefaultValidator, wxEmptyString)) { return false; } @@ -51,8 +54,8 @@ protected: VSTEffectLink *mLink; }; -#if defined(__WXMAC__) -#include "VSTControlMac.h" +#if defined(__WXOSX__) +#include "VSTControlOSX.h" #elif defined(__WXMSW__) #include "VSTControlMSW.h" #elif defined(__WXGTK__) diff --git a/src/effects/VST/VSTControlMSW.cpp b/src/effects/VST/VSTControlMSW.cpp new file mode 100644 index 000000000..c287b6179 --- /dev/null +++ b/src/effects/VST/VSTControlMSW.cpp @@ -0,0 +1,69 @@ +/********************************************************************** + + Audacity: A Digital Audio Editor + + VSTControlMSW.mm + + Leland Lucius + +**********************************************************************/ + +#include +#include + +#include "VSTControl.h" + +BEGIN_EVENT_TABLE(VSTControl, VSTControlBase) + EVT_SIZE(VSTControl::OnSize) +END_EVENT_TABLE() + +VSTControl::VSTControl() +: VSTControlBase() +{ +} + +VSTControl::~VSTControl() +{ +} + +bool VSTControl::Create(wxWindow *parent, VSTEffectLink *link) +{ + if (!VSTControlBase::Create(parent, link)) + { + return false; + } + + VstRect *rect; + + // Some effects like to have us get their rect before opening them. + mLink->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0); + + // Get the native handle + mHwnd = GetHWND(); + + // Ask the effect to add its GUI + mLink->callDispatcher(effEditOpen, 0, 0, mHwnd, 0.0); + + // Get the final bounds of the effect GUI + mLink->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0); + + // Add the effect host window to the layout + SetMinSize(wxSize(rect->right - rect->left, rect->bottom - rect->top)); + + // Must get the size again since SetPeer() could cause it to change + SetInitialSize(GetMinSize()); + + return true; +} + +void VSTControl::OnSize(wxSizeEvent & evt) +{ + evt.Skip(); + + wxSize sz = GetSize(); + wxSize s1 = evt.GetSize(); + + evt.Skip(); + + return; +} diff --git a/src/effects/VST/VSTControlMSW.h b/src/effects/VST/VSTControlMSW.h new file mode 100644 index 000000000..72f01584e --- /dev/null +++ b/src/effects/VST/VSTControlMSW.h @@ -0,0 +1,39 @@ +/********************************************************************** + + Audacity: A Digital Audio Editor + + VSTControlMSW.h + + Leland Lucius + +**********************************************************************/ + +#ifndef AUDACITY_VSTCONTROLMSW_H +#define AUDACITY_VSTCONTROLMSW_H + +#include + +#include + +#include "aeffectx.h" + +class VSTControl : public VSTControlBase +{ +public: + VSTControl(); + ~VSTControl(); + + bool Create(wxWindow *parent, VSTEffectLink *link); + + void OnSize(wxSizeEvent & evt); + +private: + HANDLE mHwnd; + + wxSize mLastMin; + bool mSettingSize; + + DECLARE_EVENT_TABLE(); +}; + +#endif diff --git a/src/effects/VST/VSTControlMac.h b/src/effects/VST/VSTControlOSX.h similarity index 100% rename from src/effects/VST/VSTControlMac.h rename to src/effects/VST/VSTControlOSX.h diff --git a/src/effects/VST/VSTControlMac.mm b/src/effects/VST/VSTControlOSX.mm similarity index 99% rename from src/effects/VST/VSTControlMac.mm rename to src/effects/VST/VSTControlOSX.mm index b6456192f..25ae773c9 100644 --- a/src/effects/VST/VSTControlMac.mm +++ b/src/effects/VST/VSTControlOSX.mm @@ -2,7 +2,7 @@ Audacity: A Digital Audio Editor - VSTControlMac.mm + VSTControlOSX.mm Leland Lucius @@ -74,14 +74,13 @@ VSTControlImpl::~VSTControlImpl() { } -BEGIN_EVENT_TABLE(VSTControl, wxControl) +BEGIN_EVENT_TABLE(VSTControl, VSTControlBase) EVT_SIZE(VSTControl::OnSize) END_EVENT_TABLE() VSTControl::VSTControl() +: VSTControlBase() { - mLink = NULL; - mVSTView = nil; mView = nil; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 5956a76a9..caba60a6a 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -41,6 +41,13 @@ #if defined(__WXMAC__) #include +#elif defined(__WXMSW__) +#include +#include +#include +#pragma comment(lib, "shlwapi") +#else +// Includes for GTK are later since they cause conflicts with our class names #endif #include @@ -2796,8 +2803,6 @@ void VSTEffect::BuildFancy() // Turn the power on...some effects need this when the editor is open PowerOn(); - OSStatus result; - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); wxPanel *container = new wxPanel(mParent, wxID_ANY); @@ -2822,14 +2827,14 @@ void VSTEffect::BuildFancy() return; } - if (!mControl->Create(mParent, this)) + if (!mControl->Create(container, this)) { return; } wxBoxSizer *innerSizer = new wxBoxSizer(wxVERTICAL); - innerSizer->Add(mControl, 1, wxEXPAND); + innerSizer->Add(mControl, 0, wxALIGN_CENTER); container->SetSizer(innerSizer); mParent->SetMinSize(wxDefaultSize); @@ -3014,14 +3019,17 @@ void VSTEffect::RefreshParameters(int skip) void VSTEffect::OnSizeWindow(wxCommandEvent & evt) { - if (!mContainer) + if (!mControl) { return; } // This really needs some work. We shouldn't know anything about the parent... - mContainer->SetMinSize(evt.GetInt(), (int) evt.GetExtraLong()); - mParent->SetMinSize(mContainer->GetMinSize()); + mControl->SetMinSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong())); + mControl->SetSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong())); + mParent->SetMinSize(wxDefaultSize); + mDialog->SetMinSize(wxDefaultSize); +// mParent->SetMinSize(mControl->GetMinSize()); mDialog->Layout(); mDialog->Fit(); } diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 58a050115..5a69dfc31 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -315,36 +315,8 @@ private: wxString mChunk; long mXMLVersion; VstPatchChunkInfo mXMLInfo; - -#if defined(__WXMAC__) - static pascal OSStatus OverlayEventHandler(EventHandlerCallRef handler, EventRef event, void *data); - OSStatus OnOverlayEvent(EventHandlerCallRef handler, EventRef event); - static pascal OSStatus WindowEventHandler(EventHandlerCallRef handler, EventRef event, void *data); - OSStatus OnWindowEvent(EventHandlerCallRef handler, EventRef event); - static pascal OSStatus TrackingEventHandler(EventHandlerCallRef handler, EventRef event, void *data); - OSStatus OnTrackingEvent(EventRef event); - - WindowRef mOverlayRef; - EventHandlerUPP mOverlayEventHandlerUPP; - EventHandlerRef mOverlayEventHandlerRef; - - WindowRef mWindowRef; - WindowRef mPreviousRef; - EventHandlerUPP mWindowEventHandlerUPP; - EventHandlerRef mWindowEventHandlerRef; - - EventHandlerUPP mTrackingHandlerUPP; - EventHandlerRef mRootTrackingHandlerRef; - EventHandlerRef mViewTrackingHandlerRef; - EventHandlerRef mSubviewTrackingHandlerRef; - EventHandlerRef mOverlayRootTrackingHandlerRef; - EventHandlerRef mOverlayViewTrackingHandlerRef; -#elif defined(__WXMSW__) - - HANDLE mHwnd; - -#else +#if defined(__WXGTK__) Display *mXdisp; Window mXwin; diff --git a/src/effects/VST/aeffectx.h b/src/effects/VST/aeffectx.h index 73d933322..c9e5a2066 100644 --- a/src/effects/VST/aeffectx.h +++ b/src/effects/VST/aeffectx.h @@ -377,4 +377,15 @@ enum VstPlugCategory kPlugCategMaxCount // 12=Marker to count the categories }; + + +class VstRect +{ +public: + short top; + short left; + short bottom; + short right; +} ; + #endif diff --git a/win/Projects/Audacity/Audacity.vcxproj b/win/Projects/Audacity/Audacity.vcxproj index 18ad434bd..413659967 100755 --- a/win/Projects/Audacity/Audacity.vcxproj +++ b/win/Projects/Audacity/Audacity.vcxproj @@ -144,6 +144,7 @@ + @@ -414,6 +415,7 @@ + diff --git a/win/Projects/Audacity/Audacity.vcxproj.filters b/win/Projects/Audacity/Audacity.vcxproj.filters index be01e8333..6754ad973 100755 --- a/win/Projects/Audacity/Audacity.vcxproj.filters +++ b/win/Projects/Audacity/Audacity.vcxproj.filters @@ -837,6 +837,9 @@ src + + src/effects/VST + @@ -1673,6 +1676,9 @@ src + + src/effects/VST + diff --git a/win/configwin.h b/win/configwin.h index 54f99d496..ab6bcb634 100644 --- a/win/configwin.h +++ b/win/configwin.h @@ -28,7 +28,7 @@ #define USE_SBSMS 1 #define USE_SOUNDTOUCH 1 #define USE_VAMP 1 -#define USE_VST 0 +#define USE_VST 1 #define USE_MIDI 1 // define this to use portSMF and PortMidi for midi file support #define INSTALL_PREFIX "."