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 "../../../commands/CommandContext.h"
19#include "../../../commands/CommandManager.h"
20#include "AudacityMessageBox.h"
21
22namespace {
23using namespace MenuTable;
24
25void OnNewTimeTrack(const CommandContext &context)
26{
27 auto &project = context.project;
28 auto &tracks = TrackList::Get( project );
29 auto &window = ProjectWindow::Get( project );
30
31
32 if (*tracks.Any<TimeTrack>().begin()) {
34 XO(
35"This version of Audacity only allows one time track for each project window.") );
36 return;
37 }
38
39 auto t = tracks.AddToHead(std::make_shared<TimeTrack>());
40
42
43 t->SetSelected(true);
44
46 .PushState(XO("Created new time track"), XO("New Track"));
47
49 t->EnsureVisible();
50}
51
52AttachedItem sAttachment{ wxT("Tracks/Add/Add"),
53 Command( wxT("NewTimeTrack"), XXO("&Time Track"),
55 )
56};
57
58}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const ReservedCommandFlag & AudioIONotBusyFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
const auto tracks
const auto project
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:86
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:354
constexpr auto Command
void SelectNone(AudacityProject &project)
void OnNewTimeTrack(const CommandContext &context)