mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-27 15:53:49 +01:00
Remove GetActiveProject from EffectRack...
... and make one EffectRack window per project
This commit is contained in:
@@ -67,17 +67,10 @@ EffectManager & EffectManager::Get()
|
|||||||
EffectManager::EffectManager()
|
EffectManager::EffectManager()
|
||||||
{
|
{
|
||||||
mSkipStateFlag = false;
|
mSkipStateFlag = false;
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
|
||||||
mRack = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectManager::~EffectManager()
|
EffectManager::~EffectManager()
|
||||||
{
|
{
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
|
||||||
// wxWidgets has already destroyed the rack since it was derived from wxFrame. So
|
|
||||||
// no need to DELETE it here.
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here solely for the purpose of Nyquist Workbench until
|
// Here solely for the purpose of Nyquist Workbench until
|
||||||
@@ -166,7 +159,7 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
|
|||||||
|
|
||||||
EffectManager & em = EffectManager::Get();
|
EffectManager & em = EffectManager::Get();
|
||||||
|
|
||||||
success = em.DoEffect(ID, &window, rate,
|
success = em.DoEffect(ID, &window, context.project, rate,
|
||||||
&tracks, &trackFactory, selectedRegion,
|
&tracks, &trackFactory, selectedRegion,
|
||||||
(flags & EffectManager::kConfigured) == 0);
|
(flags & EffectManager::kConfigured) == 0);
|
||||||
|
|
||||||
@@ -238,6 +231,7 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
|
|||||||
|
|
||||||
bool EffectManager::DoEffect(const PluginID & ID,
|
bool EffectManager::DoEffect(const PluginID & ID,
|
||||||
wxWindow *parent,
|
wxWindow *parent,
|
||||||
|
AudacityProject &project,
|
||||||
double projectRate,
|
double projectRate,
|
||||||
TrackList *list,
|
TrackList *list,
|
||||||
TrackFactory *factory,
|
TrackFactory *factory,
|
||||||
@@ -256,8 +250,10 @@ bool EffectManager::DoEffect(const PluginID & ID,
|
|||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||||
if (effect->SupportsRealtime())
|
if (effect->SupportsRealtime())
|
||||||
{
|
{
|
||||||
GetRack()->Add(effect);
|
EffectRack::Get( project ).Add(effect);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)project;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool res = effect->DoEffect(parent,
|
bool res = effect->DoEffect(parent,
|
||||||
@@ -636,27 +632,6 @@ void EffectManager::SetBatchProcessing(const PluginID & ID, bool start)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
|
||||||
EffectRack *EffectManager::GetRack()
|
|
||||||
{
|
|
||||||
if (!mRack)
|
|
||||||
{
|
|
||||||
// EffectRack is constructed with the current project as owner, so safenew is OK
|
|
||||||
mRack = safenew EffectRack();
|
|
||||||
// Make sure what I just commented remains true:
|
|
||||||
wxASSERT(mRack->GetParent());
|
|
||||||
mRack->CenterOnParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRack;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EffectManager::ShowRack()
|
|
||||||
{
|
|
||||||
GetRack()->Show(!GetRack()->IsShown());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Effect *EffectManager::GetEffect(const PluginID & ID)
|
Effect *EffectManager::GetEffect(const PluginID & ID)
|
||||||
{
|
{
|
||||||
// Must have a "valid" ID
|
// Must have a "valid" ID
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "audacity/Types.h"
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
class AudacityCommand;
|
class AudacityCommand;
|
||||||
|
class AudacityProject;
|
||||||
class CommandContext;
|
class CommandContext;
|
||||||
class CommandMessageTarget;
|
class CommandMessageTarget;
|
||||||
class ComponentInterfaceSymbol;
|
class ComponentInterfaceSymbol;
|
||||||
@@ -87,6 +88,7 @@ public:
|
|||||||
// Audacity's standard UI.
|
// Audacity's standard UI.
|
||||||
bool DoEffect(const PluginID & ID,
|
bool DoEffect(const PluginID & ID,
|
||||||
wxWindow *parent,
|
wxWindow *parent,
|
||||||
|
AudacityProject &project,
|
||||||
double projectRate,
|
double projectRate,
|
||||||
TrackList *list,
|
TrackList *list,
|
||||||
TrackFactory *factory,
|
TrackFactory *factory,
|
||||||
@@ -143,10 +145,6 @@ public:
|
|||||||
void SetSkipStateFlag(bool flag);
|
void SetSkipStateFlag(bool flag);
|
||||||
bool GetSkipStateFlag();
|
bool GetSkipStateFlag();
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
|
||||||
void ShowRack();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
|
const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -154,10 +152,6 @@ private:
|
|||||||
Effect *GetEffect(const PluginID & ID);
|
Effect *GetEffect(const PluginID & ID);
|
||||||
AudacityCommand *GetAudacityCommand(const PluginID & ID);
|
AudacityCommand *GetAudacityCommand(const PluginID & ID);
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
|
||||||
EffectRack *GetRack();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EffectMap mEffects;
|
EffectMap mEffects;
|
||||||
AudacityCommandMap mCommands;
|
AudacityCommandMap mCommands;
|
||||||
@@ -170,8 +164,6 @@ private:
|
|||||||
bool mSkipStateFlag;
|
bool mSkipStateFlag;
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||||
EffectRack *mRack;
|
|
||||||
|
|
||||||
friend class EffectRack;
|
friend class EffectRack;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ BEGIN_EVENT_TABLE(EffectRack, wxFrame)
|
|||||||
EVT_COMMAND_RANGE(ID_FAV, ID_FAV + 99, wxEVT_COMMAND_BUTTON_CLICKED, EffectRack::OnFav)
|
EVT_COMMAND_RANGE(ID_FAV, ID_FAV + 99, wxEVT_COMMAND_BUTTON_CLICKED, EffectRack::OnFav)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
EffectRack::EffectRack()
|
EffectRack::EffectRack( AudacityProject &project )
|
||||||
: wxFrame( FindProjectFrame( GetActiveProject() ),
|
: wxFrame( &GetProjectFrame( project ),
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
_("Effects Rack"),
|
_("Effects Rack"),
|
||||||
wxDefaultPosition,
|
wxDefaultPosition,
|
||||||
@@ -91,6 +91,7 @@ EffectRack::EffectRack()
|
|||||||
wxCAPTION |
|
wxCAPTION |
|
||||||
wxFRAME_NO_TASKBAR |
|
wxFRAME_NO_TASKBAR |
|
||||||
wxFRAME_FLOAT_ON_PARENT)
|
wxFRAME_FLOAT_ON_PARENT)
|
||||||
|
, mProject{ project }
|
||||||
{
|
{
|
||||||
mBypassing = false;
|
mBypassing = false;
|
||||||
mNumEffects = 0;
|
mNumEffects = 0;
|
||||||
@@ -296,7 +297,7 @@ void EffectRack::OnTimer(wxTimerEvent & WXUNUSED(evt))
|
|||||||
|
|
||||||
void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
|
void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = &mProject;
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
auto state = UndoManager::Get( *project ).GetCurrentState();
|
auto state = UndoManager::Get( *project ).GetCurrentState();
|
||||||
@@ -568,4 +569,20 @@ void EffectRack::UpdateActive()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
AudacityProject::AttachedWindows::RegisteredFactory sKey{
|
||||||
|
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
|
||||||
|
auto result = safenew EffectRack( parent );
|
||||||
|
result->CenterOnParent();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
EffectRack &EffectRack::Get( AudacityProject &project )
|
||||||
|
{
|
||||||
|
return project.AttachedWindows::Get< EffectRack >( sKey );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,17 +28,21 @@ class wxFlexGridSizer;
|
|||||||
class wxPanel;
|
class wxPanel;
|
||||||
class wxStaticText;
|
class wxStaticText;
|
||||||
|
|
||||||
|
class AudacityProject;
|
||||||
|
|
||||||
class Effect;
|
class Effect;
|
||||||
using EffectArray = std::vector<Effect*>;
|
using EffectArray = std::vector<Effect*>;
|
||||||
|
|
||||||
class EffectRack final : public wxFrame
|
class EffectRack final : public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EffectRack();
|
EffectRack( AudacityProject &project );
|
||||||
virtual ~EffectRack();
|
virtual ~EffectRack();
|
||||||
|
|
||||||
void Add(Effect *effect, bool active = false, bool favorite = false);
|
void Add(Effect *effect, bool active = false, bool favorite = false);
|
||||||
|
|
||||||
|
static EffectRack &Get( AudacityProject &project );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
wxBitmap CreateBitmap(const char *const xpm[], bool up, bool pusher);
|
wxBitmap CreateBitmap(const char *const xpm[], bool up, bool pusher);
|
||||||
@@ -59,6 +63,8 @@ private:
|
|||||||
void OnRemove(wxCommandEvent & evt);
|
void OnRemove(wxCommandEvent & evt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
AudacityProject &mProject;
|
||||||
|
|
||||||
wxStaticText *mLatency;
|
wxStaticText *mLatency;
|
||||||
int mLastLatency;
|
int mLastLatency;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "../tracks/ui/TrackView.h"
|
#include "../tracks/ui/TrackView.h"
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_EFFECTS_RACK
|
#ifdef EXPERIMENTAL_EFFECTS_RACK
|
||||||
#include "../effects/EffectManager.h"
|
#include "../effects/EffectRack.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/scrolbar.h>
|
#include <wx/scrolbar.h>
|
||||||
@@ -383,9 +383,10 @@ void OnShowClipping(const CommandContext &context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||||
void OnShowEffectsRack(const CommandContext &WXUNUSED(context) )
|
void OnShowEffectsRack(const CommandContext &context )
|
||||||
{
|
{
|
||||||
EffectManager::Get().ShowRack();
|
auto &rack = EffectRack::Get( context.project );
|
||||||
|
rack.Show( !rack.IsShown() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user