Audacity 3.2.0
EditMenus.cpp
Go to the documentation of this file.
1#include "../AdornedRulerPanel.h"
2#include "../Clipboard.h"
3#include "../CommonCommandFlags.h"
4#include "../LabelTrack.h"
5#include "../MenuCreator.h"
6#include "NoteTrack.h"
7#include "Project.h"
9#include "ProjectHistory.h"
10#include "ProjectRate.h"
12#include "../ProjectWindows.h"
13#include "../ProjectWindows.h"
14#include "../SelectUtilities.h"
15#include "SyncLock.h"
16#include "TempoChange.h"
17#include "../TrackPanel.h"
18#include "TrackFocus.h"
19#include "UndoManager.h"
20#include "ViewInfo.h"
21#include "WaveTrack.h"
22#include "WaveTrackUtilities.h"
23#include "TimeStretching.h"
24#include "WaveClip.h"
25#include "SampleBlock.h"
26#include "CommandContext.h"
27#include "TimeWarper.h"
28#include "../prefs/PrefsDialog.h"
29#include "../prefs/TracksBehaviorsPrefs.h"
30#include "../tracks/labeltrack/ui/LabelTrackView.h"
31#include "../tracks/playabletrack/wavetrack/ui/WaveChannelView.h"
32#include "AudacityMessageBox.h"
33#include "../AudioPasteDialog.h"
34#include "BasicUI.h"
35#include "Sequence.h"
36#include "UserException.h"
37#include "Viewport.h"
38
39#include <wx/clipbrd.h>
40#include <wx/frame.h>
41
42// private helper classes and functions
43namespace {
44
45// Handle text paste. Return true if did paste.
46// (This was formerly the first part of overly-long OnPaste.)
48{
49 auto &tracks = TrackList::Get( project );
50 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
51 auto &viewport = Viewport::Get(project);
52
53 // Paste into the active label (if any)
54 for (auto pLabelTrack : tracks.Any<LabelTrack>()) {
55 // Does this track have an active label?
56 if (LabelTrackView::Get( *pLabelTrack ).GetTextEditIndex(project) != -1) {
57
58 // Yes, so try pasting into it
59 auto &view = LabelTrackView::Get( *pLabelTrack );
60 if (view.PasteSelectedText( project, selectedRegion.t0(),
61 selectedRegion.t1() ))
62 {
64 .PushState(XO("Pasted text from the clipboard"), XO("Paste"));
65
66 // Make sure caret is in view
67 int x;
68 if (view.CalcCursorX( project, &x )) {
69 viewport.ScrollIntoView(x);
70 }
71
72 return true;
73 }
74 }
75 }
76
77 //Presumably, there might be not more than one track
78 //that expects text input
79 for (auto wt : tracks.Any<WaveTrack>()) {
80 auto& view = WaveChannelView::GetFirst(*wt);
81 if (view.PasteText(project)) {
82 auto &trackPanel = TrackPanel::Get(project);
83 trackPanel.Refresh(false);
84 return true;
85 }
86 }
87
88 return false;
89}
90
91wxULongLong EstimateCopyBytesCount(const TrackList& src, const TrackList& dst)
92{
93 wxULongLong result{};
94 for (auto waveTrack : src.Any<const WaveTrack>()) {
95 const auto samplesCount =
97 result += samplesCount.as_long_long() *
98 SAMPLE_SIZE(waveTrack->GetSampleFormat());
99 }
100 return result;
101}
102
103BlockArray::size_type EstimateCopiedBlocks(const TrackList& src, const TrackList& dst)
104{
105 BlockArray::size_type result{};
106 for (const auto waveTrack : src.Any<const WaveTrack>())
107 result += WaveTrackUtilities::CountBlocks(*waveTrack);
108 return result;
109}
110
111std::shared_ptr<TrackList> DuplicateDiscardTrimmed(const TrackList& src) {
112 auto result = TrackList::Create(nullptr);
113 for (auto track : src) {
114 const auto pTrack =
115 track->Copy(track->GetStartTime(), track->GetEndTime(), false);
116 pTrack->MoveTo(track->GetStartTime());
117 if (const auto waveTrack = dynamic_cast<WaveTrack*>(pTrack.get()))
119 result->Add(pTrack);
120 }
121 return result;
122}
123
124// Create and paste into NEW tracks.
125// Simplified version of DoPaste, used when there is no selection
126// on tracks
127// (This was formerly the second part of overly-long OnPaste.)
128void DoPasteNothingSelected(AudacityProject &project, const TrackList& src, double t0, double t1)
129{
130 auto &tracks = TrackList::Get( project );
131 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
132 auto &viewInfo = ViewInfo::Get( project );
133
134 assert(tracks.Selected().empty());
135
136 Track* pFirstNewTrack = NULL;
137 for (auto pClip : src) {
138 auto pNewTrack = pClip->PasteInto(project, tracks);
139 if (!pFirstNewTrack)
140 pFirstNewTrack = pNewTrack.get();
141 pNewTrack->SetSelected(true);
142 }
143
144 // Select some pasted samples, which is probably impossible to get right
145 // with various project and track sample rates.
146 // So do it at the sample rate of the project
147 const double projRate = ProjectRate::Get( project ).GetRate();
148 const double projTempo = ProjectTimeSignature::Get(project).GetTempo();
149 const double srcTempo =
150 pFirstNewTrack ? GetProjectTempo(*pFirstNewTrack).value_or(projTempo) :
151 projTempo;
152 // Apply adequate stretching to the selection. A selection of 10 seconds of
153 // audio in project A should become 5 seconds in project B if tempo in B is
154 // twice as fast.
155 const double quantT0 = QUANTIZED_TIME(t0 * srcTempo / projTempo, projRate);
156 const double quantT1 = QUANTIZED_TIME(t1 * srcTempo / projTempo, projRate);
157 selectedRegion.setTimes(
158 0.0, // anywhere else and this should be
159 // half a sample earlier
160 quantT1 - quantT0);
161
163 .PushState(XO("Pasted from the clipboard"), XO("Paste"));
164
165 if (pFirstNewTrack) {
166 TrackFocus::Get(project).Set(pFirstNewTrack);
167 Viewport::Get(project).ShowTrack(*pFirstNewTrack);
168 }
169}
170
171bool HasHiddenData(const TrackList& trackList)
172{
173 const auto range = trackList.Any<const WaveTrack>();
174 return std::any_of(range.begin(), range.end(),
175 [](const WaveTrack *pTrack){
176 return WaveTrackUtilities::HasHiddenData(*pTrack);
177 });
178}
179
180// Menu handler functions
181
182void OnUndo(const CommandContext &context)
183{
184 auto &project = context.project;
185 auto &tracks = TrackList::Get( project );
186 auto &trackPanel = TrackPanel::Get( project );
187 auto &undoManager = UndoManager::Get( project );
188
189 if (!ProjectHistory::Get( project ).UndoAvailable()) {
190 AudacityMessageBox( XO("Nothing to undo") );
191 return;
192 }
193
194 // can't undo while dragging
195 if (trackPanel.IsMouseCaptured()) {
196 return;
197 }
198
199 undoManager.Undo(
200 [&]( const UndoStackElem &elem ){
202
203 auto t = *tracks.Selected().begin();
204 if (!t)
205 t = *tracks.begin();
206 TrackFocus::Get(project).Set(t);
207 if (t)
209}
210
211void OnRedo(const CommandContext &context)
212{
213 auto &project = context.project;
214 auto &tracks = TrackList::Get( project );
215 auto &trackPanel = TrackPanel::Get( project );
216 auto &undoManager = UndoManager::Get( project );
217
218 if (!ProjectHistory::Get( project ).RedoAvailable()) {
219 AudacityMessageBox( XO("Nothing to redo") );
220 return;
221 }
222 // Can't redo whilst dragging
223 if (trackPanel.IsMouseCaptured()) {
224 return;
225 }
226
227 undoManager.Redo(
228 [&]( const UndoStackElem &elem ){
230
231 auto t = *tracks.Selected().begin();
232 if (!t)
233 t = *tracks.begin();
234 TrackFocus::Get(project).Set(t);
235 if (t)
237}
238
239void OnCut(const CommandContext &context)
240{
241 auto &project = context.project;
242 auto &tracks = TrackList::Get( project );
243 auto &trackPanel = TrackPanel::Get( project );
244 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
246
247 // This doesn't handle cutting labels, it handles
248 // cutting the _text_ inside of labels, i.e. if you're
249 // in the middle of editing the label text and select "Cut".
250
251 for (auto lt : tracks.Selected<LabelTrack>()) {
252 auto &view = LabelTrackView::Get( *lt );
253 if (view.CutSelectedText( context.project )) {
254 trackPanel.Refresh(false);
255 return;
256 }
257 }
258
259 //Presumably, there might be not more than one track
260 //that expects text input
261 for (auto wt : tracks.Any<WaveTrack>()) {
262 auto& view = WaveChannelView::GetFirst(*wt);
263 if (view.CutSelectedText(context.project)) {
264 trackPanel.Refresh(false);
265 return;
266 }
267 }
268
269 auto &clipboard = Clipboard::Get();
270 clipboard.Clear();
271
272 auto pNewClipboard = TrackList::Create( nullptr );
273 auto &newClipboard = *pNewClipboard;
274
275 tracks.Selected().Visit(
276#if defined(USE_MIDI)
277 [&](NoteTrack &n) {
278 // Since portsmf has a built-in cut operator, we use that instead
279 auto dest = n.Cut(selectedRegion.t0(), selectedRegion.t1());
280 newClipboard.Add(dest);
281 },
282#endif
283 [&](Track &n) {
284 if (n.SupportsBasicEditing()) {
285 auto dest = n.Copy(selectedRegion.t0(), selectedRegion.t1());
286 newClipboard.Add(dest);
287 }
288 }
289 );
290
291 // Survived possibility of exceptions. Commit changes to the clipboard now.
292 clipboard.Assign(
293 std::move( newClipboard ),
294 selectedRegion.t0(),
295 selectedRegion.t1(),
296 project.shared_from_this()
297 );
298
299 // Proceed to change the project. If this throws, the project will be
300 // rolled back by the top level handler.
301
303#if defined(USE_MIDI)
304 [](NoteTrack&) {
305 //if NoteTrack, it was cut, so do not clear anything
306
307 // PRL: But what if it was sync lock selected only, not selected?
308 },
309#endif
310 [&](auto &&fallthrough){ return [&](WaveTrack &wt) {
311 if (gPrefs->Read(wxT("/GUI/EnableCutLines"), (long)0))
312 wt.ClearAndAddCutLine(selectedRegion.t0(), selectedRegion.t1());
313 else
314 fallthrough();
315 }; },
316 [&](Track &n) {
317 if (n.SupportsBasicEditing())
318 n.Clear(selectedRegion.t0(), selectedRegion.t1());
319 }
320 );
321
322 selectedRegion.collapseToT0();
323
325 .PushState(XO("Cut to the clipboard"), XO("Cut"));
326
327 // Bug 1663
328 //mRuler->ClearPlayRegion();
329 ruler.DrawOverlays( true );
330}
331
332void OnDelete(const CommandContext &context)
333{
334 auto &project = context.project;
335 auto &tracks = TrackList::Get( project );
336 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
337
338 for (auto n : tracks) {
339 if (!n->SupportsBasicEditing())
340 continue;
342 n->Clear(selectedRegion.t0(), selectedRegion.t1());
343 }
344 }
345
346 double seconds = selectedRegion.duration();
347
348 selectedRegion.collapseToT0();
349
351 XO("Deleted %.2f seconds at t=%.2f")
352 .Format( seconds, selectedRegion.t0()),
353 XO("Delete"));
354}
355
356
357void OnCopy(const CommandContext &context)
358{
359 if (wxTheClipboard->Open())
360 {
361 // Clear the data from the clipboard, so that the next paste doesn't
362 // attempt to import whatever the user copied from the OS in a prior
363 // action.
364 const auto success = wxTheClipboard->SetData(safenew wxTextDataObject);
365 assert(success);
366 wxTheClipboard->Clear();
367 wxTheClipboard->Close();
368 }
369
370 auto &project = context.project;
371 auto &tracks = TrackList::Get( project );
372 auto &trackPanel = TrackPanel::Get( project );
373 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
374
375 for (auto lt : tracks.Selected<LabelTrack>()) {
376 auto &view = LabelTrackView::Get( *lt );
377 if (view.CopySelectedText( context.project )) {
378 //trackPanel.Refresh(false);
379 return;
380 }
381 }
382 //Presumably, there might be not more than one track
383 //that expects text input
384 for (auto wt : tracks.Any<WaveTrack>()) {
385 auto& view = WaveChannelView::GetFirst(*wt);
386 if (view.CopySelectedText(context.project)) {
387 return;
388 }
389 }
390
391 auto &clipboard = Clipboard::Get();
392 clipboard.Clear();
393
394 auto pNewClipboard = TrackList::Create( nullptr );
395 auto &newClipboard = *pNewClipboard;
396
397 for (auto n : tracks.Selected()) {
398 if (n->SupportsBasicEditing()) {
399 auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1());
400 newClipboard.Add(dest);
401 }
402 }
403
404 // Survived possibility of exceptions. Commit changes to the clipboard now.
405 clipboard.Assign( std::move( newClipboard ),
406 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() );
407
408 //Make sure the menus/toolbar states get updated
409 trackPanel.Refresh(false);
410}
411
412std::pair<double, double> FindSelection(const CommandContext &context)
413{
414 double sel0 = 0.0, sel1 = 0.0;
415
416#if 0
417 // Use the overriding selection if any was given in the context
418 if (auto *pRegion = context.temporarySelection.pSelectedRegion) {
419 auto &selectedRegion = *pRegion;
420 sel0 = selectedRegion.t0();
421 sel1 = selectedRegion.t1();
422 }
423 else
424#endif
425 {
426 auto &selectedRegion = ViewInfo::Get(context.project).selectedRegion;
427 sel0 = selectedRegion.t0();
428 sel1 = selectedRegion.t1();
429 }
430
431 return { sel0, sel1 };
432}
433
434std::shared_ptr<const TrackList> FindSourceTracks(const CommandContext &context)
435{
436 auto &project = context.project;
437 auto &window = GetProjectFrame(project);
439 const auto &clipboard = Clipboard::Get();
440 auto discardTrimmed = false;
441 if (&context.project != &*clipboard.Project().lock()) {
442 const auto waveClipCopyPolicy = TracksBehaviorsAudioTrackPastePolicy.Read();
443 if (waveClipCopyPolicy == wxT("Ask") &&
444 HasHiddenData(clipboard.GetTracks()))
445 {
446 AudioPasteDialog audioPasteDialog(
447 &window,
448 EstimateCopyBytesCount(clipboard.GetTracks(), tracks)
449 );
450 const auto result = audioPasteDialog.ShowModal();
451 if(result == wxID_CANCEL)
452 return {};
453 discardTrimmed =
455 }
456 else if(waveClipCopyPolicy == wxT("Discard"))
457 discardTrimmed = true;
458 }
459
460 std::shared_ptr<const TrackList> srcTracks;
461 if(discardTrimmed)
462 srcTracks = DuplicateDiscardTrimmed(clipboard.GetTracks());
463 else
464 srcTracks = clipboard.GetTracks().shared_from_this();
465
466 return srcTracks;
467}
468
470 const CommandContext &context, const TrackList &srcTracks)
471{
472 auto &project = context.project;
474 auto &trackFactory = WaveTrackFactory::Get(project);
475 auto &pSampleBlockFactory = trackFactory.GetSampleBlockFactory();
476 return pSampleBlockFactory->Subscribe([
477 toCopy = EstimateCopiedBlocks(srcTracks, tracks),
478 nCopied = 0,
479 copyStartTime = std::chrono::system_clock::now(),
480 progressDialog = std::shared_ptr<BasicUI::ProgressDialog>()]
481 (const SampleBlockCreateMessage&) mutable {
482 using namespace std::chrono;
483 constexpr auto ProgressDialogShowDelay = milliseconds { 100 };
484 ++nCopied;
485 if(!progressDialog) {
486 if(duration_cast<milliseconds>(system_clock::now() - copyStartTime) >= ProgressDialogShowDelay)
487 progressDialog = BasicUI::MakeProgress(XO("Paste clip"), XO("Pasting clip contents, please wait"), 0);
488 }
489 else {
490 progressDialog->Poll(nCopied, toCopy);
491 }
492 });
493}
494
496bool FitsInto(const Track &src, const Track &dst)
497{
498 if (!src.SameKindAs(dst))
499 return false;
500 // Mono can "fit" into stereo, by duplication of the channel
501 // Otherwise non-wave tracks always have just one "channel"
502 // Future: Fit stereo into mono too, using mix-down
503 return src.NChannels() <= dst.NChannels();
504}
505
506// First, destination track; second, source
507using Correspondence = std::vector<std::pair<Track*, const Track*>>;
508
510 TrackList &dstTracks, const TrackList &srcTracks)
511{
512 Correspondence result;
513 auto dstRange = dstTracks.Selected();
514 if (dstRange.size() == 1)
515 // Special rule when only one track is selected interprets the user's
516 // intent as pasting into that track and following ones
517 dstRange = dstTracks.Any().StartingWith(*dstRange.begin());
518 auto srcRange = srcTracks.Any();
519 while (!(dstRange.empty() || srcRange.empty())) {
520 auto &dst = **dstRange.begin();
521 auto &src = **srcRange.begin();
522 if (!FitsInto(src, dst)) {
523 // Skip selected track of inappropriate type and try again
524 ++dstRange.first;
525 continue;
526 }
527 result.emplace_back(&dst, &src);
528 ++srcRange.first;
529 ++dstRange.first;
530 }
531
532 if (!srcRange.empty())
533 // Could not fit all source tracks into the selected tracks
534 return {};
535 else
536 return result;
537}
538
539void OnPaste(const CommandContext &context)
540{
541 if (wxTheClipboard->IsSupported(wxDF_FILENAME) && wxTheClipboard->Open())
542 {
543 wxFileDataObject data;
544 const auto hadData = wxTheClipboard->GetData(data);
545 wxTheClipboard->Close();
546 if (hadData)
547 {
548 ProjectFileManager::Get(context.project).Import(data.GetFilenames());
549 return;
550 }
551 }
552
553 auto &project = context.project;
554
555 // Handle text paste first.
556 if (DoPasteText(project))
557 return;
558
559 const auto &clipboard = Clipboard::Get();
560 if (clipboard.GetTracks().empty())
561 return;
562
563 const auto srcTracks = FindSourceTracks(context);
564 if (!srcTracks)
565 // user cancelled
566 return;
567
568 auto notificationScope = NotificationScope(context, *srcTracks);
569
571 // If nothing's selected, we just insert new tracks.
572 if (!tracks.Selected()) {
574 project, *srcTracks, clipboard.T0(), clipboard.T1());
575 return;
576 }
577
578 // Otherwise, paste into the selected tracks.
579 double t0, t1;
580 std::tie(t0, t1) = FindSelection(context);
581 auto newT1 = t0 + clipboard.Duration();
582 const auto isSyncLocked = SyncLockState::Get(project).IsSyncLocked();
583
584 Track *ff = nullptr;
585 bool bPastedSomething = false;
586
587 // Find tracks to paste in
588 auto correspondence = FindCorrespondence(tracks, *srcTracks);
589 if (correspondence.empty()) {
590 if (tracks.Selected().size() == 1)
592"The content you are trying to paste will span across more tracks than you "
593"currently have available. Add more tracks and try again.")
594 );
595 else
597"There are not enough tracks selected to accommodate your copied content. "
598"Select additional tracks and try again.")
599 );
600 return;
601 }
602 auto iPair = correspondence.begin();
603 const auto endPair = correspondence.cend();
604
605 // Outer loop by sync-lock groups
606 auto next = tracks.begin();
607 for (auto range = tracks.Any(); !range.empty();
608 // Skip to next sync lock group
609 range.first = next
610 ) {
611 if (iPair == endPair)
612 // Nothing more to paste
613 break;
614 auto group = SyncLock::Group(**range.first);
615 next = tracks.Find(*group.rbegin());
616 ++next;
617
618 if (!group.contains(iPair->first))
619 // Nothing to paste into this group
620 continue;
621
622 // Inner loop over the sync-lock group by tracks
623 for (auto member : group) {
624 if (iPair == endPair || member != iPair->first) {
625 if (isSyncLocked) {
626 // Track is not pasted into but must be adjusted
627 if (t1 != newT1 && t1 <= member->GetEndTime()) {
628 member->SyncLockAdjust(t1, newT1);
629 bPastedSomething = true;
630 }
631 }
632 }
633 else {
634 // Remember first pasted-into track, to focus it
635 if (!ff)
636 ff = member;
637 // Do the pasting!
638 const auto src = (iPair++)->second;
639 member->TypeSwitch(
640 [&](WaveTrack &wn){
641 bPastedSomething = true;
642 // For correct remapping of preserved split lines:
643 PasteTimeWarper warper{ t1, t0 + src->GetEndTime() };
644 const auto newClipOnPaste =
645 gPrefs->ReadBool(wxT("/GUI/PasteAsNewClips"), false);
646 // The new-clip-on-paste behavior means: not merging the
647 // clipboard data with data at the selection borders; not
648 // reproducing boundaries within the selected region in the
649 // new clip; preserving the data underneath by trimming
650 // (rather than deleting).
651 // The legacy behavior is the opposite.
652 const auto merge = newClipOnPaste ? false : true;
653 const auto preserveExistingBoundaries = newClipOnPaste ? false : true;
654 auto clearByTrimming = newClipOnPaste ? true : false;
655 wn.ClearAndPaste(
656 t0, t1, *static_cast<const WaveTrack*>(src),
657 preserveExistingBoundaries, merge, &warper,
658 clearByTrimming);
659 },
660 [&](LabelTrack &ln){
661 // Per Bug 293, users expect labels to move on a paste into
662 // a label track.
663 ln.Clear(t0, t1);
664
665 ln.ShiftLabelsOnInsert( clipboard.Duration(), t0 );
666
667 bPastedSomething |= ln.PasteOver(t0, *src);
668 },
669 [&](Track &t){
670 bPastedSomething = true;
671 t.Clear(t0, t1);
672 t.Paste(t0, *src);
673 }
674 );
675 }
676 }
677 }
678
679 // TODO: What if we clicked past the end of the track?
680
681 if (bPastedSomething) {
683 .setTimes( t0, t0 + clipboard.Duration() );
684
686 .PushState(XO("Pasted from the clipboard"), XO("Paste"));
687
688 if (ff) {
689 TrackFocus::Get(project).Set(ff);
691 }
692 }
693}
694
695void OnDuplicate(const CommandContext &context)
696{
697 auto &project = context.project;
699 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
700
701 // This iteration is unusual because we add to the list inside the loop
702 auto range = tracks.Selected();
703 auto last = *range.rbegin();
704 for (auto n : range) {
705 if (!n->SupportsBasicEditing())
706 continue;
707
708 // Make copies not for clipboard but for direct addition to the project
709 auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1(), false);
710 dest->MoveTo(std::max(selectedRegion.t0(), n->GetStartTime()));
711 tracks.Add(dest);
712
713 // This break is really needed, else we loop infinitely
714 if (n == last)
715 break;
716 }
717
719 .PushState(XO("Duplicated"), XO("Duplicate"));
720}
721
722void OnSplitCut(const CommandContext &context)
723{
724 auto &project = context.project;
726 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
727
728 auto &clipboard = Clipboard::Get();
729 clipboard.Clear();
730
731 auto pNewClipboard = TrackList::Create(nullptr);
732 auto &newClipboard = *pNewClipboard;
733
734 tracks.Selected().Visit(
735 [&](WaveTrack &n) {
736 auto track = n.SplitCut(selectedRegion.t0(), selectedRegion.t1());
737 newClipboard.Add(track);
738 },
739 [&](Track &n) {
740 if (n.SupportsBasicEditing()) {
741 auto dest = n.Copy(selectedRegion.t0(), selectedRegion.t1());
742 n.Silence(selectedRegion.t0(), selectedRegion.t1());
743 newClipboard.Add(dest);
744 }
745 }
746 );
747
748 // Survived possibility of exceptions. Commit changes to the clipboard now.
749 clipboard.Assign(std::move(newClipboard),
750 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this());
751
753 .PushState(XO("Split-cut to the clipboard"), XO("Split Cut"));
754}
755
756void OnSplitDelete(const CommandContext &context)
757{
758 auto &project = context.project;
760 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
761
762 tracks.Selected().Visit(
763 [&](WaveTrack &wt) {
764 wt.SplitDelete(selectedRegion.t0(), selectedRegion.t1());
765 },
766 [&](Track &n) {
767 if (n.SupportsBasicEditing())
768 n.Silence(selectedRegion.t0(), selectedRegion.t1());
769 }
770 );
771
773 XO("Split-deleted %.2f seconds at t=%.2f")
774 .Format(selectedRegion.duration(), selectedRegion.t0()),
775 XO("Split Delete"));
776}
777
778void OnSilence(const CommandContext &context)
779{
780 auto &project = context.project;
782 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
783
784 const auto selectedWaveTracks = tracks.Selected<WaveTrack>();
786 [&](const ProgressReporter& parent) {
788 selectedWaveTracks.begin(), selectedWaveTracks.end(),
789 [&](WaveTrack* n, const ProgressReporter& child) {
790 n->Silence(selectedRegion.t0(), selectedRegion.t1(), child);
791 },
792 parent);
793 });
794
796 XO("Silenced selected tracks for %.2f seconds at %.2f")
797 .Format(selectedRegion.duration(), selectedRegion.t0()),
798 /* i18n-hint: verb */
799 XC("Silence", "command"));
800}
801
802void OnTrim(const CommandContext &context)
803{
804 auto &project = context.project;
805 auto &tracks = TrackList::Get( project );
806 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
807
808 if (selectedRegion.isPoint())
809 return;
810
811 tracks.Selected().Visit( [&](WaveTrack &wt) {
812 //Hide the section before the left selector
813 wt.Trim(selectedRegion.t0(), selectedRegion.t1());
814 } );
815
817 XO("Trim selected audio tracks from %.2f seconds to %.2f seconds")
818 .Format( selectedRegion.t0(), selectedRegion.t1() ),
819 XO("Trim Audio"));
820}
821
822void OnSplit(const CommandContext &context)
823{
824 auto &project = context.project;
826 auto [sel0, sel1] = FindSelection(context);
827 if (auto *pTrack = context.temporarySelection.pTrack) {
828 if (auto pWaveTrack = dynamic_cast<WaveTrack*>(pTrack))
829 pWaveTrack->Split(sel0, sel1);
830 else
831 // Did nothing, don't push history
832 return;
833 }
834 else
835 for (auto wt : tracks.Selected<WaveTrack>())
836 wt->Split(sel0, sel1);
837
838 ProjectHistory::Get( project ).PushState(XO("Split"), XO("Split"));
839#if 0
840//ANSWER-ME: Do we need to keep this commented out OnSplit() code?
841// This whole section no longer used...
842 /*
843 * Previous (pre-multiclip) implementation of "Split" command
844 * This does work only when a range is selected!
845 *
846 TrackListIterator iter(tracks);
847
848 Track *n = iter.First();
849 Track *dest;
850
851 TrackList newTracks;
852
853 while (n) {
854 if (n->GetSelected()) {
855 double sel0 = selectedRegion.t0();
856 double sel1 = selectedRegion.t1();
857
858 dest = n->Copy(sel0, sel1);
859 dest->Init(*n);
860 dest->MoveTo(std::max(sel0, n->GetOffset()));
861
862 if (sel1 >= n->GetEndTime())
863 n->Clear(sel0, sel1);
864 else if (sel0 <= n->GetOffset()) {
865 n->Clear(sel0, sel1);
866 n->MoveTo(sel1);
867 } else
868 n->Silence(sel0, sel1);
869
870 newTracks.Add(dest);
871 }
872 n = iter.Next();
873 }
874
875 TrackListIterator nIter(&newTracks);
876 n = nIter.First();
877 while (n) {
878 tracks->Add(n);
879 n = nIter.Next();
880 }
881
882 PushState(XO("Split"), XO("Split"));
883 */
884#endif
885}
886
887void OnSplitNew(const CommandContext &context)
888{
889 auto &project = context.project;
891 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
892
893 // This iteration is unusual because we add to the list inside the loop
894 auto range = tracks.Selected();
895 auto last = *range.rbegin();
896 for (auto track : range) {
897 track->TypeSwitch(
898 [&](WaveTrack &wt) {
899 // Clips must be aligned to sample positions or the NEW clip will
900 // not fit in the gap where it came from
901 const double newt0 = wt.SnapToSample(selectedRegion.t0());
902 const double newt1 = wt.SnapToSample(selectedRegion.t1());
903 // Fix issue 2846 by calling copy with forClipboard = false.
904 // This avoids creating the blank placeholder clips
905 const auto dest = wt.Copy(newt0, newt1, false);
906 if (dest) {
907 // The copy function normally puts the clip at time 0
908 // This offset lines it up with the original track's timing
909 dest->MoveTo(newt0);
910 tracks.Add(dest);
911 }
912 wt.SplitDelete(newt0, newt1);
913 }
914#if 0
915 ,
916 // LL: For now, just skip all non-wave tracks since the other do not
917 // yet support proper splitting.
918 [&](Track &n) {
919 dest = n.Cut(viewInfo.selectedRegion.t0(),
920 viewInfo.selectedRegion.t1());
921 if (dest) {
922 dest->MoveTo(std::max(0, n.GetOffset()));
923 tracks.Add(dest);
924 }
925 }
926#endif
927 );
928 if (track == last)
929 break;
930 }
931
933 .PushState(XO("Split to new track"), XO("Split New"));
934}
935
936void OnJoin(const CommandContext &context)
937{
938 auto &project = context.project;
940 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
941 const auto selectedTracks = tracks.Selected<WaveTrack>();
943 [&](const ProgressReporter& reportProgress) {
944 using namespace BasicUI;
946 selectedTracks.begin(), selectedTracks.end(),
947 [&](WaveTrack* wt, const ProgressReporter& childProgress) {
948 wt->Join(
949 selectedRegion.t0(), selectedRegion.t1(), childProgress);
950 },
951 reportProgress);
952 });
953
955 XO("Joined %.2f seconds at t=%.2f")
956 .Format(selectedRegion.duration(), selectedRegion.t0()),
957 XO("Join"));
958}
959
960void OnDisjoin(const CommandContext &context)
961{
962 auto &project = context.project;
964 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
965
966 for (auto wt : tracks.Selected<WaveTrack>())
967 wt->Disjoin(selectedRegion.t0(), selectedRegion.t1());
968
970 XO("Detached %.2f seconds at t=%.2f")
971 .Format(selectedRegion.duration(), selectedRegion.t0()),
972 XO("Detach"));
973}
974
975void OnPreferences(const CommandContext &context)
976{
977 auto &project = context.project;
978
979 GlobalPrefsDialog dialog(&GetProjectFrame(project) /* parent */, &project );
980
981 if (!dialog.ShowModal()) {
982 // Canceled
983 return;
984 }
985
986 // LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
987 // rebuilding the menus while the PrefsDialog is still in the modal
988 // state.
989 for (auto p : AllProjects{}) {
991// TODO: The comment below suggests this workaround is obsolete.
992#if defined(__WXGTK__)
993 // Workaround for:
994 //
995 // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
996 //
997 // This workaround should be removed when Audacity updates to wxWidgets
998 // 3.x which has a fix.
999 auto &window = GetProjectFrame( *p );
1000 wxRect r = window.GetRect();
1001 window.SetSize(wxSize(1,1));
1002 window.SetSize(r.GetSize());
1003#endif
1004 }
1005}
1006
1007// Legacy functions, not used as of version 2.3.0
1008
1009#if 0
1010void OnPasteOver(const CommandContext &context)
1011{
1012 auto &project = context.project;
1013 auto &selectedRegion = project.GetViewInfo().selectedRegion;
1014
1015 if((AudacityProject::msClipT1 - AudacityProject::msClipT0) > 0.0)
1016 {
1017 selectedRegion.setT1(
1018 selectedRegion.t0() +
1019 (AudacityProject::msClipT1 - AudacityProject::msClipT0));
1020 // MJS: pointless, given what we do in OnPaste?
1021 }
1022 OnPaste(context);
1023
1024 return;
1025}
1026#endif
1027
1028// Menu definitions
1029
1032 [](const AudacityProject &project){
1033 auto range = TrackList::Get(project).Any<const LabelTrack>()
1034 + [&](const LabelTrack *pTrack){
1035 return LabelTrackView::Get( *pTrack ).IsTextSelected(
1036 // unhappy const_cast because track focus might be set
1037 const_cast<AudacityProject&>(project)
1038 );
1039 };
1040 if ( !range.empty() )
1041 return true;
1042
1043 if (
1045 &&
1047 )
1048 return true;
1049
1050 return false;
1051 },
1053}; return flag; }
1054
1057 [](const AudacityProject &project)
1058 {
1060 return false;
1061
1062 const auto &viewInfo = ViewInfo::Get(project);
1063 if(viewInfo.selectedRegion.isPoint())
1064 return false;
1065
1066 const auto selectedTracks = TrackList::Get(project).Selected<const WaveTrack>();
1067 for (const auto track : selectedTracks)
1068 {
1069 const auto selectedClips =
1071 viewInfo.selectedRegion.t0(), viewInfo.selectedRegion.t1());
1072 if(selectedClips.size() > 1)
1073 return true;
1074 }
1075 return false;
1076 },
1078}; return flag; }
1079
1080using namespace MenuRegistry;
1082{
1083 static const auto NotBusyTimeAndTracksFlags =
1085
1086 // The default shortcut key for Redo is different on different platforms.
1087 static constexpr auto redoKey =
1088#ifdef __WXMSW__
1089 wxT("Ctrl+Y")
1090#else
1091 wxT("Ctrl+Shift+Z")
1092#endif
1093 ;
1094
1095 // The default shortcut key for Preferences is different on different
1096 // platforms.
1097 static constexpr auto prefKey =
1098#ifdef __WXMAC__
1099 wxT("Ctrl+,")
1100#else
1101 wxT("Ctrl+P")
1102#endif
1103 ;
1104
1105 static auto menu = std::shared_ptr{
1106 Menu( wxT("Edit"), XXO("&Edit"),
1107 Section( "UndoRedo",
1108 Command( wxT("Undo"), XXO("&Undo"), OnUndo,
1109 AudioIONotBusyFlag() | UndoAvailableFlag(), wxT("Ctrl+Z") ),
1110
1111 Command( wxT("Redo"), XXO("&Redo"), OnRedo,
1112 AudioIONotBusyFlag() | RedoAvailableFlag(), redoKey ),
1113
1114 MenuCreator::Special( wxT("UndoItemsUpdateStep"),
1115 [](AudacityProject &project, wxMenu&) {
1116 // Change names in the CommandManager as a side-effect
1118 })
1119 ),
1120
1121 Section( "Basic",
1122 // Basic Edit commands
1123 /* i18n-hint: (verb)*/
1124 Command( wxT("Cut"), XXO("Cu&t"), OnCut,
1126 wxT("Ctrl+X") ),
1127 Command( wxT("Delete"), XXO("&Delete"), OnDelete,
1129 wxT("Ctrl+K") ),
1130 /* i18n-hint: (verb)*/
1131 Command( wxT("Copy"), XXO("&Copy"), OnCopy,
1132 AudioIONotBusyFlag() | CutCopyAvailableFlag(), wxT("Ctrl+C") ),
1133 /* i18n-hint: (verb)*/
1134 Command( wxT("Paste"), XXO("&Paste"), OnPaste,
1135 AudioIONotBusyFlag(), wxT("Ctrl+V") ),
1136 /* i18n-hint: (verb)*/
1137 Command( wxT("Duplicate"), XXO("Duplic&ate"), OnDuplicate,
1138 NotBusyTimeAndTracksFlags, wxT("Ctrl+D") ),
1139
1140 Section( "",
1141 Menu( wxT("RemoveSpecial"), XXO("R&emove Special"),
1142 Section( "",
1143 /* i18n-hint: (verb) Do a special kind of cut*/
1144 Command( wxT("SplitCut"), XXO("Spl&it Cut"), OnSplitCut,
1145 NotBusyTimeAndTracksFlags,
1146 Options{ wxT("Ctrl+Alt+X") } ),
1147 /* i18n-hint: (verb) Do a special kind of DELETE*/
1148 Command( wxT("SplitDelete"), XXO("Split D&elete"), OnSplitDelete,
1149 NotBusyTimeAndTracksFlags,
1150 Options{ wxT("Ctrl+Alt+K") } )
1151 ),
1152
1153 Section( "",
1154 /* i18n-hint: (verb)*/
1155 Command( wxT("Silence"), XXO("Silence Audi&o"), OnSilence,
1157 wxT("Ctrl+L") ),
1158 /* i18n-hint: (verb)*/
1159 Command( wxT("Trim"), XXO("Tri&m Audio"), OnTrim,
1161 Options{ wxT("Ctrl+T") } )
1162 )
1163 )
1164 )
1165 ),
1166
1167
1168 Section( "Other",
1170
1171 Menu( wxT("Clip"), XXO("Audi&o Clips"),
1172 Section( "",
1173 /* i18n-hint: (verb) It's an item on a menu. */
1174 Command( wxT("Split"), XXO("Sp&lit"), OnSplit,
1176 Options{ wxT("Ctrl+I") } ),
1177 Command( wxT("SplitNew"), XXO("Split Ne&w"), OnSplitNew,
1179 Options{ wxT("Ctrl+Alt+I") } )
1180 ),
1181
1182 Section( "",
1183 /* i18n-hint: (verb)*/
1184 Command( wxT("Join"), XXO("&Join"), OnJoin,
1185 JoinClipsAvailableFlag(), wxT("Ctrl+J") ),
1186 Command( wxT("Disjoin"), XXO("Detac&h at Silences"), OnDisjoin,
1187 NotBusyTimeAndTracksFlags, wxT("Ctrl+Alt+J") )
1188 )
1189 )
1190
1191 ),
1192
1193 // Note that on Mac, the Preferences menu item is specially handled in
1194 // CommandManager (assigned a special wxWidgets id) so that it does
1195 // not appear in the Edit menu but instead under Audacity, consistent with
1196 // MacOS conventions.
1197 Section( "Preferences",
1198 Command( wxT("Preferences"), XXO("Pre&ferences"), OnPreferences,
1199 AudioIONotBusyFlag(), prefKey )
1200 )
1201
1202 ) };
1203 return menu;
1204}
1205
1207
1209{
1210 static const auto flags =
1212 static auto menu = std::shared_ptr{
1213 Menu( wxT("Edit"), XXO("&Edit"),
1214 Command( wxT("DeleteKey"), XXO("&Delete Key"), OnDelete,
1215 (flags | NoAutoSelect()),
1216 wxT("Backspace") ),
1217 Command( wxT("DeleteKey2"), XXO("Delete Key&2"), OnDelete,
1218 (flags | NoAutoSelect()),
1219 wxT("Delete") )
1220 ) };
1221 return menu;
1222}
1223
1228 (flagsRqd & NoAutoSelect()).none() )
1230};
1231
1233 []{ return TracksExistFlag(); },
1234 []{ return EditableTracksSelectedFlag(); },
1236 selectAll
1237}};
1238
1239// Including time tracks.
1241 []{ return TracksExistFlag(); },
1242 []{ return AnyTracksSelectedFlag(); },
1244 selectAll
1245}};
1246
1248 []{ return WaveTracksExistFlag(); },
1251 selectAll
1252}};
1253
1254// Also enable select for the noise reduction case.
1256 []{ return WaveTracksExistFlag(); },
1259 selectAll
1260}};
1261
1263 wxT("Optional/Extra/Part1")
1264};
1265
1266}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Toolkit-neutral facade for basic user interface services.
AttachedItem sAttachment1
AttachedItem sAttachment2
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:30
const ReservedCommandFlag & NoAutoSelect()
const ReservedCommandFlag & NoiseReductionTimeSelectedFlag()
bool EditableTracksSelectedPred(const AudacityProject &project)
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & UndoAvailableFlag()
const ReservedCommandFlag & RedoAvailableFlag()
bool AudioIOBusyPred(const AudacityProject &project)
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & EditableTracksSelectedFlag()
const ReservedCommandFlag & AnyTracksSelectedFlag()
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
bool TimeSelectedPred(const AudacityProject &project)
@ none
Definition: Dither.h:20
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:10
#define QUANTIZED_TIME(time, rate)
Definition: MemoryX.h:336
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
an object holding per-project preferred sample rate
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:52
const std::optional< double > & GetProjectTempo(const ChannelGroup &group)
Definition: TempoChange.cpp:48
const auto tracks
const auto project
Contains declarations for TimeWarper, IdentityTimeWarper, ShiftTimeWarper, LinearTimeWarper,...
std::function< void(double)> ProgressReporter
Definition: Track.h:48
ChoiceSetting TracksBehaviorsAudioTrackPastePolicy
An AudacityException with no visible message.
static std::once_flag flag
static AdornedRulerPanel & Get(AudacityProject &project)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual size_t NChannels() const =0
Report the number of channels.
wxString Read() const
Definition: Prefs.cpp:388
static Clipboard & Get()
Definition: Clipboard.cpp:28
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
TemporarySelection temporarySelection
AudacityProject & project
static CommandManager & Get(AudacityProject &project)
Abstract base class used in importing a file.
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:95
static LabelTrackView & Get(LabelTrack &)
bool IsTextSelected(AudacityProject &project) const
int GetTextEditIndex(AudacityProject &project) const
static constexpr auto Special
Definition: MenuCreator.h:36
void RebuildMenuBar()
static MenuCreator & Get(AudacityProject &project)
Definition: MenuCreator.cpp:91
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
Track::Holder Cut(double t0, double t1) override
Create tracks and modify this track.
Definition: NoteTrack.cpp:320
void Clear(double t0, double t1) override
Definition: NoteTrack.cpp:397
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Create new tracks and don't modify this track.
Definition: NoteTrack.cpp:350
double duration() const
Definition: ViewInfo.h:41
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
double t0() const
Definition: ViewInfo.h:35
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
int ShowModal() override
bool Import(const FilePath &fileName, bool addToHistory=true)
static ProjectFileManager & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
void PopState(const UndoState &state, bool doAutosave=true)
static ProjectHistory & Get(AudacityProject &project)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
static ProjectTimeSignature & Get(AudacityProject &project)
Generates classes whose instances register items at construction.
Definition: Registry.h:388
static TrackIterRange< Track > Group(Track &track)
Definition: SyncLock.cpp:150
static bool IsSelectedOrSyncLockSelectedP(const Track *pTrack)
Definition: SyncLock.h:61
static bool IsSelectedOrSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:104
bool IsSyncLocked() const
Definition: SyncLock.cpp:44
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:27
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
virtual Holder PasteInto(AudacityProject &project, TrackList &list) const =0
bool SameKindAs(const Track &track) const
Definition: Track.h:373
virtual bool SupportsBasicEditing() const
Whether this track type implements cut-copy-paste; by default, true.
Definition: Track.cpp:797
R TypeSwitch(const Functions &...functions)
Definition: Track.h:381
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
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
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
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
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
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:3349
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1503
void Silence(double t0, double t1, ProgressReporter reportProgress) override
Definition: WaveTrack.cpp:1979
void Trim(double t0, double t1)
Definition: WaveTrack.cpp:957
Holder SplitCut(double t0, double t1)
Definition: WaveTrack.cpp:943
void ClearAndPaste(double t0, double t1, const WaveTrack &src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=nullptr, bool clearByTrimming=false)
Definition: WaveTrack.cpp:1196
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
double SnapToSample(double t) const
bool ReadBool(const wxString &key, bool defaultValue) const
virtual bool Read(const wxString &key, bool *value) const =0
std::function< void(double)> ProgressReporter
Definition: BasicUI.h:25
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
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:302
constexpr auto Section
Definition: MenuRegistry.h:436
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
MENUS_API void Visit(Visitor< Traits > &visitor, AudacityProject &project)
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175
void DoSelectAllAudio(AudacityProject &project)
WAVE_TRACK_API void WithClipRenderingProgress(std::function< void(const ProgressReporter &)> action, TranslatableString title=defaultStretchRenderingTitle)
WAVE_TRACK_API size_t CountBlocks(const WaveTrack &track)
WAVE_TRACK_API sampleCount GetSequenceSamplesCount(const WaveTrack &track)
WAVE_TRACK_API void DiscardTrimmed(WaveTrack &track)
Remove hidden audio from all clips.
WAVE_TRACK_API WaveTrack::IntervalConstHolders GetClipsIntersecting(const WaveTrack &track, double t0, double t1)
std::shared_ptr< const TrackList > FindSourceTracks(const CommandContext &context)
Definition: EditMenus.cpp:434
Correspondence FindCorrespondence(TrackList &dstTracks, const TrackList &srcTracks)
Definition: EditMenus.cpp:509
wxULongLong EstimateCopyBytesCount(const TrackList &src, const TrackList &dst)
Definition: EditMenus.cpp:91
BlockArray::size_type EstimateCopiedBlocks(const TrackList &src, const TrackList &dst)
Definition: EditMenus.cpp:103
void OnDisjoin(const CommandContext &context)
Definition: EditMenus.cpp:960
void DoPasteNothingSelected(AudacityProject &project, const TrackList &src, double t0, double t1)
Definition: EditMenus.cpp:128
bool DoPasteText(AudacityProject &project)
Definition: EditMenus.cpp:47
void OnRedo(const CommandContext &context)
Definition: EditMenus.cpp:211
void OnJoin(const CommandContext &context)
Definition: EditMenus.cpp:936
RegisteredMenuItemEnabler selectWaveTracks
Definition: EditMenus.cpp:1247
std::shared_ptr< TrackList > DuplicateDiscardTrimmed(const TrackList &src)
Definition: EditMenus.cpp:111
bool FitsInto(const Track &src, const Track &dst)
Whether the source track may be pasted into the destination track.
Definition: EditMenus.cpp:496
RegisteredMenuItemEnabler selectTracks
Definition: EditMenus.cpp:1232
void OnDelete(const CommandContext &context)
Definition: EditMenus.cpp:332
auto NotificationScope(const CommandContext &context, const TrackList &srcTracks)
Definition: EditMenus.cpp:469
void OnPaste(const CommandContext &context)
Definition: EditMenus.cpp:539
const ReservedCommandFlag & CutCopyAvailableFlag()
Definition: EditMenus.cpp:1031
void OnSplit(const CommandContext &context)
Definition: EditMenus.cpp:822
std::pair< double, double > FindSelection(const CommandContext &context)
Definition: EditMenus.cpp:412
void OnSilence(const CommandContext &context)
Definition: EditMenus.cpp:778
RegisteredMenuItemEnabler selectWaveTracks2
Definition: EditMenus.cpp:1255
const ReservedCommandFlag & JoinClipsAvailableFlag()
Definition: EditMenus.cpp:1056
void OnTrim(const CommandContext &context)
Definition: EditMenus.cpp:802
void OnSplitDelete(const CommandContext &context)
Definition: EditMenus.cpp:756
std::vector< std::pair< Track *, const Track * > > Correspondence
Definition: EditMenus.cpp:507
void OnCopy(const CommandContext &context)
Definition: EditMenus.cpp:357
void OnUndo(const CommandContext &context)
Definition: EditMenus.cpp:182
void OnSplitCut(const CommandContext &context)
Definition: EditMenus.cpp:722
void OnPreferences(const CommandContext &context)
Definition: EditMenus.cpp:975
void OnDuplicate(const CommandContext &context)
Definition: EditMenus.cpp:695
RegisteredMenuItemEnabler selectAnyTracks
Definition: EditMenus.cpp:1240
bool HasHiddenData(const TrackList &trackList)
Definition: EditMenus.cpp:171
void OnSplitNew(const CommandContext &context)
Definition: EditMenus.cpp:887
void OnCut(const CommandContext &context)
Definition: EditMenus.cpp:239
CommandFlagOptions && DisableDefaultMessage() &&
Definition: CommandFlag.h:53
SelectedRegion * pSelectedRegion
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:117
UndoState state
Definition: UndoManager.h:128