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 "DoEffect.h"
16#include "CommandContext.h"
17#include "CommandManager.h"
18#include "PluginManager.h"
19#include "ProjectAudioManager.h"
20#include "ProjectWindows.h"
21#include "Viewport.h"
23#include "EffectManager.h"
24#include "../effects/EffectUI.h"
25#include <wx/log.h>
26#include <wx/frame.h>
27
29 const CommandID & Str,
30 const CommandContext & context, CommandFlag flags, bool alwaysEnabled)
31{
32 auto &commandManager = CommandManager::Get(context.project);
33 switch ( commandManager.HandleTextualCommand(
34 Str, context, flags, alwaysEnabled) ) {
36 return true;
38 return false;
40 default:
41 break;
42 }
43
44 // Not one of the singleton commands.
45 // We could/should try all the list-style commands.
46 // instead we only try the effects.
47 auto& pm = PluginManager::Get();
48 for (auto &plug : PluginManager::Get().PluginsOfType(PluginTypeEffect))
49 if (pm.GetCommandIdentifier(plug.GetID()) == Str)
50 return EffectUI::DoEffect(
51 plug.GetID(), context.project, EffectManager::kConfigured);
52
53 return false;
54}
55
61 const PluginID & ID, const CommandContext & context, unsigned flags )
62{
63 auto &project = context.project;
65 if (!plug)
66 return false;
67
69 {
71// SelectAllIfNone();
72 }
73
75 context,
76 (flags & EffectManager::kConfigured) == 0);
77
78 if (!success)
79 return false;
80
81/*
82 if (em.GetSkipStateFlag())
83 flags = flags | OnEffectFlags::kSkipState;
84
85 if (!(flags & OnEffectFlags::kSkipState))
86 {
87 wxString shortDesc = em.GetCommandName(ID);
88 wxString longDesc = em.GetCommandDescription(ID);
89 PushState(longDesc, shortDesc);
90 }
91*/
93 return true;
94}
95
97{
98 // using GET in a log message for devs' eyes only
99 wxLogDebug( "Command was: %s", ctx.parameter.GET());
100 // Not configured, so prompt user.
102 PluginManager::Get().GetByCommandIdentifier(ctx.parameter), ctx,
104}
wxString PluginID
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:30
@ PluginTypeEffect
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)
static EffectAndCommandPluginManager & Get()
bool DoAudacityCommand(const PluginID &ID, const CommandContext &, 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:753
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)
bool DoEffect(const PluginID &ID, AudacityProject &project, unsigned flags)
Definition: DoEffect.cpp:30