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