Audacity 3.2.0
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
31{
32}
33
35{
36}
37
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()
Headers and event table macros for AppCommandEvent.
Contains declarations for the CommandHandler class.
Contains declarations for ScriptCommandRelay.
An event 'envelope' for sending Command objects through the wxwidgets event loop.
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
void OnReceiveCommand(AppCommandEvent &event)
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
void Redraw()
Definition: Viewport.cpp:753
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33