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
240{
241 if (wxTheClipboard->Open())
242 {
243 // Clear the data from the clipboard, so that the next paste doesn't
244 // attempt to import whatever the user copied from the OS in a prior
245 // action.
246 const auto success = wxTheClipboard->SetData(safenew wxTextDataObject);
247 assert(success);
248 wxTheClipboard->Clear();
249 wxTheClipboard->Close();
250 }
251}
252
253void OnCut(const CommandContext &context)
254{
256
257 auto &project = context.project;
258 auto &tracks = TrackList::Get( project );
259 auto &trackPanel = TrackPanel::Get( project );
260 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
262
263 // This doesn't handle cutting labels, it handles
264 // cutting the _text_ inside of labels, i.e. if you're
265 // in the middle of editing the label text and select "Cut".
266
267 for (auto lt : tracks.Selected<LabelTrack>()) {
268 auto &view = LabelTrackView::Get( *lt );
269 if (view.CutSelectedText( context.project )) {
270 trackPanel.Refresh(false);
271 return;
272 }
273 }
274
275 //Presumably, there might be not more than one track
276 //that expects text input
277 for (auto wt : tracks.Any<WaveTrack>()) {
278 auto& view = WaveChannelView::GetFirst(*wt);
279 if (view.CutSelectedText(context.project)) {
280 trackPanel.Refresh(false);
281 return;
282 }
283 }
284
285 auto &clipboard = Clipboard::Get();
286 clipboard.Clear();
287
288 auto pNewClipboard = TrackList::Create( nullptr );
289 auto &newClipboard = *pNewClipboard;
290
291 tracks.Selected().Visit(
292#if defined(USE_MIDI)
293 [&](NoteTrack &n) {
294 // Since portsmf has a built-in cut operator, we use that instead
295 auto dest = n.Cut(selectedRegion.t0(), selectedRegion.t1());
296 newClipboard.Add(dest);
297 },
298#endif
299 [&](Track &n) {
300 if (n.SupportsBasicEditing()) {
301 auto dest = n.Copy(selectedRegion.t0(), selectedRegion.t1());
302 newClipboard.Add(dest);
303 }
304 }
305 );
306
307 // Survived possibility of exceptions. Commit changes to the clipboard now.
308 clipboard.Assign(
309 std::move( newClipboard ),
310 selectedRegion.t0(),
311 selectedRegion.t1(),
312 project.shared_from_this()
313 );
314
315 // Proceed to change the project. If this throws, the project will be
316 // rolled back by the top level handler.
317
319#if defined(USE_MIDI)
320 [](NoteTrack&) {
321 //if NoteTrack, it was cut, so do not clear anything
322
323 // PRL: But what if it was sync lock selected only, not selected?
324 },
325#endif
326 [&](auto &&fallthrough){ return [&](WaveTrack &wt) {
327 if (gPrefs->Read(wxT("/GUI/EnableCutLines"), (long)0))
328 wt.ClearAndAddCutLine(selectedRegion.t0(), selectedRegion.t1());
329 else
330 fallthrough();
331 }; },
332 [&](Track &n) {
333 if (n.SupportsBasicEditing())
334 n.Clear(selectedRegion.t0(), selectedRegion.t1());
335 }
336 );
337
338 selectedRegion.collapseToT0();
339
341 .PushState(XO("Cut to the clipboard"), XO("Cut"));
342
343 // Bug 1663
344 //mRuler->ClearPlayRegion();
345 ruler.DrawOverlays( true );
346}
347
348void OnDelete(const CommandContext &context)
349{
350 auto &project = context.project;
351 auto &tracks = TrackList::Get( project );
352 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
353
354 for (auto n : tracks) {
355 if (!n->SupportsBasicEditing())
356 continue;
358 n->Clear(selectedRegion.t0(), selectedRegion.t1());
359 }
360 }
361
362 double seconds = selectedRegion.duration();
363
364 selectedRegion.collapseToT0();
365
367 XO("Deleted %.2f seconds at t=%.2f")
368 .Format( seconds, selectedRegion.t0()),
369 XO("Delete"));
370}
371
372
373void OnCopy(const CommandContext &context)
374{
376
377 auto &project = context.project;
378 auto &tracks = TrackList::Get( project );
379 auto &trackPanel = TrackPanel::Get( project );
380 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
381
382 for (auto lt : tracks.Selected<LabelTrack>()) {
383 auto &view = LabelTrackView::Get( *lt );
384 if (view.CopySelectedText( context.project )) {
385 //trackPanel.Refresh(false);
386 return;
387 }
388 }
389 //Presumably, there might be not more than one track
390 //that expects text input
391 for (auto wt : tracks.Any<WaveTrack>()) {
392 auto& view = WaveChannelView::GetFirst(*wt);
393 if (view.CopySelectedText(context.project)) {
394 return;
395 }
396 }
397
398 auto &clipboard = Clipboard::Get();
399 clipboard.Clear();
400
401 auto pNewClipboard = TrackList::Create( nullptr );
402 auto &newClipboard = *pNewClipboard;
403
404 for (auto n : tracks.Selected()) {
405 if (n->SupportsBasicEditing()) {
406 auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1());
407 newClipboard.Add(dest);
408 }
409 }
410
411 // Survived possibility of exceptions. Commit changes to the clipboard now.
412 clipboard.Assign( std::move( newClipboard ),
413 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() );
414
415 //Make sure the menus/toolbar states get updated
416 trackPanel.Refresh(false);
417}
418
419std::pair<double, double> FindSelection(const CommandContext &context)
420{
421 double sel0 = 0.0, sel1 = 0.0;
422
423#if 0
424 // Use the overriding selection if any was given in the context
425 if (auto *pRegion = context.temporarySelection.pSelectedRegion) {
426 auto &selectedRegion = *pRegion;
427 sel0 = selectedRegion.t0();
428 sel1 = selectedRegion.t1();
429 }
430 else
431#endif
432 {
433 auto &selectedRegion = ViewInfo::Get(context.project).selectedRegion;
434 sel0 = selectedRegion.t0();
435 sel1 = selectedRegion.t1();
436 }
437
438 return { sel0, sel1 };
439}
440
441std::shared_ptr<const TrackList> FindSourceTracks(const CommandContext &context)
442{
443 auto &project = context.project;
444 auto &window = GetProjectFrame(project);
446 const auto &clipboard = Clipboard::Get();
447 auto discardTrimmed = false;
448 if (&context.project != &*clipboard.Project().lock()) {
449 const auto waveClipCopyPolicy = TracksBehaviorsAudioTrackPastePolicy.Read();
450 if (waveClipCopyPolicy == wxT("Ask") &&
451 HasHiddenData(clipboard.GetTracks()))
452 {
453 AudioPasteDialog audioPasteDialog(
454 &window,
455 EstimateCopyBytesCount(clipboard.GetTracks(), tracks)
456 );
457 const auto result = audioPasteDialog.ShowModal();
458 if(result == wxID_CANCEL)
459 return {};
460 discardTrimmed =
462 }
463 else if(waveClipCopyPolicy == wxT("Discard"))
464 discardTrimmed = true;
465 }
466
467 std::shared_ptr<const TrackList> srcTracks;
468 if(discardTrimmed)
469 srcTracks = DuplicateDiscardTrimmed(clipboard.GetTracks());
470 else
471 srcTracks = clipboard.GetTracks().shared_from_this();
472
473 return srcTracks;
474}
475
477 const CommandContext &context, const TrackList &srcTracks)
478{
479 auto &project = context.project;
481 auto &trackFactory = WaveTrackFactory::Get(project);
482 auto &pSampleBlockFactory = trackFactory.GetSampleBlockFactory();
483 return pSampleBlockFactory->Subscribe([
484 toCopy = EstimateCopiedBlocks(srcTracks, tracks),
485 nCopied = 0,
486 copyStartTime = std::chrono::system_clock::now(),
487 progressDialog = std::shared_ptr<BasicUI::ProgressDialog>()]
488 (const SampleBlockCreateMessage&) mutable {
489 using namespace std::chrono;
490 constexpr auto ProgressDialogShowDelay = milliseconds { 100 };
491 ++nCopied;
492 if(!progressDialog) {
493 if(duration_cast<milliseconds>(system_clock::now() - copyStartTime) >= ProgressDialogShowDelay)
494 progressDialog = BasicUI::MakeProgress(XO("Paste clip"), XO("Pasting clip contents, please wait"), 0);
495 }
496 else {
497 progressDialog->Poll(nCopied, toCopy);
498 }
499 });
500}
501
503bool FitsInto(const Track &src, const Track &dst)
504{
505 if (!src.SameKindAs(dst))
506 return false;
507 // Mono can "fit" into stereo, by duplication of the channel
508 // Otherwise non-wave tracks always have just one "channel"
509 // Future: Fit stereo into mono too, using mix-down
510 return src.NChannels() <= dst.NChannels();
511}
512
513// First, destination track; second, source
514using Correspondence = std::vector<std::pair<Track*, const Track*>>;
515
517 TrackList &dstTracks, const TrackList &srcTracks)
518{
519 Correspondence result;
520 auto dstRange = dstTracks.Selected();
521 if (dstRange.size() == 1)
522 // Special rule when only one track is selected interprets the user's
523 // intent as pasting into that track and following ones
524 dstRange = dstTracks.Any().StartingWith(*dstRange.begin());
525 auto srcRange = srcTracks.Any();
526 while (!(dstRange.empty() || srcRange.empty())) {
527 auto &dst = **dstRange.begin();
528 auto &src = **srcRange.begin();
529 if (!FitsInto(src, dst)) {
530 // Skip selected track of inappropriate type and try again
531 ++dstRange.first;
532 continue;
533 }
534 result.emplace_back(&dst, &src);
535 ++srcRange.first;
536 ++dstRange.first;
537 }
538
539 if (!srcRange.empty())
540 // Could not fit all source tracks into the selected tracks
541 return {};
542 else
543 return result;
544}
545
546void OnPaste(const CommandContext &context)
547{
548 if (wxTheClipboard->IsSupported(wxDF_FILENAME) && wxTheClipboard->Open())
549 {
550 wxFileDataObject data;
551 const auto hadData = wxTheClipboard->GetData(data);
552 wxTheClipboard->Close();
553 if (hadData)
554 {
555 ProjectFileManager::Get(context.project).Import(data.GetFilenames());
556 return;
557 }
558 }
559
560 auto &project = context.project;
561
562 // Handle text paste first.
563 if (DoPasteText(project))
564 return;
565
566 const auto &clipboard = Clipboard::Get();
567 if (clipboard.GetTracks().empty())
568 return;
569
570 const auto srcTracks = FindSourceTracks(context);
571 if (!srcTracks)
572 // user cancelled
573 return;
574
575 auto notificationScope = NotificationScope(context, *srcTracks);
576
578 // If nothing's selected, we just insert new tracks.
579 if (!tracks.Selected()) {
581 project, *srcTracks, clipboard.T0(), clipboard.T1());
582 return;
583 }
584
585 // Otherwise, paste into the selected tracks.
586 double t0, t1;
587 std::tie(t0, t1) = FindSelection(context);
588 auto newT1 = t0 + clipboard.Duration();
589 const auto isSyncLocked = SyncLockState::Get(project).IsSyncLocked();
590
591 Track *ff = nullptr;
592 bool bPastedSomething = false;
593
594 // Find tracks to paste in
595 auto correspondence = FindCorrespondence(tracks, *srcTracks);
596 if (correspondence.empty()) {
597 if (tracks.Selected().size() == 1)
599"The content you are trying to paste will span across more tracks than you "
600"currently have available. Add more tracks and try again.")
601 );
602 else
604"There are not enough tracks selected to accommodate your copied content. "
605"Select additional tracks and try again.")
606 );
607 return;
608 }
609 auto iPair = correspondence.begin();
610 const auto endPair = correspondence.cend();
611
612 // Outer loop by sync-lock groups
613 auto next = tracks.begin();
614 for (auto range = tracks.Any(); !range.empty();
615 // Skip to next sync lock group
616 range.first = next
617 ) {
618 if (iPair == endPair)
619 // Nothing more to paste
620 break;
621 auto group = SyncLock::Group(**range.first);
622 next = tracks.Find(*group.rbegin());
623 ++next;
624
625 if (!group.contains(iPair->first))
626 // Nothing to paste into this group
627 continue;
628
629 // Inner loop over the sync-lock group by tracks
630 for (auto member : group) {
631 if (iPair == endPair || member != iPair->first) {
632 if (isSyncLocked) {
633 // Track is not pasted into but must be adjusted
634 if (t1 != newT1 && t1 <= member->GetEndTime()) {
635 member->SyncLockAdjust(t1, newT1);
636 bPastedSomething = true;
637 }
638 }
639 }
640 else {
641 // Remember first pasted-into track, to focus it
642 if (!ff)
643 ff = member;
644 // Do the pasting!
645 const auto src = (iPair++)->second;
646 member->TypeSwitch(
647 [&](WaveTrack &wn){
648 bPastedSomething = true;
649 // For correct remapping of preserved split lines:
650 PasteTimeWarper warper{ t1, t0 + src->GetEndTime() };
651 const auto newClipOnPaste =
652 gPrefs->ReadBool(wxT("/GUI/PasteAsNewClips"), false);
653 // The new-clip-on-paste behavior means: not merging the
654 // clipboard data with data at the selection borders; not
655 // reproducing boundaries within the selected region in the
656 // new clip; preserving the data underneath by trimming
657 // (rather than deleting).
658 // The legacy behavior is the opposite.
659 const auto merge = newClipOnPaste ? false : true;
660 const auto preserveExistingBoundaries = newClipOnPaste ? false : true;
661 auto clearByTrimming = newClipOnPaste ? true : false;
662 if(src->NChannels() == 1 && wn.NChannels() == 2)
663 {
664 // When the source is mono, may paste its only channel
665 // repeatedly into a stereo track
666 const auto pastedTrack = std::static_pointer_cast<WaveTrack>(src->Duplicate());
667 pastedTrack->MonoToStereo();
668 wn.ClearAndPaste(
669 t0, t1, *pastedTrack,
670 preserveExistingBoundaries, merge, &warper,
671 clearByTrimming);
672 }
673 else
674 {
675 wn.ClearAndPaste(
676 t0, t1, *static_cast<const WaveTrack*>(src),
677 preserveExistingBoundaries, merge, &warper,
678 clearByTrimming);
679 }
680 },
681 [&](LabelTrack &ln){
682 // Per Bug 293, users expect labels to move on a paste into
683 // a label track.
684 ln.Clear(t0, t1);
685
686 ln.ShiftLabelsOnInsert( clipboard.Duration(), t0 );
687
688 bPastedSomething |= ln.PasteOver(t0, *src);
689 },
690 [&](Track &t){
691 bPastedSomething = true;
692 t.Clear(t0, t1);
693 t.Paste(t0, *src);
694 }
695 );
696 }
697 }
698 }
699
700 // TODO: What if we clicked past the end of the track?
701
702 if (bPastedSomething) {
703
704 if(!isSyncLocked && GetEditClipsCanMove())
705 {
706 //Special case when pasting without sync lock and
707 //"...move other clips" option is
708 //Also shift all intervals in all other selected tracks that
709 //starts after t0
710 const auto offset = srcTracks->GetEndTime() - (t1 - t0);
711 for(auto track : tracks.Selected<Track>())
712 {
713 const auto it = std::find_if(correspondence.begin(), correspondence.end(),
714 [=](auto& p) { return p.first == track; });
715 if(it != correspondence.end())
716 continue;
717
718 track->ShiftBy(t0, offset);
719 }
720 }
721
723 .setTimes( t0, t0 + clipboard.Duration() );
724
726 .PushState(XO("Pasted from the clipboard"), XO("Paste"));
727
728 if (ff) {
729 TrackFocus::Get(project).Set(ff);
731 }
732 }
733}
734
735void OnDuplicate(const CommandContext &context)
736{
737 auto &project = context.project;
739 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
740
741 // This iteration is unusual because we add to the list inside the loop
742 auto range = tracks.Selected();
743 auto last = *range.rbegin();
744 for (auto n : range) {
745 if (!n->SupportsBasicEditing())
746 continue;
747
748 // Make copies not for clipboard but for direct addition to the project
749 auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1(), false);
750 dest->MoveTo(std::max(selectedRegion.t0(), n->GetStartTime()));
751 tracks.Add(dest);
752
753 // This break is really needed, else we loop infinitely
754 if (n == last)
755 break;
756 }
757
759 .PushState(XO("Duplicated"), XO("Duplicate"));
760}
761
762void OnSplitCut(const CommandContext &context)
763{
764 auto &project = context.project;
766 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
767
768 auto &clipboard = Clipboard::Get();
769 clipboard.Clear();
770
771 auto pNewClipboard = TrackList::Create(nullptr);
772 auto &newClipboard = *pNewClipboard;
773
774 tracks.Selected().Visit(
775 [&](WaveTrack &n) {
776 auto track = n.SplitCut(selectedRegion.t0(), selectedRegion.t1());
777 newClipboard.Add(track);
778 },
779 [&](Track &n) {
780 if (n.SupportsBasicEditing()) {
781 auto dest = n.Copy(selectedRegion.t0(), selectedRegion.t1());
782 n.Silence(selectedRegion.t0(), selectedRegion.t1());
783 newClipboard.Add(dest);
784 }
785 }
786 );
787
788 // Survived possibility of exceptions. Commit changes to the clipboard now.
789 clipboard.Assign(std::move(newClipboard),
790 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this());
791
793 .PushState(XO("Split-cut to the clipboard"), XO("Split Cut"));
794}
795
796void OnSplitDelete(const CommandContext &context)
797{
798 auto &project = context.project;
800 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
801
802 tracks.Selected().Visit(
803 [&](WaveTrack &wt) {
804 wt.SplitDelete(selectedRegion.t0(), selectedRegion.t1());
805 },
806 [&](Track &n) {
807 if (n.SupportsBasicEditing())
808 n.Silence(selectedRegion.t0(), selectedRegion.t1());
809 }
810 );
811
813 XO("Split-deleted %.2f seconds at t=%.2f")
814 .Format(selectedRegion.duration(), selectedRegion.t0()),
815 XO("Split Delete"));
816}
817
818void OnSilence(const CommandContext &context)
819{
820 auto &project = context.project;
822 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
823
824 const auto selectedWaveTracks = tracks.Selected<WaveTrack>();
826 [&](const ProgressReporter& parent) {
828 selectedWaveTracks.begin(), selectedWaveTracks.end(),
829 [&](WaveTrack* n, const ProgressReporter& child) {
830 n->Silence(selectedRegion.t0(), selectedRegion.t1(), child);
831 },
832 parent);
833 });
834
836 XO("Silenced selected tracks for %.2f seconds at %.2f")
837 .Format(selectedRegion.duration(), selectedRegion.t0()),
838 /* i18n-hint: verb */
839 XC("Silence", "command"));
840}
841
842void OnTrim(const CommandContext &context)
843{
844 auto &project = context.project;
845 auto &tracks = TrackList::Get( project );
846 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
847
848 if (selectedRegion.isPoint())
849 return;
850
851 tracks.Selected().Visit( [&](WaveTrack &wt) {
852 //Hide the section before the left selector
853 wt.Trim(selectedRegion.t0(), selectedRegion.t1());
854 } );
855
857 XO("Trim selected audio tracks from %.2f seconds to %.2f seconds")
858 .Format( selectedRegion.t0(), selectedRegion.t1() ),
859 XO("Trim Audio"));
860}
861
862void OnSplit(const CommandContext &context)
863{
864 auto &project = context.project;
866 auto [sel0, sel1] = FindSelection(context);
867 if (auto *pTrack = context.temporarySelection.pTrack) {
868 if (auto pWaveTrack = dynamic_cast<WaveTrack*>(pTrack))
869 pWaveTrack->Split(sel0, sel1);
870 else
871 // Did nothing, don't push history
872 return;
873 }
874 else
875 for (auto wt : tracks.Selected<WaveTrack>())
876 wt->Split(sel0, sel1);
877
878 ProjectHistory::Get( project ).PushState(XO("Split"), XO("Split"));
879#if 0
880//ANSWER-ME: Do we need to keep this commented out OnSplit() code?
881// This whole section no longer used...
882 /*
883 * Previous (pre-multiclip) implementation of "Split" command
884 * This does work only when a range is selected!
885 *
886 TrackListIterator iter(tracks);
887
888 Track *n = iter.First();
889 Track *dest;
890
891 TrackList newTracks;
892
893 while (n) {
894 if (n->GetSelected()) {
895 double sel0 = selectedRegion.t0();
896 double sel1 = selectedRegion.t1();
897
898 dest = n->Copy(sel0, sel1);
899 dest->Init(*n);
900 dest->MoveTo(std::max(sel0, n->GetOffset()));
901
902 if (sel1 >= n->GetEndTime())
903 n->Clear(sel0, sel1);
904 else if (sel0 <= n->GetOffset()) {
905 n->Clear(sel0, sel1);
906 n->MoveTo(sel1);
907 } else
908 n->Silence(sel0, sel1);
909
910 newTracks.Add(dest);
911 }
912 n = iter.Next();
913 }
914
915 TrackListIterator nIter(&newTracks);
916 n = nIter.First();
917 while (n) {
918 tracks->Add(n);
919 n = nIter.Next();
920 }
921
922 PushState(XO("Split"), XO("Split"));
923 */
924#endif
925}
926
927void OnSplitNew(const CommandContext &context)
928{
929 auto &project = context.project;
931 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
932
933 // This iteration is unusual because we add to the list inside the loop
934 auto range = tracks.Selected();
935 auto last = *range.rbegin();
936 for (auto track : range) {
937 track->TypeSwitch(
938 [&](WaveTrack &wt) {
939 // Clips must be aligned to sample positions or the NEW clip will
940 // not fit in the gap where it came from
941 const double newt0 = wt.SnapToSample(selectedRegion.t0());
942 const double newt1 = wt.SnapToSample(selectedRegion.t1());
943 // Fix issue 2846 by calling copy with forClipboard = false.
944 // This avoids creating the blank placeholder clips
945 const auto dest = wt.Copy(newt0, newt1, false);
946 if (dest) {
947 // The copy function normally puts the clip at time 0
948 // This offset lines it up with the original track's timing
949 dest->MoveTo(newt0);
950 tracks.Add(dest);
951 }
952 wt.SplitDelete(newt0, newt1);
953 }
954#if 0
955 ,
956 // LL: For now, just skip all non-wave tracks since the other do not
957 // yet support proper splitting.
958 [&](Track &n) {
959 dest = n.Cut(viewInfo.selectedRegion.t0(),
960 viewInfo.selectedRegion.t1());
961 if (dest) {
962 dest->MoveTo(std::max(0, n.GetOffset()));
963 tracks.Add(dest);
964 }
965 }
966#endif
967 );
968 if (track == last)
969 break;
970 }
971
973 .PushState(XO("Split to new track"), XO("Split New"));
974}
975
976void OnJoin(const CommandContext &context)
977{
978 auto &project = context.project;
980 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
981 const auto selectedTracks = tracks.Selected<WaveTrack>();
983 [&](const ProgressReporter& reportProgress) {
984 using namespace BasicUI;
986 selectedTracks.begin(), selectedTracks.end(),
987 [&](WaveTrack* wt, const ProgressReporter& childProgress) {
988 wt->Join(
989 selectedRegion.t0(), selectedRegion.t1(), childProgress);
990 },
991 reportProgress);
992 });
993
995 XO("Joined %.2f seconds at t=%.2f")
996 .Format(selectedRegion.duration(), selectedRegion.t0()),
997 XO("Join"));
998}
999
1000void OnDisjoin(const CommandContext &context)
1001{
1002 auto &project = context.project;
1003 auto &tracks = TrackList::Get(project);
1004 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
1005
1006 for (auto wt : tracks.Selected<WaveTrack>())
1007 wt->Disjoin(selectedRegion.t0(), selectedRegion.t1());
1008
1010 XO("Detached %.2f seconds at t=%.2f")
1011 .Format(selectedRegion.duration(), selectedRegion.t0()),
1012 XO("Detach"));
1013}
1014
1015void OnPreferences(const CommandContext &context)
1016{
1017 auto &project = context.project;
1018
1019 GlobalPrefsDialog dialog(&GetProjectFrame(project) /* parent */, &project );
1020
1021 if (!dialog.ShowModal()) {
1022 // Canceled
1023 return;
1024 }
1025
1026 // LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
1027 // rebuilding the menus while the PrefsDialog is still in the modal
1028 // state.
1029 for (auto p : AllProjects{}) {
1031// TODO: The comment below suggests this workaround is obsolete.
1032#if defined(__WXGTK__)
1033 // Workaround for:
1034 //
1035 // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
1036 //
1037 // This workaround should be removed when Audacity updates to wxWidgets
1038 // 3.x which has a fix.
1039 auto &window = GetProjectFrame( *p );
1040 wxRect r = window.GetRect();
1041 window.SetSize(wxSize(1,1));
1042 window.SetSize(r.GetSize());
1043#endif
1044 }
1045}
1046
1047// Legacy functions, not used as of version 2.3.0
1048
1049#if 0
1050void OnPasteOver(const CommandContext &context)
1051{
1052 auto &project = context.project;
1053 auto &selectedRegion = project.GetViewInfo().selectedRegion;
1054
1055 if((AudacityProject::msClipT1 - AudacityProject::msClipT0) > 0.0)
1056 {
1057 selectedRegion.setT1(
1058 selectedRegion.t0() +
1059 (AudacityProject::msClipT1 - AudacityProject::msClipT0));
1060 // MJS: pointless, given what we do in OnPaste?
1061 }
1062 OnPaste(context);
1063
1064 return;
1065}
1066#endif
1067
1068// Menu definitions
1069
1072 [](const AudacityProject &project){
1073 auto range = TrackList::Get(project).Any<const LabelTrack>()
1074 + [&](const LabelTrack *pTrack){
1075 return LabelTrackView::Get( *pTrack ).IsTextSelected(
1076 // unhappy const_cast because track focus might be set
1077 const_cast<AudacityProject&>(project)
1078 );
1079 };
1080 if ( !range.empty() )
1081 return true;
1082
1083 if (
1085 &&
1087 )
1088 return true;
1089
1090 return false;
1091 },
1093}; return flag; }
1094
1097 [](const AudacityProject &project)
1098 {
1100 return false;
1101
1102 const auto &viewInfo = ViewInfo::Get(project);
1103 if(viewInfo.selectedRegion.isPoint())
1104 return false;
1105
1106 const auto selectedTracks = TrackList::Get(project).Selected<const WaveTrack>();
1107 for (const auto track : selectedTracks)
1108 {
1109 const auto selectedClips =
1111 viewInfo.selectedRegion.t0(), viewInfo.selectedRegion.t1());
1112 if(selectedClips.size() > 1)
1113 return true;
1114 }
1115 return false;
1116 },
1118}; return flag; }
1119
1120using namespace MenuRegistry;
1122{
1123 static const auto NotBusyTimeAndTracksFlags =
1125
1126 // The default shortcut key for Redo is different on different platforms.
1127 static constexpr auto redoKey =
1128#ifdef __WXMSW__
1129 wxT("Ctrl+Y")
1130#else
1131 wxT("Ctrl+Shift+Z")
1132#endif
1133 ;
1134
1135 // The default shortcut key for Preferences is different on different
1136 // platforms.
1137 static constexpr auto prefKey =
1138#ifdef __WXMAC__
1139 wxT("Ctrl+,")
1140#else
1141 wxT("Ctrl+P")
1142#endif
1143 ;
1144
1145 static auto menu = std::shared_ptr{
1146 Menu( wxT("Edit"), XXO("&Edit"),
1147 Section( "UndoRedo",
1148 Command( wxT("Undo"), XXO("&Undo"), OnUndo,
1149 AudioIONotBusyFlag() | UndoAvailableFlag(), wxT("Ctrl+Z") ),
1150
1151 Command( wxT("Redo"), XXO("&Redo"), OnRedo,
1152 AudioIONotBusyFlag() | RedoAvailableFlag(), redoKey ),
1153
1154 MenuCreator::Special( wxT("UndoItemsUpdateStep"),
1155 [](AudacityProject &project, wxMenu&) {
1156 // Change names in the CommandManager as a side-effect
1158 })
1159 ),
1160
1161 Section( "Basic",
1162 // Basic Edit commands
1163 /* i18n-hint: (verb)*/
1164 Command( wxT("Cut"), XXO("Cu&t"), OnCut,
1166 wxT("Ctrl+X") ),
1167 Command( wxT("Delete"), XXO("&Delete"), OnDelete,
1169 wxT("Ctrl+K") ),
1170 /* i18n-hint: (verb)*/
1171 Command( wxT("Copy"), XXO("&Copy"), OnCopy,
1172 AudioIONotBusyFlag() | CutCopyAvailableFlag(), wxT("Ctrl+C") ),
1173 /* i18n-hint: (verb)*/
1174 Command( wxT("Paste"), XXO("&Paste"), OnPaste,
1175 AudioIONotBusyFlag(), wxT("Ctrl+V") ),
1176 /* i18n-hint: (verb)*/
1177 Command( wxT("Duplicate"), XXO("Duplic&ate"), OnDuplicate,
1178 NotBusyTimeAndTracksFlags, wxT("Ctrl+D") ),
1179
1180 Section( "",
1181 Menu( wxT("RemoveSpecial"), XXO("R&emove Special"),
1182 Section( "",
1183 /* i18n-hint: (verb) Do a special kind of cut*/
1184 Command( wxT("SplitCut"), XXO("Spl&it Cut"), OnSplitCut,
1185 NotBusyTimeAndTracksFlags,
1186 Options{ wxT("Ctrl+Alt+X") } ),
1187 /* i18n-hint: (verb) Do a special kind of DELETE*/
1188 Command( wxT("SplitDelete"), XXO("Split D&elete"), OnSplitDelete,
1189 NotBusyTimeAndTracksFlags,
1190 Options{ wxT("Ctrl+Alt+K") } )
1191 ),
1192
1193 Section( "",
1194 /* i18n-hint: (verb)*/
1195 Command( wxT("Silence"), XXO("Silence Audi&o"), OnSilence,
1197 wxT("Ctrl+L") ),
1198 /* i18n-hint: (verb)*/
1199 Command( wxT("Trim"), XXO("Tri&m Audio"), OnTrim,
1201 Options{ wxT("Ctrl+T") } )
1202 )
1203 )
1204 )
1205 ),
1206
1207
1208 Section( "Other",
1210
1211 Menu( wxT("Clip"), XXO("Audi&o Clips"),
1212 Section( "",
1213 /* i18n-hint: (verb) It's an item on a menu. */
1214 Command( wxT("Split"), XXO("Sp&lit"), OnSplit,
1216 Options{ wxT("Ctrl+I") } ),
1217 Command( wxT("SplitNew"), XXO("Split Ne&w"), OnSplitNew,
1219 Options{ wxT("Ctrl+Alt+I") } )
1220 ),
1221
1222 Section( "",
1223 /* i18n-hint: (verb)*/
1224 Command( wxT("Join"), XXO("&Join"), OnJoin,
1225 JoinClipsAvailableFlag(), wxT("Ctrl+J") ),
1226 Command( wxT("Disjoin"), XXO("Detac&h at Silences"), OnDisjoin,
1227 NotBusyTimeAndTracksFlags, wxT("Ctrl+Alt+J") )
1228 )
1229 )
1230
1231 ),
1232
1233 // Note that on Mac, the Preferences menu item is specially handled in
1234 // CommandManager (assigned a special wxWidgets id) so that it does
1235 // not appear in the Edit menu but instead under Audacity, consistent with
1236 // MacOS conventions.
1237 Section( "Preferences",
1238 Command( wxT("Preferences"), XXO("Pre&ferences"), OnPreferences,
1239 AudioIONotBusyFlag(), prefKey )
1240 )
1241
1242 ) };
1243 return menu;
1244}
1245
1247
1249{
1250 static const auto flags =
1252 static auto menu = std::shared_ptr{
1253 Menu( wxT("Edit"), XXO("&Edit"),
1254 Command( wxT("DeleteKey"), XXO("&Delete Key"), OnDelete,
1255 (flags | NoAutoSelect()),
1256 wxT("Backspace") ),
1257 Command( wxT("DeleteKey2"), XXO("Delete Key&2"), OnDelete,
1258 (flags | NoAutoSelect()),
1259 wxT("Delete") )
1260 ) };
1261 return menu;
1262}
1263
1268 (flagsRqd & NoAutoSelect()).none() )
1270};
1271
1273 []{ return TracksExistFlag(); },
1274 []{ return EditableTracksSelectedFlag(); },
1276 selectAll
1277}};
1278
1279// Including time tracks.
1281 []{ return TracksExistFlag(); },
1282 []{ return AnyTracksSelectedFlag(); },
1284 selectAll
1285}};
1286
1288 []{ return WaveTracksExistFlag(); },
1291 selectAll
1292}};
1293
1294// Also enable select for the noise reduction case.
1296 []{ return WaveTracksExistFlag(); },
1299 selectAll
1300}};
1301
1303 wxT("Optional/Extra/Part1")
1304};
1305
1306}
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.
bool GetEditClipsCanMove()
Definition: WaveTrack.cpp:3408
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:98
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:326
void Clear(double t0, double t1) override
Definition: NoteTrack.cpp:403
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Create new tracks and don't modify this track.
Definition: NoteTrack.cpp:356
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:3376
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1526
void Silence(double t0, double t1, ProgressReporter reportProgress) override
Definition: WaveTrack.cpp:2000
void Trim(double t0, double t1)
Definition: WaveTrack.cpp:980
Holder SplitCut(double t0, double t1)
Definition: WaveTrack.cpp:966
size_t NChannels() const override
A constant property.
Definition: WaveTrack.cpp:530
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:1219
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Create new tracks and don't modify this track.
Definition: WaveTrack.cpp:1097
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:441
Correspondence FindCorrespondence(TrackList &dstTracks, const TrackList &srcTracks)
Definition: EditMenus.cpp:516
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:1000
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:976
RegisteredMenuItemEnabler selectWaveTracks
Definition: EditMenus.cpp:1287
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:503
RegisteredMenuItemEnabler selectTracks
Definition: EditMenus.cpp:1272
void OnDelete(const CommandContext &context)
Definition: EditMenus.cpp:348
auto NotificationScope(const CommandContext &context, const TrackList &srcTracks)
Definition: EditMenus.cpp:476
void OnPaste(const CommandContext &context)
Definition: EditMenus.cpp:546
const ReservedCommandFlag & CutCopyAvailableFlag()
Definition: EditMenus.cpp:1071
void OnSplit(const CommandContext &context)
Definition: EditMenus.cpp:862
std::pair< double, double > FindSelection(const CommandContext &context)
Definition: EditMenus.cpp:419
void OnSilence(const CommandContext &context)
Definition: EditMenus.cpp:818
RegisteredMenuItemEnabler selectWaveTracks2
Definition: EditMenus.cpp:1295
const ReservedCommandFlag & JoinClipsAvailableFlag()
Definition: EditMenus.cpp:1096
void OnTrim(const CommandContext &context)
Definition: EditMenus.cpp:842
void OnSplitDelete(const CommandContext &context)
Definition: EditMenus.cpp:796
std::vector< std::pair< Track *, const Track * > > Correspondence
Definition: EditMenus.cpp:514
void OnCopy(const CommandContext &context)
Definition: EditMenus.cpp:373
void OnUndo(const CommandContext &context)
Definition: EditMenus.cpp:182
void OnSplitCut(const CommandContext &context)
Definition: EditMenus.cpp:762
void OnPreferences(const CommandContext &context)
Definition: EditMenus.cpp:1015
void OnDuplicate(const CommandContext &context)
Definition: EditMenus.cpp:735
RegisteredMenuItemEnabler selectAnyTracks
Definition: EditMenus.cpp:1280
bool HasHiddenData(const TrackList &trackList)
Definition: EditMenus.cpp:171
void OnSplitNew(const CommandContext &context)
Definition: EditMenus.cpp:927
void OnCut(const CommandContext &context)
Definition: EditMenus.cpp:253
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