Move static EffectManager::DoEffect into new namespace
This commit is contained in:
parent
23a0206d2a
commit
91c45dd32a
|
@ -31,6 +31,7 @@
|
|||
#include "Project.h"
|
||||
#include "ShuttleGui.h"
|
||||
#include "effects/EffectManager.h"
|
||||
#include "effects/EffectUI.h"
|
||||
#include "effects/nyquist/Nyquist.h"
|
||||
#include "../images/AudacityLogo.xpm"
|
||||
#include "../../src/commands/CommandContext.h"
|
||||
|
@ -1403,7 +1404,7 @@ void NyqBench::OnGo(wxCommandEvent & e)
|
|||
mRunning = true;
|
||||
UpdateWindowUI();
|
||||
|
||||
EffectManager::DoEffect(ID, CommandContext(*p), 0);
|
||||
EffectUI::DoEffect(ID, CommandContext(*p), 0);
|
||||
|
||||
mRunning = false;
|
||||
UpdateWindowUI();
|
||||
|
|
|
@ -796,7 +796,7 @@ bool MacroCommands::ApplyEffectCommand(
|
|||
EffectManager::kDontRepeatLast);
|
||||
else
|
||||
// and apply the effect...
|
||||
res = EffectManager::DoEffect(ID,
|
||||
res = EffectUI::DoEffect(ID,
|
||||
Context,
|
||||
EffectManager::kConfigured |
|
||||
EffectManager::kSkipState |
|
||||
|
@ -831,7 +831,7 @@ bool MacroCommands::HandleTextualCommand( CommandManager &commandManager,
|
|||
{
|
||||
if (em.GetCommandIdentifier(plug->GetID()) == Str)
|
||||
{
|
||||
return EffectManager::DoEffect(
|
||||
return EffectUI::DoEffect(
|
||||
plug->GetID(), context,
|
||||
EffectManager::kConfigured);
|
||||
}
|
||||
|
|
|
@ -91,14 +91,13 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
|
|||
mEffects.erase(id);
|
||||
}
|
||||
|
||||
/// DoEffect() takes a PluginID and has the EffectManager execute the associated
|
||||
/// effect.
|
||||
/// DoEffect() takes a PluginID and executes the associated effect.
|
||||
///
|
||||
/// At the moment flags are used only to indicate whether to prompt for
|
||||
// parameters, whether to save the state to history and whether to allow
|
||||
/// 'Repeat Last Effect'.
|
||||
|
||||
/* static */ bool EffectManager::DoEffect(
|
||||
/* static */ bool EffectUI::DoEffect(
|
||||
const PluginID & ID, const CommandContext &context, unsigned flags )
|
||||
{
|
||||
AudacityProject &project = context.project;
|
||||
|
@ -157,9 +156,26 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
|
|||
|
||||
EffectManager & em = EffectManager::Get();
|
||||
|
||||
success = em.DoEffect(ID, &window, context.project, rate,
|
||||
&tracks, &trackFactory, selectedRegion,
|
||||
(flags & EffectManager::kConfigured) == 0);
|
||||
em.SetSkipStateFlag( false );
|
||||
if (auto effect = em.GetEffect(ID)) {
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
if (effect->SupportsRealtime())
|
||||
{
|
||||
EffectRack::Get( context.project ).Add(effect);
|
||||
}
|
||||
#endif
|
||||
success = effect->DoEffect(&window,
|
||||
rate,
|
||||
&tracks,
|
||||
&trackFactory,
|
||||
selectedRegion,
|
||||
(flags & EffectManager::kConfigured) == 0
|
||||
? DialogFactory
|
||||
: nullptr
|
||||
);
|
||||
}
|
||||
else
|
||||
success = false;
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
@ -227,43 +243,6 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EffectManager::DoEffect(const PluginID & ID,
|
||||
wxWindow *parent,
|
||||
AudacityProject &project,
|
||||
double projectRate,
|
||||
TrackList *list,
|
||||
TrackFactory *trackFactory,
|
||||
NotifyingSelectedRegion &selectedRegion,
|
||||
bool shouldPrompt /* = true */)
|
||||
|
||||
{
|
||||
this->SetSkipStateFlag(false);
|
||||
Effect *effect = GetEffect(ID);
|
||||
|
||||
if (!effect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
if (effect->SupportsRealtime())
|
||||
{
|
||||
EffectRack::Get( project ).Add(effect);
|
||||
}
|
||||
#else
|
||||
(void)project;
|
||||
#endif
|
||||
|
||||
bool res = effect->DoEffect( parent,
|
||||
projectRate,
|
||||
list,
|
||||
trackFactory,
|
||||
selectedRegion,
|
||||
shouldPrompt ? EffectUI::DialogFactory : nullptr );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool EffectManager::DoAudacityCommand(const PluginID & ID,
|
||||
const CommandContext &context,
|
||||
wxWindow *parent,
|
||||
|
|
|
@ -71,9 +71,6 @@ public:
|
|||
// them by index number, usually when the user selects one from a menu.
|
||||
//
|
||||
public:
|
||||
static bool DoEffect(
|
||||
const PluginID & ID, const CommandContext &context, unsigned flags );
|
||||
|
||||
EffectManager();
|
||||
virtual ~EffectManager();
|
||||
|
||||
|
@ -83,19 +80,6 @@ public:
|
|||
const PluginID & RegisterEffect(Effect *f);
|
||||
void UnregisterEffect(const PluginID & ID);
|
||||
|
||||
/** Run an effect given the plugin ID */
|
||||
// Returns true on success. Will only operate on tracks that
|
||||
// have the "selected" flag set to true, which is consistent with
|
||||
// Audacity's standard UI.
|
||||
bool DoEffect(const PluginID & ID,
|
||||
wxWindow *parent,
|
||||
AudacityProject &project,
|
||||
double projectRate,
|
||||
TrackList *list,
|
||||
TrackFactory *factory,
|
||||
NotifyingSelectedRegion &selectedRegion,
|
||||
bool shouldPrompt = true);
|
||||
|
||||
TranslatableString GetEffectFamilyName(const PluginID & ID);
|
||||
TranslatableString GetVendorName(const PluginID & ID);
|
||||
|
||||
|
@ -150,12 +134,12 @@ public:
|
|||
|
||||
const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
|
||||
|
||||
private:
|
||||
/** Return an effect by its ID. */
|
||||
Effect *GetEffect(const PluginID & ID);
|
||||
AudacityCommand *GetAudacityCommand(const PluginID & ID);
|
||||
|
||||
private:
|
||||
AudacityCommand *GetAudacityCommand(const PluginID & ID);
|
||||
|
||||
EffectMap mEffects;
|
||||
AudacityCommandMap mCommands;
|
||||
EffectOwnerMap mHostEffects;
|
||||
|
|
|
@ -310,7 +310,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
|
|||
{
|
||||
if (mPowerState[i])
|
||||
{
|
||||
if (!EffectManager::DoEffect(mEffects[i]->GetID(),
|
||||
if (!EffectUI::DoEffect(mEffects[i]->GetID(),
|
||||
*project,
|
||||
EffectManager::kConfigured))
|
||||
// If any effect fails (or throws), then stop.
|
||||
|
@ -1195,7 +1195,7 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
|
|||
// This is absolute hackage...but easy and I can't think of another way just now.
|
||||
//
|
||||
// It should callback to the EffectManager to kick off the processing
|
||||
EffectManager::DoEffect(mEffect->GetID(), context,
|
||||
EffectUI::DoEffect(mEffect->GetID(), context,
|
||||
EffectManager::kConfigured);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,9 +212,20 @@ private:
|
|||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
struct CommandContext;
|
||||
|
||||
namespace EffectUI {
|
||||
|
||||
wxDialog *DialogFactory( wxWindow *parent, EffectHostInterface *pHost,
|
||||
EffectUIClientInterface *client);
|
||||
|
||||
/** Run an effect given the plugin ID */
|
||||
// Returns true on success. Will only operate on tracks that
|
||||
// have the "selected" flag set to true, which is consistent with
|
||||
// Audacity's standard UI.
|
||||
bool DoEffect(
|
||||
const PluginID & ID, const CommandContext &context, unsigned flags );
|
||||
|
||||
}
|
||||
|
||||
#endif // __AUDACITY_EFFECTUI_H__
|
||||
|
|
|
@ -34,7 +34,6 @@ Functions that find and load all LV2 plugins on the system.
|
|||
#include <wx/log.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "../EffectManager.h"
|
||||
#include "../../Internat.h"
|
||||
|
||||
#include "LV2Effect.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../commands/ScreenshotCommand.h"
|
||||
#include "../effects/Contrast.h"
|
||||
#include "../effects/EffectManager.h"
|
||||
#include "../effects/EffectUI.h"
|
||||
#include "../effects/RealtimeEffectManager.h"
|
||||
#include "../prefs/EffectsPrefs.h"
|
||||
|
||||
|
@ -423,7 +424,7 @@ void OnManageGenerators(const CommandContext &context)
|
|||
void OnEffect(const CommandContext &context)
|
||||
{
|
||||
// using GET to interpret parameter as a PluginID
|
||||
EffectManager::DoEffect(context.parameter.GET(), context, 0);
|
||||
EffectUI::DoEffect(context.parameter.GET(), context, 0);
|
||||
}
|
||||
|
||||
void OnManageEffects(const CommandContext &context)
|
||||
|
@ -437,7 +438,7 @@ void OnRepeatLastEffect(const CommandContext &context)
|
|||
auto lastEffect = MenuManager::Get(context.project).mLastEffect;
|
||||
if (!lastEffect.empty())
|
||||
{
|
||||
EffectManager::DoEffect(
|
||||
EffectUI::DoEffect(
|
||||
lastEffect, context, EffectManager::kConfigured );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "../commands/CommandContext.h"
|
||||
#include "../commands/CommandManager.h"
|
||||
#include "../effects/EffectManager.h"
|
||||
#include "../effects/EffectUI.h"
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackControls.h"
|
||||
#include "../widgets/ASlider.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
|
@ -688,7 +689,7 @@ void OnNewTimeTrack(const CommandContext &context)
|
|||
|
||||
void OnStereoToMono(const CommandContext &context)
|
||||
{
|
||||
EffectManager::DoEffect(
|
||||
EffectUI::DoEffect(
|
||||
EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")),
|
||||
context,
|
||||
EffectManager::kConfigured);
|
||||
|
|
Loading…
Reference in New Issue