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