Audacity 3.2.0
LabelMenus.cpp
Go to the documentation of this file.
1#include "AudioIO.h"
2#include "../Clipboard.h"
3#include "../CommonCommandFlags.h"
4#include "../LabelTrack.h"
5#include "Prefs.h"
6#include "Project.h"
7#include "ProjectAudioIO.h"
8#include "ProjectHistory.h"
9#include "../ProjectWindow.h"
10#include "../SelectUtilities.h"
11#include "SyncLock.h"
12#include "../TrackPanelAx.h"
13#include "../TrackPanel.h"
14#include "ViewInfo.h"
15#include "WaveTrack.h"
16#include "../commands/CommandContext.h"
17#include "../commands/CommandManager.h"
18#include "../tracks/labeltrack/ui/LabelTrackView.h"
20
21#include <cassert>
22
25
26// private helper classes and functions
27namespace {
28
31 [](const AudacityProject &project){
32 // At least one label track selected, having at least one label
33 // completely within the time selection.
34 const auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
35 const auto &test = [&]( const LabelTrack *pTrack ){
36 const auto &labels = pTrack->GetLabels();
37 return std::any_of( labels.begin(), labels.end(),
38 [&](const LabelStruct &label){
39 return
40 label.getT0() >= selectedRegion.t0()
41 &&
42 label.getT1() <= selectedRegion.t1()
43 ;
44 }
45 );
46 };
47 auto range = TrackList::Get(project).Selected<const LabelTrack>()
48 + test;
49 return !range.empty();
50 }
51}; return flag; }
52
53//Adds label and returns index of label in labeltrack.
56 bool preserveFocus = false)
57{
58 auto &tracks = TrackList::Get( project );
59 auto &trackFocus = TrackFocus::Get( project );
60 auto &trackPanel = TrackPanel::Get( project );
61
62 wxString title; // of label
63
64 bool useDialog;
65 gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
66 if (useDialog) {
68 project, region, wxEmptyString, title) == wxID_CANCEL)
69 return -1; // index
70 }
71
72 // If the focused track is a label track, use that
73 const auto pFocusedTrack = trackFocus.Get();
74
75 // Look for a label track at or after the focused track
76 auto begin = tracks.begin();
77 auto iter = pFocusedTrack
78 ? tracks.Find(pFocusedTrack)
79 : begin;
80 auto lt = * iter.Filter<LabelTrack>();
81
82 // If none found, start a NEW label track and use it
83 if (!lt)
85
86// LLL: Commented as it seemed a little forceful to remove users
87// selection when adding the label. This does not happen if
88// you select several tracks and the last one of those is a
89// label track...typing a label will not clear the selections.
90//
91// SelectNone();
92 lt->SetSelected(true);
93
94 int index;
95 if (useDialog) {
96 index = lt->AddLabel(region, title);
97 }
98 else {
99 int focusTrackNumber = -1;
100 if (pFocusedTrack && preserveFocus) {
101 // Must remember the track to re-focus after finishing a label edit.
102 // do NOT identify it by a pointer, which might dangle! Identify
103 // by position.
104 focusTrackNumber = std::distance(begin, iter);
105 }
106 index =
107 LabelTrackView::Get( *lt ).AddLabel(region, title, focusTrackNumber);
108 }
109
111 .PushState(XO("Added label"), XO("Label"));
112
113 if (!useDialog) {
114 TrackFocus::Get(project).Set(lt);
115 lt->EnsureVisible();
116 }
117 trackPanel.SetFocus();
118
119 return index;
120}
121
122//get regions selected by selected labels
123//removes unnecessary regions, overlapping regions are merged
125 const TrackList &tracks, const SelectedRegion &selectedRegion,
126 Regions &regions )
127{
128 //determine labeled regions
129 for (auto lt : tracks.Selected< const LabelTrack >()) {
130 for (int i = 0; i < lt->GetNumLabels(); i++)
131 {
132 const LabelStruct *ls = lt->GetLabel(i);
133 if (ls->selectedRegion.t0() >= selectedRegion.t0() &&
134 ls->selectedRegion.t1() <= selectedRegion.t1())
135 regions.push_back(Region(ls->getT0(), ls->getT1()));
136 }
137 }
138
139 //anything to do ?
140 if( regions.size() == 0 )
141 return;
142
143 //sort and remove unnecessary regions
144 std::sort(regions.begin(), regions.end());
145 unsigned int selected = 1;
146 while( selected < regions.size() )
147 {
148 const Region &cur = regions.at( selected );
149 Region &last = regions.at( selected - 1 );
150 if( cur.start < last.end )
151 {
152 if( cur.end > last.end )
153 last.end = cur.end;
154 regions.erase( regions.begin() + selected );
155 }
156 else
157 ++selected;
158 }
159}
160
164using EditFunction = std::function<void(Track &track, double, double)>;
165
166//Executes the edit function on all selected wave tracks with
167//regions specified by selected labels
168//If No tracks selected, function is applied on all tracks
169//If the function replaces the selection with audio of a different length,
170// bSyncLockedTracks should be set true to perform the same action on sync-lock
171// selected tracks.
173 TrackList &tracks, const SelectedRegion &selectedRegion,
174 EditFunction action)
175{
176 Regions regions;
177
178 GetRegionsByLabel(tracks, selectedRegion, regions);
179 if (regions.empty())
180 return;
181
182 const bool notLocked = (!SyncLockState::Get(project).IsSyncLocked() &&
183 (tracks.Selected<PlayableTrack>()).empty());
184
185 //Apply action on tracks starting from
186 //labeled regions in the end. This is to correctly perform
187 //actions like 'Delete' which collapse the track area.
188 for (auto t : tracks) {
189 const bool playable = dynamic_cast<const PlayableTrack *>(t) != nullptr;
190 if (SyncLock::IsSyncLockSelected(t) || (notLocked && playable)) {
191 for (size_t i = regions.size(); i--;) {
192 const Region &region = regions.at(i);
193 action(*t, region.start, region.end);
194 }
195 }
196 }
197}
198
202 std::function<std::shared_ptr<TrackList>(Track &, double, double)>;
203
204//Executes the edit function on all selected wave tracks with
205//regions specified by selected labels
206//If No tracks selected, function is applied on all tracks
207//Functions copy the edited regions to clipboard, possibly in multiple tracks
208//This probably should not be called if *action() changes the timeline, because
209// the copy needs to happen by track, and the timeline change by group.
211 TrackList &tracks, const SelectedRegion &selectedRegion,
212 EditDestFunction action)
213{
214 Regions regions;
215
216 GetRegionsByLabel(tracks, selectedRegion, regions);
217 if (regions.empty())
218 return;
219
220 const bool notLocked = (!SyncLockState::Get(project).IsSyncLocked() &&
221 (tracks.Selected<PlayableTrack>()).empty());
222
223 auto &clipboard = Clipboard::Get();
224 clipboard.Clear();
225
226 auto pNewClipboard = TrackList::Create(nullptr);
227 auto &newClipboard = *pNewClipboard;
228
229 //Apply action on wavetracks starting from
230 //labeled regions in the end. This is to correctly perform
231 //actions like 'Cut' which collapse the track area.
232
233 for (auto t : tracks) {
234 const bool playable = dynamic_cast<const PlayableTrack *>(t) != nullptr;
235 if (SyncLock::IsSyncLockSelected(t) || (notLocked && playable)) {
236 // These tracks accumulate the needed clips, right to left:
237 std::shared_ptr<TrackList> merged;
238 for (size_t i = regions.size(); i--;) {
239 const Region &region = regions.at(i);
240 if (auto dest = action(*t, region.start, region.end)) {
241 if (!merged)
242 merged = dest;
243 else {
244 const auto pMerged = *merged->begin();
245 // Paste to the beginning; unless this is the first region,
246 // offset the track to account for time between the regions
247 if (i + 1 < regions.size())
248 pMerged->ShiftBy(
249 regions.at(i + 1).start - region.end);
250
251 // dest may have a placeholder clip at the end that is
252 // removed when pasting, which is okay because we proceed
253 // right to left. Any placeholder already in merged is kept.
254 // Only the rightmost placeholder is important in the final
255 // result.
256 pMerged->Paste(0.0, *dest);
257 }
258 }
259 else
260 // nothing copied but there is a 'region', so the 'region' must
261 // be a 'point label' so offset
262 if (i + 1 < regions.size() && merged)
263 (*merged->begin())
264 ->ShiftBy(regions.at(i + 1).start - region.end);
265 }
266 if (merged)
267 newClipboard.Append(std::move(*merged));
268 }
269 }
270
271 // Survived possibility of exceptions. Commit changes to the clipboard now.
272 clipboard.Assign( std::move( newClipboard ),
273 regions.front().start, regions.back().end, project.shared_from_this() );
274}
275
276}
277
279namespace {
280
281// Menu handler functions
282
283void OnEditLabels(const CommandContext &context)
284{
285 auto &project = context.project;
287}
288
289void OnAddLabel(const CommandContext &context)
290{
291 auto &project = context.project;
292 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
293
294 DoAddLabel(project, selectedRegion);
295}
296
298{
299 auto &project = context.project;
301
302 auto gAudioIO = AudioIO::Get();
303 if (token > 0 &&
304 gAudioIO->IsStreamActive(token)) {
305 double indicator = gAudioIO->GetStreamTime();
306 DoAddLabel(project, SelectedRegion(indicator, indicator), true);
307 }
308}
309
310// Creates a NEW label in each selected label track with text from the system
311// clipboard
312void OnPasteNewLabel(const CommandContext &context)
313{
314 auto &project = context.project;
315 auto &tracks = TrackList::Get( project );
316 auto &trackPanel = TrackPanel::Get( project );
317 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
318
319 bool bPastedSomething = false;
320
321 {
322 auto trackRange = tracks.Selected<const LabelTrack>();
323 if (trackRange.empty())
324 {
325 // If there are no selected label tracks, try to choose the first label
326 // track after some other selected track
327 Track *t = *tracks.Selected().begin()
328 .Filter(&Track::Any)
329 .Filter<LabelTrack>();
330
331 // If no match found, add one
332 if (!t)
334
335 // Select this track so the loop picks it up
336 t->SetSelected(true);
337 }
338 }
339
340 LabelTrack *plt = NULL; // the previous track
341 for ( auto lt : tracks.Selected<LabelTrack>() )
342 {
343 // Unselect the last label, so we'll have just one active label when
344 // we're done
345 if (plt)
347
348 // Add a NEW label, paste into it
349 // Paul L: copy whatever defines the selected region, not just times
350 auto &view = LabelTrackView::Get( *lt );
351 view.AddLabel(selectedRegion);
352 if (view.PasteSelectedText( context.project, selectedRegion.t0(),
353 selectedRegion.t1() ))
354 bPastedSomething = true;
355
356 // Set previous track
357 plt = lt;
358 }
359
360 // plt should point to the last label track pasted to -- ensure it's visible
361 // and set focus
362 if (plt) {
363 TrackFocus::Get(project).Set(plt);
364 plt->EnsureVisible();
365 trackPanel.SetFocus();
366 }
367
368 if (bPastedSomething) {
370 XO("Pasted from the clipboard"), XO("Paste Text to New Label"));
371 }
372}
373
374void OnToggleTypeToCreateLabel(const CommandContext &WXUNUSED(context) )
375{
376 bool typeToCreateLabel;
377 gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, false);
378 gPrefs->Write(wxT("/GUI/TypeToCreateLabel"), !typeToCreateLabel);
379 gPrefs->Flush();
381}
382
383void OnCutLabels(const CommandContext &context)
384{
385 auto &project = context.project;
387 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
388
389 if (selectedRegion.isPoint())
390 return;
391
392 // Because of grouping the copy may need to operate on different tracks than
393 // the clear, so we do these actions separately.
394 auto copyfunc = [&](Track &track, double t0, double t1) {
395 assert(track.IsLeader());
396 std::shared_ptr<TrackList> result;
397 track.TypeSwitch( [&](WaveTrack &wt) { result = wt.Copy(t0, t1); } );
398 return result;
399 };
400 EditClipboardByLabel(project, tracks, selectedRegion, copyfunc);
401
402 bool enableCutlines = gPrefs->ReadBool(wxT( "/GUI/EnableCutLines"), false);
403 auto editfunc = [&](Track &track, double t0, double t1) {
404 assert(track.IsLeader());
405 track.TypeSwitch(
406 [&](WaveTrack &t) {
407 if (enableCutlines)
408 t.ClearAndAddCutLine(t0, t1);
409 else
410 t.Clear(t0, t1);
411 },
412 [&](Track &t) {
413 t.Clear(t0, t1);
414 }
415 );
416 };
417 EditByLabel(project, tracks, selectedRegion, editfunc);
418
419 selectedRegion.collapseToT0();
420
422 /* i18n-hint: (verb) past tense. Audacity has just cut the labeled audio
423 regions.*/
424 XO("Cut labeled audio regions to clipboard"),
425 /* i18n-hint: (verb)*/
426 XO("Cut Labeled Audio"));
427}
428
429void OnDeleteLabels(const CommandContext &context)
430{
431 auto &project = context.project;
433 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
434
435 if (selectedRegion.isPoint())
436 return;
437
438 auto editfunc = [&](Track &track, double t0, double t1) {
439 assert(track.IsLeader());
440 track.TypeSwitch( [&](Track &t) { t.Clear(t0, t1); } );
441 };
442 EditByLabel(project, tracks, selectedRegion, editfunc);
443
444 selectedRegion.collapseToT0();
445
447 /* i18n-hint: (verb) Audacity has just deleted the labeled audio regions*/
448 XO("Deleted labeled audio regions"),
449 /* i18n-hint: (verb)*/
450 XO("Delete Labeled Audio"));
451}
452
454{
455 auto &project = context.project;
457 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
458
459 if (selectedRegion.isPoint())
460 return;
461
462 auto copyfunc = [&](Track &track, double t0, double t1) {
463 assert(track.IsLeader());
464 std::shared_ptr<TrackList> result;
465 track.TypeSwitch(
466 [&](WaveTrack &wt) {
467 result = wt.SplitCut(t0, t1);
468 },
469 [&](Track &t) {
470 result = t.Copy(t0, t1);
471 t.Silence(t0, t1);
472 }
473 );
474 return result;
475 };
476 EditClipboardByLabel(project, tracks, selectedRegion, copyfunc);
477
479 /* i18n-hint: (verb) Audacity has just split cut the labeled audio
480 regions*/
481 XO("Split Cut labeled audio regions to clipboard"),
482 /* i18n-hint: (verb) Do a special kind of cut on the labels*/
483 XO("Split Cut Labeled Audio"));
484}
485
487{
488 auto &project = context.project;
490 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
491
492 if (selectedRegion.isPoint())
493 return;
494
495 auto editfunc = [&](Track &track, double t0, double t1) {
496 assert(track.IsLeader());
497 track.TypeSwitch(
498 [&](WaveTrack &t) {
499 t.SplitDelete(t0, t1);
500 },
501 [&](Track &t) {
502 t.Silence(t0, t1);
503 }
504 );
505 };
506 EditByLabel(project, tracks, selectedRegion, editfunc);
507
509 /* i18n-hint: (verb) Audacity has just done a special kind of DELETE on
510 the labeled audio regions */
511 XO("Split Deleted labeled audio regions"),
512 /* i18n-hint: (verb) Do a special kind of DELETE on labeled audio
513 regions */
514 XO("Split Delete Labeled Audio"));
515}
516
517void OnSilenceLabels(const CommandContext &context)
518{
519 auto &project = context.project;
521 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
522
523 if (selectedRegion.isPoint())
524 return;
525
526 auto editfunc = [&](Track &track, double t0, double t1) {
527 assert(track.IsLeader());
528 // TODO use progress-bar utilities pending in
529 // https://github.com/audacity/audacity/pull/5043
530 track.TypeSwitch([&](WaveTrack& t) { t.Silence(t0, t1, {}); });
531 };
532 EditByLabel(project, tracks, selectedRegion, editfunc);
533
535 /* i18n-hint: (verb)*/
536 XO("Silenced labeled audio regions"),
537 /* i18n-hint: (verb)*/
538 XO("Silence Labeled Audio"));
539}
540
541void OnCopyLabels(const CommandContext &context)
542{
543 auto &project = context.project;
545 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
546
547 if (selectedRegion.isPoint())
548 return;
549
550 auto copyfunc = [&](Track &track, double t0, double t1) {
551 assert(track.IsLeader());
552 std::shared_ptr<TrackList> result;
553 track.TypeSwitch( [&](WaveTrack &wt) { result = wt.Copy(t0, t1); } );
554 return result;
555 };
556 EditClipboardByLabel(project, tracks, selectedRegion, copyfunc);
557
559 .PushState(XO("Copied labeled audio regions to clipboard"),
560 /* i18n-hint: (verb)*/
561 XO("Copy Labeled Audio"));
562}
563
564void OnSplitLabels(const CommandContext &context)
565{
566 auto &project = context.project;
568 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
569
570 if (selectedRegion.isPoint())
571 return;
572
573 auto editfunc = [&](Track &track, double t0, double t1) {
574 assert(track.IsLeader());
575 track.TypeSwitch( [&](WaveTrack &t) { t.Split(t0, t1); } );
576 };
577 EditByLabel(project, tracks, selectedRegion, editfunc);
578
580 /* i18n-hint: (verb) past tense. Audacity has just split the labeled
581 audio (a point or a region)*/
582 XO("Split labeled audio (points or regions)"),
583 /* i18n-hint: (verb)*/
584 XO("Split Labeled Audio"));
585}
586
587void OnJoinLabels(const CommandContext &context)
588{
589 auto &project = context.project;
591 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
592
593 if (selectedRegion.isPoint())
594 return;
595
596 auto editfunc = [&](Track &track, double t0, double t1) {
597 assert(track.IsLeader());
598 track.TypeSwitch( [&](WaveTrack &t) { t.Join(t0, t1); } );
599 };
600 EditByLabel(project, tracks, selectedRegion, editfunc);
601
603 /* i18n-hint: (verb) Audacity has just joined the labeled audio (points or
604 regions) */
605 XO("Joined labeled audio (points or regions)"),
606 /* i18n-hint: (verb) */
607 XO("Join Labeled Audio"));
608}
609
610void OnDisjoinLabels(const CommandContext &context)
611{
612 auto &project = context.project;
614 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
615
616 if (selectedRegion.isPoint())
617 return;
618
619 auto editfunc = [&](Track &track, double t0, double t1) {
620 assert(track.IsLeader());
621 track.TypeSwitch( [&](WaveTrack &t) {
622 wxBusyCursor busy;
623 t.Disjoin(t0, t1);
624 } );
625 };
626 EditByLabel(project, tracks, selectedRegion, editfunc);
627
629 /* i18n-hint: (verb) Audacity has just detached the labeled audio regions.
630 This message appears in history and tells you about something
631 Audacity has done.*/
632 XO("Detached labeled audio regions"),
633 /* i18n-hint: (verb)*/
634 XO("Detach Labeled Audio"));
635}
636
637void OnNewLabelTrack(const CommandContext &context)
638{
639 auto &project = context.project;
640 auto &tracks = TrackList::Get( project );
641
642 auto track = LabelTrack::Create(tracks);
643
645
646 track->SetSelected(true);
647
649 .PushState(XO("Created new label track"), XO("New Track"));
650
651 TrackFocus::Get(project).Set(track);
652 track->EnsureVisible();
653}
654
655// Menu definitions
656
657using namespace MenuTable;
659{
660 using namespace MenuTable;
662
663 static const auto NotBusyLabelsAndWaveFlags =
666
667 // Returns TWO menus.
668
669 static BaseItemSharedPtr menus{
670 Items( wxT("LabelEditMenus"),
671
672 Menu( wxT("Labels"), XXO("&Labels"),
673 Section( "",
674 Command( wxT("EditLabels"), XXO("Label &Editor"), OnEditLabels,
676 ),
677
678 Section( "",
679 Command( wxT("AddLabel"), XXO("Add Label at &Selection"),
680 OnAddLabel, AlwaysEnabledFlag, wxT("Ctrl+B") ),
681 Command( wxT("AddLabelPlaying"),
682 XXO("Add Label at &Playback Position"),
684 #ifdef __WXMAC__
685 wxT("Ctrl+.")
686 #else
687 wxT("Ctrl+M")
688 #endif
689 ),
690 Command( wxT("PasteNewLabel"), XXO("Paste Te&xt to New Label"),
692 AudioIONotBusyFlag(), wxT("Ctrl+Alt+V") )
693 ),
694
695 Section( "",
696 Command( wxT("TypeToCreateLabel"),
697 XXO("&Typing Creates New Labels"),
699 Options{}.CheckTest(wxT("/GUI/TypeToCreateLabel"), false) )
700 )
701 ), // first menu
702
704
705 Menu( wxT("Labeled"), XXO("La&beled Audio"),
706 Section( "",
707 /* i18n-hint: (verb)*/
708 Command( wxT("CutLabels"), XXO("&Cut"), OnCutLabels,
711 Options{ wxT("Alt+X"), XO("Label Cut") } ),
712 Command( wxT("DeleteLabels"), XXO("&Delete"), OnDeleteLabels,
715 Options{ wxT("Alt+K"), XO("Label Delete") } )
716 ),
717
718 Section( "",
719 /* i18n-hint: (verb) A special way to cut out a piece of audio*/
720 Command( wxT("SplitCutLabels"), XXO("&Split Cut"),
721 OnSplitCutLabels, NotBusyLabelsAndWaveFlags,
722 Options{ wxT("Alt+Shift+X"), XO("Label Split Cut") } ),
723 Command( wxT("SplitDeleteLabels"), XXO("Sp&lit Delete"),
724 OnSplitDeleteLabels, NotBusyLabelsAndWaveFlags,
725 Options{ wxT("Alt+Shift+K"), XO("Label Split Delete") } )
726 ),
727
728 Section( "",
729 Command( wxT("SilenceLabels"), XXO("Silence &Audio"),
730 OnSilenceLabels, NotBusyLabelsAndWaveFlags,
731 Options{ wxT("Alt+L"), XO("Label Silence") } ),
732 /* i18n-hint: (verb)*/
733 Command( wxT("CopyLabels"), XXO("Co&py"), OnCopyLabels,
734 NotBusyLabelsAndWaveFlags,
735 Options{ wxT("Alt+Shift+C"), XO("Label Copy") } )
736 ),
737
738 Section( "",
739 /* i18n-hint: (verb)*/
740 Command( wxT("SplitLabels"), XXO("Spli&t"), OnSplitLabels,
742 Options{ wxT("Alt+I"), XO("Label Split") } ),
743 /* i18n-hint: (verb)*/
744 Command( wxT("JoinLabels"), XXO("&Join"), OnJoinLabels,
745 NotBusyLabelsAndWaveFlags,
746 Options{ wxT("Alt+J"), XO("Label Join") } ),
747 Command( wxT("DisjoinLabels"), XXO("Detac&h at Silences"),
748 OnDisjoinLabels, NotBusyLabelsAndWaveFlags,
749 wxT("Alt+Shift+J") )
750 )
751 ) // second menu
752
753 ) }; // two menus
754 return menus;
755}
756
758 { wxT("Edit/Other"),
759 { OrderingHint::Before, wxT("EditMetaData") } },
761};
762
763AttachedItem sAttachment2{ wxT("Tracks/Add/Add"),
764 Command( wxT("NewLabelTrack"), XXO("&Label Track"),
766};
767
768}
wxT("CloseDown"))
AttachedItem sAttachment1
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & AudioIOBusyFlag()
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
WaveTrack::Region Region
Definition: LabelMenus.cpp:23
WaveTrack::Regions Regions
Definition: LabelMenus.cpp:24
static const auto title
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
TranslatableString label
Definition: TagsEditor.cpp:165
const auto tracks
const auto project
static std::once_flag flag
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static AudioIO * Get()
Definition: AudioIO.cpp:123
static Clipboard & Get()
Definition: Clipboard.cpp:28
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:29
double getT1() const
Definition: LabelTrack.h:40
double getT0() const
Definition: LabelTrack.h:39
SelectedRegion selectedRegion
Definition: LabelTrack.h:69
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
Definition: LabelTrack.cpp:76
static LabelTrackView & Get(LabelTrack &)
static int DialogForLabelName(AudacityProject &project, const SelectedRegion &region, const wxString &initialValue, wxString &value)
int AddLabel(const SelectedRegion &region, const wxString &title={}, int restoreFocus=-1)
static void DoEditLabels(AudacityProject &project, LabelTrack *lt=nullptr, int index=-1)
AudioTrack subclass that can also be audibly replayed by the program.
Definition: PlayableTrack.h:40
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
Defines a selected portion of a project.
double t1() const
double t0() const
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:82
bool IsSyncLocked() const
Definition: SyncLock.cpp:43
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:26
static void ModifyAllProjectToolbarMenus()
Track * Get()
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:123
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:86
virtual void SetSelected(bool s)
Definition: Track.cpp:75
R TypeSwitch(const Functions &...functions)
Definition: Track.h:427
virtual void Clear(double t0, double t1)=0
bool IsLeader() const override
Definition: Track.cpp:298
bool Any() const
Definition: Track.cpp:292
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:987
static TrackListHolder Create(AudacityProject *pOwner)
Definition: Track.cpp:372
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:354
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1108
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:232
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
A Track that contains audio waveform data.
Definition: WaveTrack.h:220
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1579
std::vector< Region > Regions
Definition: WaveTrack.h:241
void Silence(double t0, double t1, ProgressReporter reportProgress) override
Definition: WaveTrack.cpp:2116
void Join(double t0, double t1)
Definition: WaveTrack.cpp:2273
void ClearAndAddCutLine(double t0, double t1)
Definition: WaveTrack.cpp:1223
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:1215
void Split(double t0, double t1)
Definition: WaveTrack.cpp:3609
void Disjoin(double t0, double t1)
Definition: WaveTrack.cpp:2185
TrackListHolder Copy(double t0, double t1, bool forClipboard=true) const override
Create new tracks and don't modify this track.
Definition: WaveTrack.cpp:1147
TrackListHolder SplitCut(double t0, double t1)
Definition: WaveTrack.cpp:1055
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
bool ReadBool(const wxString &key, bool defaultValue) const
virtual bool Read(const wxString &key, bool *value) const =0
constexpr auto Section
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
constexpr auto Items
constexpr auto Command
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:113
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:78
void SelectNone(AudacityProject &project)
void OnAddLabel(const CommandContext &context)
Definition: LabelMenus.cpp:289
void OnSplitDeleteLabels(const CommandContext &context)
Definition: LabelMenus.cpp:486
int DoAddLabel(AudacityProject &project, const SelectedRegion &region, bool preserveFocus=false)
Definition: LabelMenus.cpp:54
void EditByLabel(AudacityProject &project, TrackList &tracks, const SelectedRegion &selectedRegion, EditFunction action)
Definition: LabelMenus.cpp:172
void OnSplitCutLabels(const CommandContext &context)
Definition: LabelMenus.cpp:453
void OnCopyLabels(const CommandContext &context)
Definition: LabelMenus.cpp:541
void OnSplitLabels(const CommandContext &context)
Definition: LabelMenus.cpp:564
void OnCutLabels(const CommandContext &context)
Definition: LabelMenus.cpp:383
void GetRegionsByLabel(const TrackList &tracks, const SelectedRegion &selectedRegion, Regions &regions)
Definition: LabelMenus.cpp:124
std::function< std::shared_ptr< TrackList >(Track &, double, double)> EditDestFunction
Definition: LabelMenus.cpp:202
void OnJoinLabels(const CommandContext &context)
Definition: LabelMenus.cpp:587
std::function< void(Track &track, double, double)> EditFunction
Definition: LabelMenus.cpp:164
void OnPasteNewLabel(const CommandContext &context)
Definition: LabelMenus.cpp:312
void OnDeleteLabels(const CommandContext &context)
Definition: LabelMenus.cpp:429
void OnEditLabels(const CommandContext &context)
Definition: LabelMenus.cpp:283
const ReservedCommandFlag & LabelsSelectedFlag()
Definition: LabelMenus.cpp:30
BaseItemSharedPtr LabelEditMenus()
Definition: LabelMenus.cpp:658
void OnSilenceLabels(const CommandContext &context)
Definition: LabelMenus.cpp:517
void OnDisjoinLabels(const CommandContext &context)
Definition: LabelMenus.cpp:610
void EditClipboardByLabel(AudacityProject &project, TrackList &tracks, const SelectedRegion &selectedRegion, EditDestFunction action)
Definition: LabelMenus.cpp:210
void OnAddLabelPlaying(const CommandContext &context)
Definition: LabelMenus.cpp:297
void OnToggleTypeToCreateLabel(const CommandContext &WXUNUSED(context))
Definition: LabelMenus.cpp:374
void OnNewLabelTrack(const CommandContext &context)
Definition: LabelMenus.cpp:637
Options && CheckTest(const CheckFn &fn) &&
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:228