Audacity  2.2.2
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 #include "../Audacity.h"
20 #include "CommandHandler.h"
21 #include <wx/event.h>
22 #include "../Project.h"
23 #include "Command.h"
24 #include "AppCommandEvent.h"
25 #include "ScriptCommandRelay.h"
26 
28  : mCurrentContext(std::make_unique<CommandExecutionContext>
29  (&app, GetActiveProject()))
30 { }
31 
33 {
34 }
35 
37 {
38  // TODO: Review if the extend command handling is ever utilized
39  // mCurrentContext->proj = proj;
40 }
41 
43 {
44  // First retrieve the actual command from the event 'envelope'.
45  CommandHolder cmd = event.GetCommand();
46 
47  // JKC: In case the user changed the project, let us track that.
48  // This saves us the embarrassment (crash) of a NEW project
49  // being opened, the old one closed and still trying to act
50  // on the old one.
52  // Then apply it to current application & project. Note that the
53  // command may change the context - for example, switching to a
54  // different project.
55  cmd->Apply(*mCurrentContext);
56 
57  // Redraw the project
58  mCurrentContext->GetProject()->RedrawProject();
59 }
std::shared_ptr< Command > CommandHolder
Contains declaration of Command base class.
Headers and event table macros for AppCommandEvent.
Contains declarations for ScriptCommandRelay.
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:158
CommandHandler(AudacityApp &app)
AudacityApp is the 'main' class for Audacity.
Definition: AudacityApp.h:59
Contains declarations for the CommandHandler class.
An event 'envelope' for sending Command objects through the wxwidgets event loop. ...
void OnReceiveCommand(AppCommandEvent &event)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:300
Represents a context to which a command may be applied.
Definition: Command.h:50
void SetProject(AudacityProject *proj)
std::unique_ptr< CommandExecutionContext > mCurrentContext