1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 14:13:57 +01:00

Round 8 of wx3 changes

VST control working on Windows...further changes will be required
This commit is contained in:
Leland Lucius
2015-07-16 14:30:04 -05:00
parent 805f0e29d1
commit ac4c4faadc
12 changed files with 160 additions and 51 deletions

View File

@@ -12,6 +12,7 @@
#define AUDACITY_VSTCONTROL_H
#include <wx/control.h>
#include <wx/panel.h>
#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__)

View File

@@ -0,0 +1,69 @@
/**********************************************************************
Audacity: A Digital Audio Editor
VSTControlMSW.mm
Leland Lucius
**********************************************************************/
#include <wx/dynlib.h>
#include <wx/sizer.h>
#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;
}

View File

@@ -0,0 +1,39 @@
/**********************************************************************
Audacity: A Digital Audio Editor
VSTControlMSW.h
Leland Lucius
**********************************************************************/
#ifndef AUDACITY_VSTCONTROLMSW_H
#define AUDACITY_VSTCONTROLMSW_H
#include <Windows.h>
#include <wx/control.h>
#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

View File

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

View File

@@ -41,6 +41,13 @@
#if defined(__WXMAC__)
#include <dlfcn.h>
#elif defined(__WXMSW__)
#include <wx/dynlib.h>
#include <wx/msw/seh.h>
#include <shlwapi.h>
#pragma comment(lib, "shlwapi")
#else
// Includes for GTK are later since they cause conflicts with our class names
#endif
#include <wx/app.h>
@@ -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();
}

View File

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

View File

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