From 1c588fa01475cd63f28a5608eb857d72b4ec0986 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 12 Jun 2019 22:44:24 -0400 Subject: [PATCH] Move enum into EffectManager... ... tying Effect into a cycle of 3 with EffectManager and EffectRack, which is only revealing the true dependencies --- src/BatchCommands.cpp | 14 +++++++------- src/Menus.h | 10 ---------- src/ProjectFileManager.cpp | 2 +- src/effects/Effect.cpp | 3 ++- src/effects/EffectManager.h | 11 +++++++++++ src/effects/EffectRack.cpp | 2 +- src/menus/PluginMenus.cpp | 18 +++++++++--------- src/menus/TrackMenus.cpp | 2 +- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 272f5fa11..0b32f90b7 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -736,16 +736,16 @@ bool MacroCommands::ApplyEffectCommand( // and apply the effect... res = PluginActions::DoAudacityCommand(ID, Context, - PluginActions::kConfigured | - PluginActions::kSkipState | - PluginActions::kDontRepeatLast); + EffectManager::kConfigured | + EffectManager::kSkipState | + EffectManager::kDontRepeatLast); else // and apply the effect... res = PluginActions::DoEffect(ID, Context, - PluginActions::kConfigured | - PluginActions::kSkipState | - PluginActions::kDontRepeatLast); + EffectManager::kConfigured | + EffectManager::kSkipState | + EffectManager::kDontRepeatLast); } return res; @@ -778,7 +778,7 @@ bool MacroCommands::HandleTextualCommand( CommandManager &commandManager, { return PluginActions::DoEffect( plug->GetID(), context, - PluginActions::kConfigured); + EffectManager::kConfigured); } plug = pm.GetNextPlugin(PluginTypeEffect); } diff --git a/src/Menus.h b/src/Menus.h index 1a92a08f9..b8f1786d7 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -140,16 +140,6 @@ void DoRecord( AudacityProject & ); /// Namespace for helper functions to do with plug ins namespace PluginActions { - enum : unsigned { - // No flags specified - kNone = 0x00, - // Flag used to disable prompting for configuration parameteres. - kConfigured = 0x01, - // Flag used to disable saving the state after processing. - kSkipState = 0x02, - // Flag used to disable "Repeat Last Effect" - kDontRepeatLast = 0x04, - }; bool DoEffect( const PluginID & ID, const CommandContext & context, unsigned flags ); bool DoAudacityCommand( diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 865bc8ba0..2a98dcbe9 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -1715,7 +1715,7 @@ bool ProjectFileManager::Import( PluginActions::DoEffect( EffectManager::Get().GetEffectByIdentifier(wxT("Normalize")), context, - PluginActions::kConfigured); + EffectManager::kConfigured); } // This is a no-fail: diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 6dbbd0097..cd7002ecf 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -47,6 +47,7 @@ greater use in future. #include "audacity/ConfigInterface.h" +#include "EffectManager.h" #include "RealtimeEffectManager.h" #include "../AudioIO.h" #include "../CommonCommandFlags.h" @@ -777,7 +778,7 @@ bool Effect::Apply() // // It should callback to the EffectManager to kick off the processing return PluginActions::DoEffect(GetID(), context, - PluginActions::kConfigured); + EffectManager::kConfigured); } void Effect::Preview() diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 3280290d9..2a371604c 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -45,6 +45,17 @@ class AUDACITY_DLL_API EffectManager { public: + enum : unsigned { + // No flags specified + kNone = 0x00, + // Flag used to disable prompting for configuration parameteres. + kConfigured = 0x01, + // Flag used to disable saving the state after processing. + kSkipState = 0x02, + // Flag used to disable "Repeat Last Effect" + kDontRepeatLast = 0x04, + }; + /** Get the singleton instance of the EffectManager. Probably not safe for multi-thread use. */ static EffectManager & Get(); diff --git a/src/effects/EffectRack.cpp b/src/effects/EffectRack.cpp index d66af665c..ef4a8c84b 100644 --- a/src/effects/EffectRack.cpp +++ b/src/effects/EffectRack.cpp @@ -311,7 +311,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt)) { if (!PluginActions::DoEffect(mEffects[i]->GetID(), *project, - PluginActions::kConfigured)) + EffectManager::kConfigured)) // If any effect fails (or throws), then stop. return; } diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 482aaeec2..b6f9fa56b 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -447,7 +447,7 @@ bool DoEffect( // Make sure there's no activity since the effect is about to be applied // to the project's tracks. Mainly for Apply during RTP, but also used // for batch commands - if (flags & kConfigured) + if (flags & EffectManager::kConfigured) { TransportActions::DoStop(project); SelectUtilities::SelectAllIfNone( project ); @@ -486,22 +486,22 @@ bool DoEffect( success = em.DoEffect(ID, &window, rate, &tracks, &trackFactory, &selectedRegion, - (flags & kConfigured) == 0); + (flags & EffectManager::kConfigured) == 0); if (!success) return false; if (em.GetSkipStateFlag()) - flags = flags | kSkipState; + flags = flags | EffectManager::kSkipState; - if (!(flags & kSkipState)) + if (!(flags & EffectManager::kSkipState)) { wxString shortDesc = em.GetCommandName(ID); wxString longDesc = em.GetCommandDescription(ID); ProjectHistory::Get( project ).PushState(longDesc, shortDesc); } - if (!(flags & kDontRepeatLast)) + if (!(flags & EffectManager::kDontRepeatLast)) { // Only remember a successful effect, don't remember insert, // or analyze effects. @@ -559,7 +559,7 @@ bool DoAudacityCommand( if (!plug) return false; - if (flags & kConfigured) + if (flags & EffectManager::kConfigured) { TransportActions::DoStop(project); // SelectAllIfNone(); @@ -569,7 +569,7 @@ bool DoAudacityCommand( bool success = em.DoAudacityCommand(ID, context, &window, - (flags & kConfigured) == 0); + (flags & EffectManager::kConfigured) == 0); if (!success) return false; @@ -616,7 +616,7 @@ void OnRepeatLastEffect(const CommandContext &context) auto lastEffect = MenuManager::Get(context.project).mLastEffect; if (!lastEffect.empty()) { - DoEffect( lastEffect, context, kConfigured ); + DoEffect( lastEffect, context, EffectManager::kConfigured ); } } @@ -743,7 +743,7 @@ void OnAudacityCommand(const CommandContext & ctx) wxLogDebug( "Command was: %s", ctx.parameter.GET()); // Not configured, so prompt user. DoAudacityCommand(EffectManager::Get().GetEffectByIdentifier(ctx.parameter), - ctx, kNone); + ctx, EffectManager::kNone); } }; // struct Handler diff --git a/src/menus/TrackMenus.cpp b/src/menus/TrackMenus.cpp index 85961e1e6..e830f1f98 100644 --- a/src/menus/TrackMenus.cpp +++ b/src/menus/TrackMenus.cpp @@ -677,7 +677,7 @@ void OnStereoToMono(const CommandContext &context) PluginActions::DoEffect( EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), context, - PluginActions::kConfigured); + EffectManager::kConfigured); } void OnMixAndRender(const CommandContext &context)