Audacity  2.3.1
Public Member Functions | Private Attributes | List of all members
CommandHandler Class Reference

Contains methods for applying commands that are passed to it. More...

#include <CommandHandler.h>

Public Member Functions

 CommandHandler ()
 
 ~CommandHandler ()
 
void SetProject (AudacityProject *proj)
 
void OnReceiveCommand (AppCommandEvent &event)
 

Private Attributes

std::unique_ptr< CommandContextmCurrentContext
 

Detailed Description

Contains methods for applying commands that are passed to it.

Definition at line 25 of file CommandHandler.h.

Constructor & Destructor Documentation

CommandHandler::CommandHandler ( )

Definition at line 28 of file CommandHandler.cpp.

29  : mCurrentContext(std::make_unique<CommandContext>
30  (*GetActiveProject()))
31 { }
std::unique_ptr< CommandContext > mCurrentContext
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
CommandHandler::~CommandHandler ( )

Definition at line 33 of file CommandHandler.cpp.

34 {
35 }

Member Function Documentation

void CommandHandler::OnReceiveCommand ( AppCommandEvent event)

Definition at line 43 of file CommandHandler.cpp.

References GetActiveProject(), mCurrentContext, and SetProject().

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  auto result = GuardedCall<bool>( [&] {
57  return cmd->Apply(*mCurrentContext);
58  });
59  wxUnusedVar(result);
60 
61  // Redraw the project
62  mCurrentContext->GetProject()->RedrawProject();
63 }
std::unique_ptr< CommandContext > mCurrentContext
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
void SetProject(AudacityProject *proj)
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
void CommandHandler::SetProject ( AudacityProject proj)

Definition at line 37 of file CommandHandler.cpp.

Referenced by OnReceiveCommand().

38 {
39  // TODO: Review if the extend command handling is ever utilized
40  // mCurrentContext->proj = proj;
41 }

Member Data Documentation

std::unique_ptr<CommandContext> CommandHandler::mCurrentContext
private

Definition at line 28 of file CommandHandler.h.

Referenced by OnReceiveCommand().


The documentation for this class was generated from the following files: