Audacity 3.2.0
Public Member Functions | 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 OnReceiveCommand (AppCommandEvent &event)
 

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::CommandHandler ( )

Definition at line 30 of file CommandHandler.cpp.

31{
32}

◆ ~CommandHandler()

CommandHandler::~CommandHandler ( )

Definition at line 34 of file CommandHandler.cpp.

35{
36}

Member Function Documentation

◆ OnReceiveCommand()

void CommandHandler::OnReceiveCommand ( AppCommandEvent event)

Definition at line 38 of file CommandHandler.cpp.

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}
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
void Redraw()
Definition: Viewport.cpp:753
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33

References Viewport::Get(), GetActiveProject(), and Viewport::Redraw().

Here is the call graph for this function:

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