Audacity
3.2.0
src
commands
CommandHandler.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
3
Audacity - A Digital Audio Editor
4
Copyright 1999-2009 Audacity Team
5
File License: wxWidgets
6
7
Dan Horgan
8
9
******************************************************************/
/*******************************************************************/
18
19
20
#include "
CommandHandler.h
"
21
22
#include "../ActiveProject.h"
23
#include "
Project.h
"
24
#include "
AppCommandEvent.h
"
25
#include "
ScriptCommandRelay.h
"
26
#include "
CommandContext.h
"
27
#include "../commands/Command.h"
28
#include "
Viewport.h
"
29
30
CommandHandler::CommandHandler
()
31
{
32
}
33
34
CommandHandler::~CommandHandler
()
35
{
36
}
37
38
void
CommandHandler::OnReceiveCommand
(
AppCommandEvent
&event)
39
{
40
// First retrieve the actual command from the event 'envelope'.
41
OldStyleCommandPointer
cmd =
event
.GetCommand();
42
43
if
(
const
auto
pProject =
GetActiveProject
().lock()) {
44
// Then apply it to current application & project. Note that the
45
// command may change the context - for example, switching to a
46
// different project.
47
CommandContext
context{ *pProject };
48
auto
result = GuardedCall<bool>( [&] {
49
return
cmd->Apply( context );
50
});
51
wxUnusedVar(result);
52
53
// Redraw the project
54
Viewport::Get
(context.project).
Redraw
();
55
}
56
}
GetActiveProject
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
Definition:
ActiveProject.cpp:22
AppCommandEvent.h
Headers and event table macros for AppCommandEvent.
CommandContext.h
CommandHandler.h
Contains declarations for the CommandHandler class.
Project.h
ScriptCommandRelay.h
Contains declarations for ScriptCommandRelay.
Viewport.h
AppCommandEvent
An event 'envelope' for sending Command objects through the wxwidgets event loop.
Definition:
AppCommandEvent.h:30
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition:
CommandContext.h:37
CommandHandler::OnReceiveCommand
void OnReceiveCommand(AppCommandEvent &event)
Definition:
CommandHandler.cpp:38
CommandHandler::~CommandHandler
~CommandHandler()
Definition:
CommandHandler.cpp:34
CommandHandler::CommandHandler
CommandHandler()
Definition:
CommandHandler.cpp:30
OldStyleCommandPointer
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
Viewport::Redraw
void Redraw()
Definition:
Viewport.cpp:753
Viewport::Get
static Viewport & Get(AudacityProject &project)
Definition:
Viewport.cpp:33
Generated by
1.9.3