Audacity
3.2.0
src
commands
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
"
22
#include "
EffectAndCommandPluginManager.h
"
23
#include "
EffectManager.h
"
24
#include "../effects/EffectUI.h"
25
#include <wx/log.h>
26
#include <wx/frame.h>
27
28
bool
CommandDispatch::HandleTextualCommand
(
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) ) {
35
case
CommandManager::CommandSuccess
:
36
return
true
;
37
case
CommandManager::CommandFailure
:
38
return
false
;
39
case
CommandManager::CommandNotFound
:
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
60
bool
CommandDispatch::DoAudacityCommand
(
61
const
PluginID
& ID,
const
CommandContext
& context,
unsigned
flags )
62
{
63
auto
&
project
= context.
project
;
64
const
PluginDescriptor
*plug =
PluginManager::Get
().
GetPlugin
(ID);
65
if
(!plug)
66
return
false
;
67
68
if
(flags &
EffectManager::kConfigured
)
69
{
70
ProjectAudioManager::Get
(
project
).
Stop
();
71
// SelectAllIfNone();
72
}
73
74
bool
success =
EffectAndCommandPluginManager::Get
().
DoAudacityCommand
(ID,
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
*/
92
Viewport::Get
(
project
).
Redraw
();
93
return
true
;
94
}
95
96
void
CommandDispatch::OnAudacityCommand
(
const
CommandContext
& ctx)
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.
101
CommandDispatch::DoAudacityCommand
(
102
PluginManager::Get
().GetByCommandIdentifier(ctx.
parameter
), ctx,
103
EffectManager::kNone
);
104
}
CommandContext.h
CommandDispatch.h
PluginID
wxString PluginID
Definition:
CommandDispatch.h:20
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition:
CommandFlag.h:30
CommandManager.h
DoEffect.h
EffectAndCommandPluginManager.h
EffectManager.h
PluginTypeEffect
@ PluginTypeEffect
Definition:
PluginDescriptor.h:30
PluginManager.h
ProjectAudioManager.h
ProjectWindows.h
accessors for certain important windows associated with each project
project
const auto project
Definition:
TestWaveTrackMaker.cpp:18
Viewport.h
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition:
CommandContext.h:37
CommandContext::parameter
CommandParameter parameter
Definition:
CommandContext.h:75
CommandContext::project
AudacityProject & project
Definition:
CommandContext.h:71
CommandManager::CommandNotFound
@ CommandNotFound
Definition:
CommandManager.h:247
CommandManager::CommandFailure
@ CommandFailure
Definition:
CommandManager.h:245
CommandManager::CommandSuccess
@ CommandSuccess
Definition:
CommandManager.h:246
CommandManager::Get
static CommandManager & Get(AudacityProject &project)
Definition:
CommandManager.cpp:110
EffectAndCommandPluginManager::Get
static EffectAndCommandPluginManager & Get()
Definition:
EffectAndCommandPluginManager.cpp:20
EffectAndCommandPluginManager::DoAudacityCommand
bool DoAudacityCommand(const PluginID &ID, const CommandContext &, bool shouldPrompt=true)
Definition:
EffectAndCommandPluginManager.cpp:26
EffectManager::kNone
@ kNone
Definition:
EffectManager.h:57
EffectManager::kConfigured
@ kConfigured
Definition:
EffectManager.h:59
Identifier::GET
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
PluginDescriptor
Definition:
PluginDescriptor.h:43
PluginManager::GetPlugin
const PluginDescriptor * GetPlugin(const PluginID &ID) const
Definition:
PluginManager.cpp:1050
PluginManager::Get
static PluginManager & Get()
Definition:
PluginManager.cpp:380
ProjectAudioManager::Stop
void Stop(bool stopStream=true)
Definition:
ProjectAudioManager.cpp:501
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition:
ProjectAudioManager.cpp:57
TaggedIdentifier< CommandIdTag, false >
Viewport::Redraw
void Redraw()
Definition:
Viewport.cpp:753
Viewport::Get
static Viewport & Get(AudacityProject &project)
Definition:
Viewport.cpp:33
CommandDispatch::DoAudacityCommand
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
Definition:
CommandDispatch.cpp:60
CommandDispatch::HandleTextualCommand
AUDACITY_DLL_API bool HandleTextualCommand(const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
Definition:
CommandDispatch.cpp:28
CommandDispatch::OnAudacityCommand
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
Definition:
CommandDispatch.cpp:96
EffectUI::DoEffect
bool DoEffect(const PluginID &ID, AudacityProject &project, unsigned flags)
Definition:
DoEffect.cpp:30
Generated by
1.9.3