Audacity 3.2.0
TimeTrackMenuItems.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5@file TimeTrackMenuItems.cpp
6@brief Injects menu items using TimeTrack but not the views of it
7
8Paul Licameli split from TrackMenus.cpp
9
10**********************************************************************/
11
12#include "CommonCommandFlags.h"
13#include "ProjectHistory.h"
14#include "ProjectWindow.h"
15#include "SelectUtilities.h"
16#include "TimeTrack.h"
17#include "TrackPanelAx.h"
18#include "ViewInfo.h"
19#include "../../../commands/CommandContext.h"
20#include "../../../commands/CommandManager.h"
22
23namespace {
24using namespace MenuTable;
25
27void OnNewTimeTrack(const CommandContext &context)
28{
29 auto &project = context.project;
30 auto &tracks = TrackList::Get( project );
31 auto &viewInfo = ViewInfo::Get( project );
32 auto &window = ProjectWindow::Get( project );
33
34 if ( *tracks.Any<TimeTrack>().begin() ) {
36 XO(
37"This version of Audacity only allows one time track for each project window.") );
38 return;
39 }
40
41 auto t = tracks.AddToHead( std::make_shared<TimeTrack>(&viewInfo) );
42
44
45 t->SetSelected(true);
46
47 ProjectHistory::Get( project )
48 .PushState(XO("Created new time track"), XO("New Track"));
49
50 TrackFocus::Get(project).Set(t);
51 t->EnsureVisible();
52}
53};
54
56 // Handler is not stateful. Doesn't need a factory registered with
57 // AudacityProject.
58 static Handler instance;
59 return instance;
60}
61
62#define FN(X) (&Handler :: X)
63AttachedItem sAttachment{ wxT("Tracks/Add/Add"),
65 Command( wxT("NewTimeTrack"), XXO("&Time Track"),
66 FN(OnNewTimeTrack), AudioIONotBusyFlag() )
67 )
68};
69#undef FN
70
71}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
wxEvtHandler CommandHandlerObject
const ReservedCommandFlag & AudioIONotBusyFlag()
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
#define FN(X)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
Track * Get()
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:98
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:467
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
void SelectNone(AudacityProject &project)
CommandHandlerObject & findCommandHandler(AudacityProject &)
void OnNewTimeTrack(const CommandContext &context)