Audacity 3.2.0
CommandDispatch Namespace Reference


AUDACITY_DLL_API bool HandleTextualCommand (const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
AUDACITY_DLL_API bool DoAudacityCommand (const PluginID &ID, const CommandContext &context, unsigned flags)
AUDACITY_DLL_API void OnAudacityCommand (const CommandContext &ctx)

Function Documentation

◆ DoAudacityCommand()

bool CommandDispatch::DoAudacityCommand ( const PluginID ID,
const CommandContext context,
unsigned  flags 

DoAudacityCommand() takes a PluginID and executes the associated command.

At the moment flags are used only to indicate whether to prompt for parameters

Definition at line 59 of file CommandDispatch.cpp.

62 auto &project = context.project;
63 auto &window = GetProjectFrame(project);
65 if (!plug)
66 return false;
69 {
71// SelectAllIfNone();
72 }
75 bool success = em.DoAudacityCommand(ID,
76 context,
77 &window,
78 (flags & EffectManager::kConfigured) == 0);
80 if (!success)
81 return false;
84 if (em.GetSkipStateFlag())
85 flags = flags | OnEffectFlags::kSkipState;
87 if (!(flags & OnEffectFlags::kSkipState))
88 {
89 wxString shortDesc = em.GetCommandName(ID);
90 wxString longDesc = em.GetCommandDescription(ID);
91 PushState(longDesc, shortDesc);
92 }
95 return true;
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
const auto project
AudacityProject & project
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48
static EffectManager & Get()
bool DoAudacityCommand(const PluginID &ID, const CommandContext &, wxWindow *parent, bool shouldPrompt=true)
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
void Stop(bool stopStream=true)
static ProjectAudioManager & Get(AudacityProject &project)
void Redraw()
Definition: Viewport.cpp:776
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32

References EffectManager::DoAudacityCommand(), PluginManager::Get(), EffectManager::Get(), Viewport::Get(), ProjectAudioManager::Get(), PluginManager::GetPlugin(), GetProjectFrame(), EffectManager::kConfigured, CommandContext::project, project, Viewport::Redraw(), and ProjectAudioManager::Stop().

Referenced by MacroCommands::ApplyEffectCommand(), and OnAudacityCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleTextualCommand()

bool CommandDispatch::HandleTextualCommand ( const CommandID Str,
const CommandContext context,
CommandFlag  flags,
bool  alwaysEnabled 

Definition at line 26 of file CommandDispatch.cpp.

30 auto &commandManager = CommandManager::Get(context.project);
31 switch ( commandManager.HandleTextualCommand(
32 Str, context, flags, alwaysEnabled) ) {
34 return true;
36 return false;
38 default:
39 break;
40 }
42 // Not one of the singleton commands.
43 // We could/should try all the list-style commands.
44 // instead we only try the effects.
46 for (auto &plug : PluginManager::Get().PluginsOfType(PluginTypeEffect))
47 if (em.GetCommandIdentifier(plug.GetID()) == Str)
48 return EffectUI::DoEffect(
49 plug.GetID(), context,
52 return false;
@ PluginTypeEffect
static CommandManager & Get(AudacityProject &project)
CommandID GetCommandIdentifier(const PluginID &ID)
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1146

References CommandManager::CommandFailure, CommandManager::CommandNotFound, CommandManager::CommandSuccess, EffectUI::DoEffect(), PluginManager::Get(), EffectManager::Get(), CommandManager::Get(), EffectManager::GetCommandIdentifier(), EffectManager::kConfigured, PluginTypeEffect, and CommandContext::project.

Referenced by MacroCommands::ApplyCommand(), ScreenshotCommand::CapturePreferences(), and ToolBarButtons::OnButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAudacityCommand()

void CommandDispatch::OnAudacityCommand ( const CommandContext ctx)

Definition at line 98 of file CommandDispatch.cpp.

100 // using GET in a log message for devs' eyes only
101 wxLogDebug( "Command was: %s", ctx.parameter.GET());
102 // Not configured, so prompt user.
104 EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
CommandParameter parameter
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)

References DoAudacityCommand(), EffectManager::Get(), Identifier::GET(), EffectManager::kNone, and CommandContext::parameter.

Here is the call graph for this function: