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 #include "../commands/CommandContext.h"
27 
29  : mCurrentContext(std::make_unique<CommandContext>
30  (*GetActiveProject()))
31 { }
32 
34 {
35 }
36 
38 {
39  // TODO: Review if the extend command handling is ever utilized
40  // mCurrentContext->proj = proj;
41 }
42 
44 {
45  // First retrieve the actual command from the event 'envelope'.
46  OldStyleCommandPointer cmd = event.GetCommand();
47 
48  // JKC: In case the user changed the project, let us track that.
49  // This saves us the embarrassment (crash) of a NEW project
50  // being opened, the old one closed and still trying to act
51  // on the old one.
53  // Then apply it to current application & project. Note that the
54  // command may change the context - for example, switching to a
55  // different project.
56  cmd->Apply(*mCurrentContext);
57 
58  // Redraw the project
59  mCurrentContext->GetProject()->RedrawProject();
60 }
Contains declaration of Command base class.
Headers and event table macros for AppCommandEvent.
Contains declarations for ScriptCommandRelay.
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
std::unique_ptr< CommandContext > mCurrentContext
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:308
void SetProject(AudacityProject *proj)
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.