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 "ProjectWindows.h"
20#include "Viewport.h"
21#include "../effects/EffectManager.h"
22#include "../effects/EffectUI.h"
23#include <wx/log.h>
24#include <wx/frame.h>
25
27 const CommandID & Str,
28 const CommandContext & context, CommandFlag flags, bool alwaysEnabled)
29{
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 }
41
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,
51
52 return false;
53}
54
60 const PluginID & ID, const CommandContext & context, unsigned flags )
61{
62 auto &project = context.project;
63 auto &window = GetProjectFrame(project);
65 if (!plug)
66 return false;
67
69 {
71// SelectAllIfNone();
72 }
73
75 bool success = em.DoAudacityCommand(ID,
76 context,
77 &window,
78 (flags & EffectManager::kConfigured) == 0);
79
80 if (!success)
81 return false;
82
83/*
84 if (em.GetSkipStateFlag())
85 flags = flags | OnEffectFlags::kSkipState;
86
87 if (!(flags & OnEffectFlags::kSkipState))
88 {
89 wxString shortDesc = em.GetCommandName(ID);
90 wxString longDesc = em.GetCommandDescription(ID);
91 PushState(longDesc, shortDesc);
92 }
93*/
95 return true;
96}
97
99{
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),
106}
wxString PluginID
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:30
@ PluginTypeEffect
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 ...
accessors for certain important windows associated with each project
const auto project
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandParameter parameter
AudacityProject & project
static CommandManager & Get(AudacityProject &project)
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)
void Redraw()
Definition: Viewport.cpp:749
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
AUDACITY_DLL_API bool HandleTextualCommand(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:1148