Audacity 3.2.0
CommandDispatch.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file CommandDispatch.cpp
6 @brief implements functions HandleTextualCommand, DoAudacityCommand,
7 OnAudacityCommand
8
9 Paul Licameli split from BatchCommands.cpp
10
11**********************************************************************/
12
13#include "CommandDispatch.h"
14
15#include "CommandContext.h"
16#include "CommandManager.h"
17#include "PluginManager.h"
18#include "ProjectAudioManager.h"
19#include "ProjectWindow.h"
20#include "../effects/EffectManager.h"
21#include "../effects/EffectUI.h"
22#include <wx/log.h>
23
25 const CommandID & Str,
26 const CommandContext & context, CommandFlag flags, bool alwaysEnabled)
27{
28 switch ( commandManager.HandleTextualCommand(
29 Str, context, flags, alwaysEnabled) ) {
31 return true;
33 return false;
35 default:
36 break;
37 }
38
39 // Not one of the singleton commands.
40 // We could/should try all the list-style commands.
41 // instead we only try the effects.
43 for (auto &plug : PluginManager::Get().PluginsOfType(PluginTypeEffect))
44 if (em.GetCommandIdentifier(plug.GetID()) == Str)
45 return EffectUI::DoEffect(
46 plug.GetID(), context,
48
49 return false;
50}
51
57 const PluginID & ID, const CommandContext & context, unsigned flags )
58{
59 auto &project = context.project;
60 auto &window = ProjectWindow::Get( project );
62 if (!plug)
63 return false;
64
66 {
68// SelectAllIfNone();
69 }
70
72 bool success = em.DoAudacityCommand(ID,
73 context,
74 &window,
75 (flags & EffectManager::kConfigured) == 0);
76
77 if (!success)
78 return false;
79
80/*
81 if (em.GetSkipStateFlag())
82 flags = flags | OnEffectFlags::kSkipState;
83
84 if (!(flags & OnEffectFlags::kSkipState))
85 {
86 wxString shortDesc = em.GetCommandName(ID);
87 wxString longDesc = em.GetCommandDescription(ID);
88 PushState(longDesc, shortDesc);
89 }
90*/
91 window.RedrawProject();
92 return true;
93}
94
96{
97 // using GET in a log message for devs' eyes only
98 wxLogDebug( "Command was: %s", ctx.parameter.GET());
99 // Not configured, so prompt user.
101 EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
103}
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:30
wxString PluginID
Definition: EffectManager.h:30
@ PluginTypeEffect
const auto project
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandParameter parameter
AudacityProject & project
CommandManager implements a system for organizing all user-callable commands.
TextualCommandResult HandleTextualCommand(const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48
CommandID GetCommandIdentifier(const PluginID &ID)
static EffectManager & Get()
bool DoAudacityCommand(const PluginID &ID, const CommandContext &, wxWindow *parent, bool shouldPrompt=true)
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
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
void Stop(bool stopStream=true)
static ProjectAudioManager & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
AUDACITY_DLL_API bool HandleTextualCommand(CommandManager &commandManager, const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1144