Audacity  3.0.3
EditMenus.cpp
Go to the documentation of this file.
1 
2 #include "../AdornedRulerPanel.h"
3 #include "../Clipboard.h"
4 #include "../CommonCommandFlags.h"
5 #include "../LabelTrack.h"
6 #include "../Menus.h"
7 #include "../NoteTrack.h"
8 #include "Prefs.h"
9 #include "Project.h"
10 #include "../ProjectHistory.h"
11 #include "ProjectRate.h"
12 #include "../ProjectSettings.h"
13 #include "../ProjectWindow.h"
14 #include "../ProjectWindows.h"
15 #include "../SelectUtilities.h"
16 #include "../TrackPanel.h"
17 #include "../TrackPanelAx.h"
18 #include "../UndoManager.h"
19 #include "ViewInfo.h"
20 #include "../WaveTrack.h"
21 #include "../commands/CommandContext.h"
22 #include "../commands/CommandManager.h"
23 #include "../commands/ScreenshotCommand.h"
24 #include "../effects/TimeWarper.h"
25 #include "../export/Export.h"
26 #include "../prefs/PrefsDialog.h"
27 #include "../tracks/labeltrack/ui/LabelTrackView.h"
28 #include "../widgets/AudacityMessageBox.h"
29 
30 // private helper classes and functions
31 namespace {
33  (const Track *n, const Track::Holder &dest, TrackList &list)
34 {
35  Track::FinishCopy( n, dest.get() );
36  if (dest)
37  list.Add( dest );
38 }
39 
40 // Handle text paste (into active label), if any. Return true if did paste.
41 // (This was formerly the first part of overly-long OnPaste.)
43 {
44  auto &tracks = TrackList::Get( project );
45  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
46  auto &window = ProjectWindow::Get( project );
47 
48  for (auto pLabelTrack : tracks.Any<LabelTrack>())
49  {
50  // Does this track have an active label?
51  if (LabelTrackView::Get( *pLabelTrack ).GetTextEditIndex(project) != -1) {
52 
53  // Yes, so try pasting into it
54  auto &view = LabelTrackView::Get( *pLabelTrack );
55  if (view.PasteSelectedText( project, selectedRegion.t0(),
56  selectedRegion.t1() ))
57  {
58  ProjectHistory::Get( project )
59  .PushState(XO("Pasted text from the clipboard"), XO("Paste"));
60 
61  // Make sure caret is in view
62  int x;
63  if (view.CalcCursorX( project, &x )) {
64  window.ScrollIntoView(x);
65  }
66 
67  return true;
68  }
69  }
70  }
71  return false;
72 }
73 
74 // Return true if nothing selected, regardless of paste result.
75 // If nothing was selected, create and paste into NEW tracks.
76 // (This was formerly the second part of overly-long OnPaste.)
78 {
79  auto &tracks = TrackList::Get( project );
80  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
81  auto &viewInfo = ViewInfo::Get( project );
82  auto &window = ProjectWindow::Get( project );
83 
84  // First check whether anything's selected.
85  if (tracks.Selected())
86  return false;
87  else
88  {
89  const auto &clipboard = Clipboard::Get();
90  auto clipTrackRange = clipboard.GetTracks().Any< const Track >();
91  if (clipTrackRange.empty())
92  return true; // nothing to paste
93 
94  Track* pFirstNewTrack = NULL;
95  for (auto pClip : clipTrackRange) {
96  auto pNewTrack = pClip->PasteInto( project );
97  bool newTrack = (pNewTrack.use_count() == 1);
98  wxASSERT(pClip);
99 
100  if (!pFirstNewTrack)
101  pFirstNewTrack = pNewTrack.get();
102 
103  pNewTrack->SetSelected(true);
104  if (newTrack)
105  FinishCopy(pClip, pNewTrack, tracks);
106  else
107  Track::FinishCopy(pClip, pNewTrack.get());
108  }
109 
110  // Select some pasted samples, which is probably impossible to get right
111  // with various project and track sample rates.
112  // So do it at the sample rate of the project
113  double projRate = ProjectRate::Get( project ).GetRate();
114  double quantT0 = QUANTIZED_TIME(clipboard.T0(), projRate);
115  double quantT1 = QUANTIZED_TIME(clipboard.T1(), projRate);
116  selectedRegion.setTimes(
117  0.0, // anywhere else and this should be
118  // half a sample earlier
119  quantT1 - quantT0);
120 
121  ProjectHistory::Get( project )
122  .PushState(XO("Pasted from the clipboard"), XO("Paste"));
123 
124  if (pFirstNewTrack) {
125  TrackFocus::Get(project).Set(pFirstNewTrack);
126  pFirstNewTrack->EnsureVisible();
127  }
128 
129  return true;
130  }
131 }
132 
133 }
134 
135 namespace EditActions {
136 
137 // Menu handler functions
138 
140 void OnUndo(const CommandContext &context)
141 {
142  auto &project = context.project;
143  auto &tracks = TrackList::Get( project );
144  auto &trackPanel = TrackPanel::Get( project );
145  auto &undoManager = UndoManager::Get( project );
146  auto &window = ProjectWindow::Get( project );
147 
148  if (!ProjectHistory::Get( project ).UndoAvailable()) {
149  AudacityMessageBox( XO("Nothing to undo") );
150  return;
151  }
152 
153  // can't undo while dragging
154  if (trackPanel.IsMouseCaptured()) {
155  return;
156  }
157 
158  undoManager.Undo(
159  [&]( const UndoStackElem &elem ){
160  ProjectHistory::Get( project ).PopState( elem.state ); } );
161 
162  auto t = *tracks.Selected().begin();
163  if (!t)
164  t = *tracks.Any().begin();
165  if (t) {
166  TrackFocus::Get(project).Set(t);
167  t->EnsureVisible();
168  }
169 }
170 
171 void OnRedo(const CommandContext &context)
172 {
173  auto &project = context.project;
174  auto &tracks = TrackList::Get( project );
175  auto &trackPanel = TrackPanel::Get( project );
176  auto &undoManager = UndoManager::Get( project );
177  auto &window = ProjectWindow::Get( project );
178 
179  if (!ProjectHistory::Get( project ).RedoAvailable()) {
180  AudacityMessageBox( XO("Nothing to redo") );
181  return;
182  }
183  // Can't redo whilst dragging
184  if (trackPanel.IsMouseCaptured()) {
185  return;
186  }
187 
188  undoManager.Redo(
189  [&]( const UndoStackElem &elem ){
190  ProjectHistory::Get( project ).PopState( elem.state ); } );
191 
192  auto t = *tracks.Selected().begin();
193  if (!t)
194  t = *tracks.Any().begin();
195  if (t) {
196  TrackFocus::Get(project).Set(t);
197  t->EnsureVisible();
198  }
199 }
200 
201 void OnCut(const CommandContext &context)
202 {
203  auto &project = context.project;
204  auto &tracks = TrackList::Get( project );
205  auto &trackPanel = TrackPanel::Get( project );
206  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
207  auto &ruler = AdornedRulerPanel::Get( project );
208  auto &window = ProjectWindow::Get( project );
209 
210  // This doesn't handle cutting labels, it handles
211  // cutting the _text_ inside of labels, i.e. if you're
212  // in the middle of editing the label text and select "Cut".
213 
214  for (auto lt : tracks.Selected< LabelTrack >()) {
215  auto &view = LabelTrackView::Get( *lt );
216  if (view.CutSelectedText( context.project )) {
217  trackPanel.Refresh(false);
218  return;
219  }
220  }
221 
222  auto &clipboard = Clipboard::Get();
223  clipboard.Clear();
224 
225  auto pNewClipboard = TrackList::Create( nullptr );
226  auto &newClipboard = *pNewClipboard;
227 
228  tracks.Selected().Visit(
229 #if defined(USE_MIDI)
230  [&](NoteTrack *n) {
231  // Since portsmf has a built-in cut operator, we use that instead
232  auto dest = n->Cut(selectedRegion.t0(),
233  selectedRegion.t1());
234  FinishCopy(n, dest, newClipboard);
235  },
236 #endif
237  [&](Track *n) {
238  if (n->SupportsBasicEditing()) {
239  auto dest = n->Copy(selectedRegion.t0(),
240  selectedRegion.t1());
241  FinishCopy(n, dest, newClipboard);
242  }
243  }
244  );
245 
246  // Survived possibility of exceptions. Commit changes to the clipboard now.
247  clipboard.Assign(
248  std::move( newClipboard ),
249  selectedRegion.t0(),
250  selectedRegion.t1(),
251  project.shared_from_this()
252  );
253 
254  // Proceed to change the project. If this throws, the project will be
255  // rolled back by the top level handler.
256 
257  (tracks.Any() + &Track::IsSelectedOrSyncLockSelected).Visit(
258 #if defined(USE_MIDI)
259  [](NoteTrack*) {
260  //if NoteTrack, it was cut, so do not clear anything
261 
262  // PRL: But what if it was sync lock selected only, not selected?
263  },
264 #endif
265  [&](WaveTrack *wt, const Track::Fallthrough &fallthrough) {
266  if (gPrefs->Read(wxT("/GUI/EnableCutLines"), (long)0)) {
267  wt->ClearAndAddCutLine(
268  selectedRegion.t0(),
269  selectedRegion.t1());
270  }
271  else
272  fallthrough();
273  },
274  [&](Track *n) {
275  if (n->SupportsBasicEditing())
276  n->Clear(selectedRegion.t0(), selectedRegion.t1());
277  }
278  );
279 
280  selectedRegion.collapseToT0();
281 
282  ProjectHistory::Get( project )
283  .PushState(XO("Cut to the clipboard"), XO("Cut"));
284 
285  // Bug 1663
286  //mRuler->ClearPlayRegion();
287  ruler.DrawOverlays( true );
288 }
289 
290 void OnDelete(const CommandContext &context)
291 {
292  auto &project = context.project;
293  auto &tracks = TrackList::Get( project );
294  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
295  auto &window = ProjectWindow::Get( project );
296 
297  for (auto n : tracks.Any()) {
298  if (!n->SupportsBasicEditing())
299  continue;
300  if (n->GetSelected() || n->IsSyncLockSelected()) {
301  n->Clear(selectedRegion.t0(), selectedRegion.t1());
302  }
303  }
304 
305  double seconds = selectedRegion.duration();
306 
307  selectedRegion.collapseToT0();
308 
309  ProjectHistory::Get( project ).PushState(
310  XO("Deleted %.2f seconds at t=%.2f")
311  .Format( seconds, selectedRegion.t0()),
312  XO("Delete"));
313 }
314 
315 
316 void OnCopy(const CommandContext &context)
317 {
318  auto &project = context.project;
319  auto &tracks = TrackList::Get( project );
320  auto &trackPanel = TrackPanel::Get( project );
321  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
322 
323  for (auto lt : tracks.Selected< LabelTrack >()) {
324  auto &view = LabelTrackView::Get( *lt );
325  if (view.CopySelectedText( context.project )) {
326  //trackPanel.Refresh(false);
327  return;
328  }
329  }
330 
331  auto &clipboard = Clipboard::Get();
332  clipboard.Clear();
333 
334  auto pNewClipboard = TrackList::Create( nullptr );
335  auto &newClipboard = *pNewClipboard;
336 
337  for (auto n : tracks.Selected()) {
338  if (n->SupportsBasicEditing()) {
339  auto dest = n->Copy(selectedRegion.t0(),
340  selectedRegion.t1());
341  FinishCopy(n, dest, newClipboard);
342  }
343  }
344 
345  // Survived possibility of exceptions. Commit changes to the clipboard now.
346  clipboard.Assign( std::move( newClipboard ),
347  selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() );
348 
349  //Make sure the menus/toolbar states get updated
350  trackPanel.Refresh(false);
351 }
352 
353 std::pair<double, double> FindSelection(const CommandContext &context)
354 {
355  double sel0 = 0.0, sel1 = 0.0;
356 
357 #if 0
358  // Use the overriding selection if any was given in the context
359  if (auto *pRegion = context.temporarySelection.pSelectedRegion) {
360  auto &selectedRegion = *pRegion;
361  sel0 = selectedRegion.t0();
362  sel1 = selectedRegion.t1();
363  }
364  else
365 #endif
366  {
367  auto &selectedRegion = ViewInfo::Get(context.project).selectedRegion;
368  sel0 = selectedRegion.t0();
369  sel1 = selectedRegion.t1();
370  }
371 
372  return { sel0, sel1 };
373 }
374 
375 void OnPaste(const CommandContext &context)
376 {
377  auto &project = context.project;
378  auto &tracks = TrackList::Get( project );
379  auto &trackFactory = WaveTrackFactory::Get( project );
380  auto &pSampleBlockFactory = trackFactory.GetSampleBlockFactory();
381  const auto &settings = ProjectSettings::Get( project );
382  auto &window = ProjectWindow::Get( project );
383 
384  auto isSyncLocked = settings.IsSyncLocked();
385 
386  // Handle text paste (into active label) first.
387  if (DoPasteText(project))
388  return;
389 
390  // If nothing's selected, we just insert NEW tracks.
391  if (DoPasteNothingSelected(project))
392  return;
393 
394  const auto &clipboard = Clipboard::Get();
395  auto clipTrackRange = clipboard.GetTracks().Any< const Track >();
396  if (clipTrackRange.empty())
397  return;
398 
399  // Otherwise, paste into the selected tracks.
400  double t0, t1;
401  std::tie(t0, t1) = FindSelection(context);
402 
403  auto pN = tracks.Any().begin();
404 
405  Track *ff = NULL;
406  const Track *lastClipBeforeMismatch = NULL;
407  const Track *mismatchedClip = NULL;
408  const Track *prevClip = NULL;
409 
410  bool bAdvanceClipboard = true;
411  bool bPastedSomething = false;
412 
413  auto pasteWaveTrack = [&](WaveTrack *dst, const Track *src){
414  bPastedSomething = true;
415  // For correct remapping of preserved split lines:
416  PasteTimeWarper warper{ t1, t0 + src->GetEndTime() };
417  dst->ClearAndPaste(t0, t1, src, true, true, &warper);
418  };
419 
420  auto pC = clipTrackRange.begin();
421  size_t nnChannels=0, ncChannels=0;
422  while (*pN && *pC) {
423  auto n = *pN;
424  auto c = *pC;
425  if (n->GetSelected()) {
426  bAdvanceClipboard = true;
427  if (mismatchedClip)
428  c = mismatchedClip;
429  if (!c->SameKindAs(*n)) {
430  if (!mismatchedClip) {
431  lastClipBeforeMismatch = prevClip;
432  mismatchedClip = c;
433  }
434  bAdvanceClipboard = false;
435  c = lastClipBeforeMismatch;
436 
437 
438  // If the types still don't match...
439  while (c && !c->SameKindAs(*n)) {
440  prevClip = c;
441  c = * ++ pC;
442  }
443  }
444 
445  // Handle case where the first track in clipboard
446  // is of different type than the first selected track
447  if (!c) {
448  c = mismatchedClip;
449  while (n && (!c->SameKindAs(*n) || !n->GetSelected()))
450  {
451  // Must perform sync-lock adjustment before incrementing n
452  if (n->IsSyncLockSelected()) {
453  auto newT1 = t0 + clipboard.Duration();
454  if (t1 != newT1 && t1 <= n->GetEndTime()) {
455  n->SyncLockAdjust(t1, newT1);
456  bPastedSomething = true;
457  }
458  }
459  n = * ++ pN;
460  }
461  if (!n)
462  c = NULL;
463  }
464 
465  // The last possible case for cross-type pastes: triggered when we try
466  // to paste 1+ tracks from one type into 1+ tracks of another type. If
467  // there's a mix of types, this shouldn't run.
468  if (!c)
469  // Throw, so that any previous changes to the project in this loop
470  // are discarded.
473  XO("Pasting one type of track into another is not allowed."),
474  XO("Warning"),
475  "Error:_Copying_or_Pasting"
476  };
477 
478  // We should need this check only each time we visit the leading
479  // channel
480  if ( n->IsLeader() ) {
481  wxASSERT( c->IsLeader() ); // the iteration logic should ensure this
482 
483  auto cChannels = TrackList::Channels(c);
484  ncChannels = cChannels.size();
485  auto nChannels = TrackList::Channels(n);
486  nnChannels = nChannels.size();
487 
488  // When trying to copy from stereo to mono track, show error and
489  // exit
490  // TODO: Automatically offer user to mix down to mono (unfortunately
491  // this is not easy to implement
492  if (ncChannels > nnChannels)
493  {
494  if (ncChannels > 2) {
495  // TODO: more-than-two-channels-message
496  // Re-word the error message
497  }
498  // else
499 
500  // Throw, so that any previous changes to the project in this
501  // loop are discarded.
504  XO("Copying stereo audio into a mono track is not allowed."),
505  XO("Warning"),
506  "Error:_Copying_or_Pasting"
507  };
508  }
509  }
510 
511  if (!ff)
512  ff = n;
513 
514  wxASSERT( n && c && n->SameKindAs(*c) );
515  n->TypeSwitch(
516  [&](WaveTrack *wn){
517  pasteWaveTrack(wn, static_cast<const WaveTrack *>(c));
518  },
519  [&](LabelTrack *ln){
520  // Per Bug 293, users expect labels to move on a paste into
521  // a label track.
522  ln->Clear(t0, t1);
523 
524  ln->ShiftLabelsOnInsert( clipboard.Duration(), t0 );
525 
526  bPastedSomething |= ln->PasteOver(t0, c);
527  },
528  [&](Track *){
529  bPastedSomething = true;
530  n->Clear(t0, t1);
531  n->Paste(t0, c);
532  }
533  );
534 
535  --nnChannels;
536  --ncChannels;
537 
538  // When copying from mono to stereo track, paste the wave form
539  // to both channels
540  // TODO: more-than-two-channels
541  // This will replicate the last pasted channel as many times as needed
542  while (nnChannels > 0 && ncChannels == 0)
543  {
544  n = * ++ pN;
545  --nnChannels;
546 
547  n->TypeSwitch(
548  [&](WaveTrack *wn){
549  pasteWaveTrack(wn, c);
550  },
551  [&](Track *){
552  n->Clear(t0, t1);
553  bPastedSomething = true;
554  n->Paste(t0, c);
555  }
556  );
557  }
558 
559  if (bAdvanceClipboard) {
560  prevClip = c;
561  c = * ++ pC;
562  }
563  } // if (n->GetSelected())
564  else if (n->IsSyncLockSelected())
565  {
566  auto newT1 = t0 + clipboard.Duration();
567  if (t1 != newT1 && t1 <= n->GetEndTime()) {
568  n->SyncLockAdjust(t1, newT1);
569  bPastedSomething = true;
570  }
571  }
572  ++pN;
573  }
574 
575  // This block handles the cases where our clipboard is smaller
576  // than the amount of selected destination tracks. We take the
577  // last wave track, and paste that one into the remaining
578  // selected tracks.
579  if ( *pN && ! *pC )
580  {
581  const auto wc =
582  *clipboard.GetTracks().Any< const WaveTrack >().rbegin();
583 
584  tracks.Any().StartingWith(*pN).Visit(
585  [&](WaveTrack *wt, const Track::Fallthrough &fallthrough) {
586  if (!wt->GetSelected())
587  return fallthrough();
588 
589  if (wc) {
590  pasteWaveTrack(wt, wc);
591  }
592  else {
593  auto tmp = wt->EmptyCopy( pSampleBlockFactory );
594  tmp->InsertSilence( 0.0,
595  // MJS: Is this correct?
596  clipboard.Duration() );
597  tmp->Flush();
598 
599  pasteWaveTrack(wt, tmp.get());
600  }
601  },
602  [&](LabelTrack *lt, const Track::Fallthrough &fallthrough) {
603  if (!lt->GetSelected() && !lt->IsSyncLockSelected())
604  return fallthrough();
605 
606  lt->Clear(t0, t1);
607 
608  // As above, only shift labels if sync-lock is on.
609  if (isSyncLocked)
611  clipboard.Duration(), t0);
612  },
613  [&](Track *n) {
614  if (n->IsSyncLockSelected())
615  n->SyncLockAdjust(t1, t0 + clipboard.Duration() );
616  }
617  );
618  }
619 
620  // TODO: What if we clicked past the end of the track?
621 
622  if (bPastedSomething)
623  {
625  .setTimes( t0, t0 + clipboard.Duration() );
626 
627  ProjectHistory::Get( project )
628  .PushState(XO("Pasted from the clipboard"), XO("Paste"));
629 
630  if (ff) {
631  TrackFocus::Get(project).Set(ff);
632  ff->EnsureVisible();
633  ff->LinkConsistencyCheck();
634  }
635  }
636 }
637 
638 void OnDuplicate(const CommandContext &context)
639 {
640  auto &project = context.project;
641  auto &tracks = TrackList::Get( project );
642  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
643  auto &window = ProjectWindow::Get( project );
644 
645  // This iteration is unusual because we add to the list inside the loop
646  auto range = tracks.Selected();
647  auto last = *range.rbegin();
648  for (auto n : range) {
649  if (!n->SupportsBasicEditing())
650  continue;
651 
652  // Make copies not for clipboard but for direct addition to the project
653  auto dest = n->Copy(selectedRegion.t0(),
654  selectedRegion.t1(), false);
655  dest->Init(*n);
656  dest->SetOffset(wxMax(selectedRegion.t0(), n->GetOffset()));
657  tracks.Add( dest );
658 
659  // This break is really needed, else we loop infinitely
660  if (n == last)
661  break;
662  }
663 
664  ProjectHistory::Get( project )
665  .PushState(XO("Duplicated"), XO("Duplicate"));
666 }
667 
668 void OnSplitCut(const CommandContext &context)
669 {
670  auto &project = context.project;
671  auto &tracks = TrackList::Get( project );
672  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
673  auto &window = ProjectWindow::Get( project );
674 
675  auto &clipboard = Clipboard::Get();
676  clipboard.Clear();
677 
678  auto pNewClipboard = TrackList::Create( nullptr );
679  auto &newClipboard = *pNewClipboard;
680 
681  Track::Holder dest;
682 
683  tracks.Selected().Visit(
684  [&](WaveTrack *n) {
685  dest = n->SplitCut(
686  selectedRegion.t0(),
687  selectedRegion.t1());
688  if (dest)
689  FinishCopy(n, dest, newClipboard);
690  },
691  [&](Track *n) {
692  if (n->SupportsBasicEditing()) {
693  dest = n->Copy(selectedRegion.t0(),
694  selectedRegion.t1());
695  n->Silence(selectedRegion.t0(),
696  selectedRegion.t1());
697  if (dest)
698  FinishCopy(n, dest, newClipboard);
699  }
700  }
701  );
702 
703  // Survived possibility of exceptions. Commit changes to the clipboard now.
704  clipboard.Assign( std::move( newClipboard ),
705  selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() );
706 
707  ProjectHistory::Get( project )
708  .PushState(XO("Split-cut to the clipboard"), XO("Split Cut"));
709 }
710 
711 void OnSplitDelete(const CommandContext &context)
712 {
713  auto &project = context.project;
714  auto &tracks = TrackList::Get( project );
715  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
716  auto &window = ProjectWindow::Get( project );
717 
718  tracks.Selected().Visit(
719  [&](WaveTrack *wt) {
720  wt->SplitDelete(selectedRegion.t0(),
721  selectedRegion.t1());
722  },
723  [&](Track *n) {
724  if (n->SupportsBasicEditing())
725  n->Silence(selectedRegion.t0(),
726  selectedRegion.t1());
727  }
728  );
729 
730  ProjectHistory::Get( project ).PushState(
731  XO("Split-deleted %.2f seconds at t=%.2f")
732  .Format( selectedRegion.duration(), selectedRegion.t0() ),
733  XO("Split Delete"));
734 }
735 
736 void OnSilence(const CommandContext &context)
737 {
738  auto &project = context.project;
739  auto &tracks = TrackList::Get( project );
740  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
741 
742  for ( auto n : tracks.Selected< WaveTrack >() )
743  n->Silence(selectedRegion.t0(), selectedRegion.t1());
744 
745  ProjectHistory::Get( project ).PushState(
746  XO("Silenced selected tracks for %.2f seconds at %.2f")
747  .Format( selectedRegion.duration(), selectedRegion.t0() ),
748  /* i18n-hint: verb */
749  XC("Silence", "command"));
750 }
751 
752 void OnTrim(const CommandContext &context)
753 {
754  auto &project = context.project;
755  auto &tracks = TrackList::Get( project );
756  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
757  auto &window = ProjectWindow::Get( project );
758 
759  if (selectedRegion.isPoint())
760  return;
761 
762  tracks.Selected().Visit(
763  [&](WaveTrack *wt) {
764  //Hide the section before the left selector
765  wt->Trim(selectedRegion.t0(),
766  selectedRegion.t1());
767  }
768  );
769 
770  ProjectHistory::Get( project ).PushState(
771  XO("Trim selected audio tracks from %.2f seconds to %.2f seconds")
772  .Format( selectedRegion.t0(), selectedRegion.t1() ),
773  XO("Trim Audio"));
774 }
775 
776 void OnSplit(const CommandContext &context)
777 {
778  auto &project = context.project;
779  auto &tracks = TrackList::Get( project );
780 
781  auto [sel0, sel1] = FindSelection(context);
782 
783  if (auto *pTrack = context.temporarySelection.pTrack) {
784  if (auto pWaveTrack = dynamic_cast<WaveTrack*>(pTrack))
785  for (auto pChannel : TrackList::Channels(pWaveTrack))
786  pChannel->Split( sel0, sel1 );
787  else
788  // Did nothing, don't push history
789  return;
790  }
791  else {
792  for (auto wt : tracks.Selected< WaveTrack >())
793  wt->Split( sel0, sel1 );
794  }
795 
796  ProjectHistory::Get( project ).PushState(XO("Split"), XO("Split"));
797 #if 0
798 //ANSWER-ME: Do we need to keep this commented out OnSplit() code?
799 // This whole section no longer used...
800  /*
801  * Previous (pre-multiclip) implementation of "Split" command
802  * This does work only when a range is selected!
803  *
804  TrackListIterator iter(tracks);
805 
806  Track *n = iter.First();
807  Track *dest;
808 
809  TrackList newTracks;
810 
811  while (n) {
812  if (n->GetSelected()) {
813  double sel0 = selectedRegion.t0();
814  double sel1 = selectedRegion.t1();
815 
816  dest = n->Copy(sel0, sel1);
817  dest->Init(*n);
818  dest->SetOffset(wxMax(sel0, n->GetOffset()));
819 
820  if (sel1 >= n->GetEndTime())
821  n->Clear(sel0, sel1);
822  else if (sel0 <= n->GetOffset()) {
823  n->Clear(sel0, sel1);
824  n->SetOffset(sel1);
825  } else
826  n->Silence(sel0, sel1);
827 
828  newTracks.Add(dest);
829  }
830  n = iter.Next();
831  }
832 
833  TrackListIterator nIter(&newTracks);
834  n = nIter.First();
835  while (n) {
836  tracks->Add(n);
837  n = nIter.Next();
838  }
839 
840  PushState(XO("Split"), XO("Split"));
841  */
842 #endif
843 }
844 
845 void OnSplitNew(const CommandContext &context)
846 {
847  auto &project = context.project;
848  auto &tracks = TrackList::Get( project );
849  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
850  auto &window = ProjectWindow::Get( project );
851 
852  Track::Holder dest;
853 
854  // This iteration is unusual because we add to the list inside the loop
855  auto range = tracks.Selected();
856  auto last = *range.rbegin();
857  for (auto track : range) {
858  track->TypeSwitch(
859  [&](WaveTrack *wt) {
860  // Clips must be aligned to sample positions or the NEW clip will
861  // not fit in the gap where it came from
862  double offset = wt->GetOffset();
863  offset = wt->LongSamplesToTime(wt->TimeToLongSamples(offset));
864  double newt0 = wt->LongSamplesToTime(wt->TimeToLongSamples(
865  selectedRegion.t0()));
866  double newt1 = wt->LongSamplesToTime(wt->TimeToLongSamples(
867  selectedRegion.t1()));
868  dest = wt->SplitCut(newt0, newt1);
869  if (dest) {
870  dest->SetOffset(wxMax(newt0, offset));
871  FinishCopy(wt, dest, tracks);
872  }
873  }
874 #if 0
875  ,
876  // LL: For now, just skip all non-wave tracks since the other do not
877  // yet support proper splitting.
878  [&](Track *n) {
879  dest = n->Cut(viewInfo.selectedRegion.t0(),
880  viewInfo.selectedRegion.t1());
881  if (dest) {
882  dest->SetOffset(wxMax(0, n->GetOffset()));
883  FinishCopy(n, dest, *tracks);
884  }
885  }
886 #endif
887  );
888  if (track == last)
889  break;
890  }
891 
892  ProjectHistory::Get( project )
893  .PushState(XO("Split to new track"), XO("Split New"));
894 }
895 
896 void OnJoin(const CommandContext &context)
897 {
898  auto &project = context.project;
899  auto &tracks = TrackList::Get( project );
900  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
901  auto &window = ProjectWindow::Get( project );
902 
903  for (auto wt : tracks.Selected< WaveTrack >())
904  wt->Join(selectedRegion.t0(),
905  selectedRegion.t1());
906 
907  ProjectHistory::Get( project ).PushState(
908  XO("Joined %.2f seconds at t=%.2f")
909  .Format( selectedRegion.duration(), selectedRegion.t0() ),
910  XO("Join"));
911 }
912 
913 void OnDisjoin(const CommandContext &context)
914 {
915  auto &project = context.project;
916  auto &tracks = TrackList::Get( project );
917  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
918  auto &window = ProjectWindow::Get( project );
919 
920  for (auto wt : tracks.Selected< WaveTrack >())
921  wt->Disjoin(selectedRegion.t0(),
922  selectedRegion.t1());
923 
924  ProjectHistory::Get( project ).PushState(
925  XO("Detached %.2f seconds at t=%.2f")
926  .Format( selectedRegion.duration(), selectedRegion.t0() ),
927  XO("Detach"));
928 }
929 
930 void OnEditMetadata(const CommandContext &context)
931 {
932  auto &project = context.project;
933  (void)Exporter::DoEditMetadata( project,
934  XO("Edit Metadata Tags"), XO("Metadata Tags"), true);
935 }
936 
937 void OnPreferences(const CommandContext &context)
938 {
939  auto &project = context.project;
940 
941  GlobalPrefsDialog dialog(&GetProjectFrame( project ) /* parent */, &project );
942 
943  if( ScreenshotCommand::MayCapture( &dialog ) )
944  return;
945 
946  if (!dialog.ShowModal()) {
947  // Canceled
948  return;
949  }
950 
951  // LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
952  // rebuilding the menus while the PrefsDialog is still in the modal
953  // state.
954  for (auto p : AllProjects{}) {
956 // TODO: The comment below suggests this workaround is obsolete.
957 #if defined(__WXGTK__)
958  // Workaround for:
959  //
960  // http://bugzilla.audacityteam.org/show_bug.cgi?id=458
961  //
962  // This workaround should be removed when Audacity updates to wxWidgets
963  // 3.x which has a fix.
964  auto &window = GetProjectFrame( *p );
965  wxRect r = window.GetRect();
966  window.SetSize(wxSize(1,1));
967  window.SetSize(r.GetSize());
968 #endif
969  }
970 }
971 
972 // Legacy functions, not used as of version 2.3.0
973 
974 #if 0
975 void OnPasteOver(const CommandContext &context)
976 {
977  auto &project = context.project;
978  auto &selectedRegion = project.GetViewInfo().selectedRegion;
979 
980  if((AudacityProject::msClipT1 - AudacityProject::msClipT0) > 0.0)
981  {
982  selectedRegion.setT1(
983  selectedRegion.t0() +
984  (AudacityProject::msClipT1 - AudacityProject::msClipT0));
985  // MJS: pointless, given what we do in OnPaste?
986  }
987  OnPaste(context);
988 
989  return;
990 }
991 #endif
992 
993 }; // struct Handler
994 
995 } // namespace
996 
998  // Handler is not stateful. Doesn't need a factory registered with
999  // AudacityProject.
1000  static EditActions::Handler instance;
1001  return instance;
1002 };
1003 
1004 // Menu definitions
1005 
1006 #define FN(X) (& EditActions::Handler :: X)
1007 
1008 static const ReservedCommandFlag
1010  [](const AudacityProject &project){
1011  auto range = TrackList::Get( project ).Any<const LabelTrack>()
1012  + [&](const LabelTrack *pTrack){
1013  return LabelTrackView::Get( *pTrack ).IsTextSelected(
1014  // unhappy const_cast because track focus might be set
1015  const_cast<AudacityProject&>(project)
1016  );
1017  };
1018  if ( !range.empty() )
1019  return true;
1020 
1021  if (
1022  TimeSelectedPred( project )
1023  &&
1024  EditableTracksSelectedPred( project )
1025  )
1026  return true;
1027 
1028  return false;
1029  },
1030  cutCopyOptions()
1031 }; return flag; }
1032 
1033 namespace {
1034 using namespace MenuTable;
1036 {
1038 
1039  static const auto NotBusyTimeAndTracksFlags =
1041 
1042  // The default shortcut key for Redo is different on different platforms.
1043  static constexpr auto redoKey =
1044 #ifdef __WXMSW__
1045  wxT("Ctrl+Y")
1046 #else
1047  wxT("Ctrl+Shift+Z")
1048 #endif
1049  ;
1050 
1051  // The default shortcut key for Preferences is different on different
1052  // platforms.
1053  static constexpr auto prefKey =
1054 #ifdef __WXMAC__
1055  wxT("Ctrl+,")
1056 #else
1057  wxT("Ctrl+P")
1058 #endif
1059  ;
1060 
1061  static BaseItemSharedPtr menu{
1063  Menu( wxT("Edit"), XXO("&Edit"),
1064  Section( "UndoRedo",
1065  Command( wxT("Undo"), XXO("&Undo"), FN(OnUndo),
1066  AudioIONotBusyFlag() | UndoAvailableFlag(), wxT("Ctrl+Z") ),
1067 
1068  Command( wxT("Redo"), XXO("&Redo"), FN(OnRedo),
1069  AudioIONotBusyFlag() | RedoAvailableFlag(), redoKey ),
1070 
1071  Special( wxT("UndoItemsUpdateStep"),
1072  [](AudacityProject &project, wxMenu&) {
1073  // Change names in the CommandManager as a side-effect
1075  })
1076  ),
1077 
1078  Section( "Basic",
1079  // Basic Edit commands
1080  /* i18n-hint: (verb)*/
1081  Command( wxT("Cut"), XXO("Cu&t"), FN(OnCut),
1083  wxT("Ctrl+X") ),
1084  Command( wxT("Delete"), XXO("&Delete"), FN(OnDelete),
1086  wxT("Ctrl+K") ),
1087  /* i18n-hint: (verb)*/
1088  Command( wxT("Copy"), XXO("&Copy"), FN(OnCopy),
1089  AudioIONotBusyFlag() | CutCopyAvailableFlag(), wxT("Ctrl+C") ),
1090  /* i18n-hint: (verb)*/
1091  Command( wxT("Paste"), XXO("&Paste"), FN(OnPaste),
1092  AudioIONotBusyFlag(), wxT("Ctrl+V") ),
1093  /* i18n-hint: (verb)*/
1094  Command( wxT("Duplicate"), XXO("Duplic&ate"), FN(OnDuplicate),
1095  NotBusyTimeAndTracksFlags, wxT("Ctrl+D") ),
1096 
1097  Section( "",
1098  Menu( wxT("RemoveSpecial"), XXO("R&emove Special"),
1099  Section( "",
1100  /* i18n-hint: (verb) Do a special kind of cut*/
1101  Command( wxT("SplitCut"), XXO("Spl&it Cut"), FN(OnSplitCut),
1102  NotBusyTimeAndTracksFlags,
1103  Options{ wxT("Ctrl+Alt+X") } ),
1104  /* i18n-hint: (verb) Do a special kind of DELETE*/
1105  Command( wxT("SplitDelete"), XXO("Split D&elete"), FN(OnSplitDelete),
1106  NotBusyTimeAndTracksFlags,
1107  Options{ wxT("Ctrl+Alt+K") } )
1108  ),
1109 
1110  Section( "",
1111  /* i18n-hint: (verb)*/
1112  Command( wxT("Silence"), XXO("Silence Audi&o"), FN(OnSilence),
1114  wxT("Ctrl+L") ),
1115  /* i18n-hint: (verb)*/
1116  Command( wxT("Trim"), XXO("Tri&m Audio"), FN(OnTrim),
1118  Options{ wxT("Ctrl+T") } )
1119  )
1120  )
1121  )
1122  ),
1123 
1124 
1125  Section( "Other",
1127 
1128  Menu( wxT("Clip"), XXO("Clip B&oundaries"),
1129  Section( "",
1130  /* i18n-hint: (verb) It's an item on a menu. */
1131  Command( wxT("Split"), XXO("Sp&lit"), FN(OnSplit),
1133  Options{ wxT("Ctrl+I") } ),
1134  Command( wxT("SplitNew"), XXO("Split Ne&w"), FN(OnSplitNew),
1136  Options{ wxT("Ctrl+Alt+I") } )
1137  ),
1138 
1139  Section( "",
1140  /* i18n-hint: (verb)*/
1141  Command( wxT("Join"), XXO("&Join"), FN(OnJoin),
1142  NotBusyTimeAndTracksFlags, wxT("Ctrl+J") ),
1143  Command( wxT("Disjoin"), XXO("Detac&h at Silences"), FN(OnDisjoin),
1144  NotBusyTimeAndTracksFlags, wxT("Ctrl+Alt+J") )
1145  )
1146  ),
1147 
1149 
1150  Command( wxT("EditMetaData"), XXO("&Metadata..."), FN(OnEditMetadata),
1151  AudioIONotBusyFlag() )
1152 
1154 
1155  ),
1156 
1157  // Note that on Mac, the Preferences menu item is specially handled in
1158  // CommandManager (assigned a special wxWidgets id) so that it does
1159  // not appear in the Edit menu but instead under Audacity, consistent with
1160  // MacOS conventions.
1161  Section( "Preferences",
1162  Command( wxT("Preferences"), XXO("Pre&ferences..."), FN(OnPreferences),
1163  AudioIONotBusyFlag(), prefKey )
1164  )
1165 
1166  ) ) };
1167  return menu;
1168 }
1169 
1171  wxT(""),
1172  Shared( EditMenu() )
1173 };
1174 
1176 {
1178  static const auto flags =
1180  static BaseItemSharedPtr menu{
1182  Menu( wxT("Edit"), XXO("&Edit"),
1183  Command( wxT("DeleteKey"), XXO("&Delete Key"), FN(OnDelete),
1184  (flags | NoAutoSelect()),
1185  wxT("Backspace") ),
1186  Command( wxT("DeleteKey2"), XXO("Delete Key&2"), FN(OnDelete),
1187  (flags | NoAutoSelect()),
1188  wxT("Delete") )
1189  ) ) };
1190  return menu;
1191 }
1192 
1193 auto canSelectAll = [](const AudacityProject &project){
1194  return MenuManager::Get( project ).mWhatIfNoSelection != 0; };
1195 auto selectAll = []( AudacityProject &project, CommandFlag flagsRqd ){
1196  if ( MenuManager::Get( project ).mWhatIfNoSelection == 1 &&
1197  (flagsRqd & NoAutoSelect()).none() )
1199 };
1200 
1202  []{ return TracksExistFlag(); },
1203  []{ return EditableTracksSelectedFlag(); },
1204  canSelectAll,
1205  selectAll
1206 }};
1207 
1208 // Including time tracks.
1210  []{ return TracksExistFlag(); },
1211  []{ return AnyTracksSelectedFlag(); },
1212  canSelectAll,
1213  selectAll
1214 }};
1215 
1217  []{ return WaveTracksExistFlag(); },
1219  canSelectAll,
1220  selectAll
1221 }};
1222 
1223 // Also enable select for the noise reduction case.
1225  []{ return WaveTracksExistFlag(); },
1227  canSelectAll,
1228  selectAll
1229 }};
1230 
1232  wxT("Optional/Extra/Part1"),
1233  Shared( ExtraEditMenu() )
1234 };
1235 
1236 }
1237 #undef FN
PrefsDialog::ShowModal
int ShowModal() override
Definition: PrefsDialog.cpp:596
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
WaveTrackFactory::Get
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:2890
TemporarySelection::pTrack
Track * pTrack
Definition: CommandContext.h:31
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
FN
#define FN(X)
Definition: EditMenus.cpp:1006
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
EditActions::Handler::OnCut
void OnCut(const CommandContext &context)
Definition: EditMenus.cpp:201
MenuTable::FinderScope
Definition: CommandManager.h:485
EditActions::Handler::OnSplitCut
void OnSplitCut(const CommandContext &context)
Definition: EditMenus.cpp:668
flag
static std::once_flag flag
Definition: WaveformView.cpp:1119
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
NoAutoSelect
const ReservedCommandFlag & NoAutoSelect()
Definition: CommonCommandFlags.cpp:312
Project.h
anonymous_namespace{EditMenus.cpp}::selectTracks
RegisteredMenuItemEnabler selectTracks
Definition: EditMenus.cpp:1201
Track::SupportsBasicEditing
virtual bool SupportsBasicEditing() const
Whether this track type implements cut-copy-paste; by default, true.
Definition: Track.cpp:1239
Track::EnsureVisible
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:100
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:127
EditActions::Handler
Definition: EditMenus.cpp:139
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
Format
Abstract base class used in importing a file.
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1280
WaveTracksExistFlag
const ReservedCommandFlag & WaveTracksExistFlag()
Definition: CommonCommandFlags.cpp:273
WaveTrack::ClearAndAddCutLine
void ClearAndAddCutLine(double t0, double t1)
Definition: WaveTrack.cpp:758
EditActions::Handler::OnCopy
void OnCopy(const CommandContext &context)
Definition: EditMenus.cpp:316
ReservedCommandFlag
Definition: CommandFlag.h:89
Registry::Shared
std::unique_ptr< SharedItem > Shared(const BaseItemSharedPtr &ptr)
Definition: Registry.h:93
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
TrackList::Add
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1503
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
WaveTrack::GetOffset
double GetOffset() const override
Definition: WaveTrack.cpp:237
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
CutCopyAvailableFlag
static const ReservedCommandFlag & CutCopyAvailableFlag()
Definition: EditMenus.cpp:1009
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
MenuTable::AttachedItem
Definition: CommandManager.h:708
SelectUtilities::DoSelectAllAudio
void DoSelectAllAudio(AudacityProject &project)
Definition: SelectUtilities.cpp:144
EditActions::Handler::OnDelete
void OnDelete(const CommandContext &context)
Definition: EditMenus.cpp:290
EditableTracksSelectedFlag
const ReservedCommandFlag & EditableTracksSelectedFlag()
Definition: CommonCommandFlags.cpp:180
EditActions::Handler::OnPreferences
void OnPreferences(const CommandContext &context)
Definition: EditMenus.cpp:937
WaveTrack::ClearAndPaste
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:848
EditActions::Handler::OnUndo
void OnUndo(const CommandContext &context)
Definition: EditMenus.cpp:140
WaveTrack::Copy
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:680
anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler
Ruler & ruler()
Definition: TimeTrackVRulerControls.cpp:34
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:254
WaveTracksSelectedFlag
const ReservedCommandFlag & WaveTracksSelectedFlag()
Definition: CommonCommandFlags.cpp:164
WaveTrack::SplitDelete
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1012
EditActions::Handler::OnTrim
void OnTrim(const CommandContext &context)
Definition: EditMenus.cpp:752
LabelTrack::ShiftLabelsOnInsert
void ShiftLabelsOnInsert(double length, double pt)
Definition: LabelTrack.cpp:201
EditActions::Handler::OnDuplicate
void OnDuplicate(const CommandContext &context)
Definition: EditMenus.cpp:638
NotifyingSelectedRegion::setTimes
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:62
EditActions::Handler::OnPaste
void OnPaste(const CommandContext &context)
Definition: EditMenus.cpp:375
anonymous_namespace{EditMenus.cpp}::selectAnyTracks
RegisteredMenuItemEnabler selectAnyTracks
Definition: EditMenus.cpp:1209
cutCopyOptions
const CommandFlagOptions & cutCopyOptions()
Definition: CommonCommandFlags.cpp:73
Track::SetSelected
virtual void SetSelected(bool s)
Definition: Track.cpp:90
AdornedRulerPanel::Get
static AdornedRulerPanel & Get(AudacityProject &project)
Definition: AdornedRulerPanel.cpp:899
LabelTrack::Clear
void Clear(double t0, double t1) override
Definition: LabelTrack.cpp:152
NoteTrack::Clear
void Clear(double t0, double t1) override
Definition: NoteTrack.cpp:527
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
anonymous_namespace{EditMenus.cpp}::DoPasteText
bool DoPasteText(AudacityProject &project)
Definition: EditMenus.cpp:42
XXO
#define XXO(s)
Definition: Internat.h:44
anonymous_namespace{EditMenus.cpp}::selectWaveTracks
RegisteredMenuItemEnabler selectWaveTracks
Definition: EditMenus.cpp:1216
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
Track::Holder
std::shared_ptr< Track > Holder
Definition: Track.h:336
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1862
NoteTrack::Copy
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: NoteTrack.cpp:480
WaveTrack::SplitCut
Track::Holder SplitCut(double t0, double t1)
Definition: WaveTrack.cpp:606
Registry::BaseItemSharedPtr
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:72
ProjectHistory::PopState
void PopState(const UndoState &state, bool doAutosave=true)
Definition: ProjectHistory.cpp:143
none
@ none
Definition: Dither.h:20
AnyTracksSelectedFlag
const ReservedCommandFlag & AnyTracksSelectedFlag()
Definition: CommonCommandFlags.cpp:188
anonymous_namespace{EditMenus.cpp}::ExtraEditMenu
BaseItemSharedPtr ExtraEditMenu()
Definition: EditMenus.cpp:1175
MenuCreator::RebuildMenuBar
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
UndoAvailableFlag
const ReservedCommandFlag & UndoAvailableFlag()
Definition: CommonCommandFlags.cpp:241
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:504
MenuManager::mWhatIfNoSelection
int mWhatIfNoSelection
Definition: Menus.h:122
UndoStackElem::state
UndoState state
Definition: UndoManager.h:110
findCommandHandler
static CommandHandlerObject & findCommandHandler(AudacityProject &)
Definition: EditMenus.cpp:997
LabelTrackView::Get
static LabelTrackView & Get(LabelTrack &)
Definition: LabelTrackView.cpp:162
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:755
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
EditActions::Handler::FindSelection
std::pair< double, double > FindSelection(const CommandContext &context)
Definition: EditMenus.cpp:353
EditActions
Definition: EditMenus.cpp:135
TracksExistFlag
const ReservedCommandFlag & TracksExistFlag()
Definition: CommonCommandFlags.cpp:173
EditableTracksSelectedPred
bool EditableTracksSelectedPred(const AudacityProject &project)
Definition: CommonCommandFlags.cpp:45
ViewInfo.h
ScreenshotCommand::MayCapture
static bool MayCapture(wxDialog *pDlg)
Definition: ScreenshotCommand.cpp:345
Track::GetSelected
bool GetSelected() const
Definition: Track.h:431
EditActions::Handler::OnJoin
void OnJoin(const CommandContext &context)
Definition: EditMenus.cpp:896
NoteTrack::Cut
Track::Holder Cut(double t0, double t1) override
Definition: NoteTrack.cpp:450
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
Clipboard::Get
static Clipboard & Get()
Definition: Clipboard.cpp:29
EditActions::Handler::OnRedo
void OnRedo(const CommandContext &context)
Definition: EditMenus.cpp:171
RegisteredMenuItemEnabler
Definition: CommandFlag.h:119
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1857
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
anonymous_namespace{EditMenus.cpp}::EditMenu
BaseItemSharedPtr EditMenu()
Definition: EditMenus.cpp:1035
LabelTrackView::GetTextEditIndex
int GetTextEditIndex(AudacityProject &project) const
Definition: LabelTrackView.cpp:1003
UndoManager::Get
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:57
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
TimeSelectedFlag
const ReservedCommandFlag & TimeSelectedFlag()
Definition: CommonCommandFlags.cpp:159
GetProjectFrame
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 ...
Definition: ProjectWindows.cpp:72
anonymous_namespace{EditMenus.cpp}::FinishCopy
void FinishCopy(const Track *n, const Track::Holder &dest, TrackList &list)
Definition: EditMenus.cpp:33
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
AllProjects
Definition: Project.h:35
EditActions::Handler::OnSplitDelete
void OnSplitDelete(const CommandContext &context)
Definition: EditMenus.cpp:711
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition: CommandFunctors.h:28
MenuTable::Menu
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
Definition: CommandManager.h:623
ProjectRate.h
an object holding per-project preferred sample rate
TrackList::Create
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
Definition: Track.cpp:523
anonymous_namespace{EditMenus.cpp}::canSelectAll
auto canSelectAll
Definition: EditMenus.cpp:1193
Track::FinishCopy
static void FinishCopy(const Track *n, Track *dest)
Definition: Track.cpp:388
GlobalPrefsDialog
Definition: PrefsDialog.h:81
anonymous_namespace{EditMenus.cpp}::selectWaveTracks2
RegisteredMenuItemEnabler selectWaveTracks2
Definition: EditMenus.cpp:1224
RedoAvailableFlag
const ReservedCommandFlag & RedoAvailableFlag()
Definition: CommonCommandFlags.cpp:247
WaveTrack::Silence
void Silence(double t0, double t1) override
Definition: WaveTrack.cpp:1422
MenuTable::Section
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
Definition: CommandManager.h:611
Track::IsSelectedOrSyncLockSelected
bool IsSelectedOrSyncLockSelected() const
Definition: Track.cpp:376
EditActions::Handler::OnEditMetadata
void OnEditMetadata(const CommandContext &context)
Definition: EditMenus.cpp:930
TimeSelectedPred
bool TimeSelectedPred(const AudacityProject &project)
Definition: CommonCommandFlags.cpp:66
EditActions::Handler::OnDisjoin
void OnDisjoin(const CommandContext &context)
Definition: EditMenus.cpp:913
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:47
Prefs.h
TemporarySelection::pSelectedRegion
SelectedRegion * pSelectedRegion
Definition: CommandContext.h:30
MenuTable
Definition: CommandManager.h:416
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
EditActions::Handler::OnSilence
void OnSilence(const CommandContext &context)
Definition: EditMenus.cpp:736
NoiseReductionTimeSelectedFlag
const ReservedCommandFlag & NoiseReductionTimeSelectedFlag()
Definition: CommonCommandFlags.cpp:154
MenuManager::ModifyUndoMenuItems
static void ModifyUndoMenuItems(AudacityProject &project)
Definition: Menus.cpp:444
ExceptionType::BadUserAction
@ BadUserAction
Indicates that the user performed an action that is not allowed.
QUANTIZED_TIME
#define QUANTIZED_TIME(time, rate)
Definition: MemoryX.h:628
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
MenuTable::Special
std::unique_ptr< SpecialItem > Special(const Identifier &name, const SpecialItem::Appender &fn)
Definition: CommandManager.h:700
anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected
bool DoPasteNothingSelected(AudacityProject &project)
Definition: EditMenus.cpp:77
SimpleMessageBoxException
A MessageBoxException that shows a given, unvarying string.
Definition: AudacityException.h:95
Track::PasteInto
virtual Holder PasteInto(AudacityProject &) const =0
Find or create the destination track for a paste, maybe in a different project.
PasteTimeWarper
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
Exporter::DoEditMetadata
static bool DoEditMetadata(AudacityProject &project, const TranslatableString &title, const TranslatableString &shortUndoDescription, bool force)
Definition: Export.cpp:399
EditActions::Handler::OnSplit
void OnSplit(const CommandContext &context)
Definition: EditMenus.cpp:776
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
anonymous_namespace{Menus.cpp}::Options
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:527
WaveTrack::Trim
void Trim(double t0, double t1)
Definition: WaveTrack.cpp:639
anonymous_namespace{EditMenus.cpp}::selectAll
auto selectAll
Definition: EditMenus.cpp:1195
anonymous_namespace{EditMenus.cpp}::sAttachment1
AttachedItem sAttachment1
Definition: EditMenus.cpp:1170
Track::SyncLockAdjust
virtual void SyncLockAdjust(double oldT1, double newT1)
Definition: Track.cpp:293
LabelTrackView::IsTextSelected
bool IsTextSelected(AudacityProject &project) const
Definition: LabelTrackView.cpp:1055
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:67
EditActions::Handler::OnSplitNew
void OnSplitNew(const CommandContext &context)
Definition: EditMenus.cpp:845
UndoStackElem
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:97
CommandContext::temporarySelection
TemporarySelection temporarySelection
Definition: CommandContext.h:71
anonymous_namespace{EditMenus.cpp}::sAttachment2
AttachedItem sAttachment2
Definition: EditMenus.cpp:1231