MCPcopy Create free account
hub / github.com/audacity/audacity / OnCutLabels

Function OnCutLabels

src/menus/LabelMenus.cpp:422–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422void OnCutLabels(const CommandContext &context)
423{
424 auto &project = context.project;
425 auto &tracks = TrackList::Get(project);
426 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
427
428 if (selectedRegion.isPoint())
429 return;
430
431 // Because of grouping the copy may need to operate on different tracks than
432 // the clear, so we do these actions separately.
433 auto copyfunc = [&](Track &track, double t0, double t1) {
434 Track::Holder result;
435 track.TypeSwitch( [&](WaveTrack &wt) { result = wt.Copy(t0, t1); } );
436 return result;
437 };
438 EditClipboardByLabel(project, tracks, selectedRegion, copyfunc);
439
440 bool enableCutlines = gPrefs->ReadBool(wxT( "/GUI/EnableCutLines"), false);
441 auto editfunc = [&](Track &track, double t0, double t1) {
442 track.TypeSwitch(
443 [&](WaveTrack &t) {
444 if (enableCutlines)
445 t.ClearAndAddCutLine(t0, t1);
446 else
447 t.Clear(t0, t1);
448 },
449 [&](Track &t) {
450 t.Clear(t0, t1);
451 }
452 );
453 };
454 EditByLabel(project, tracks, selectedRegion, editfunc);
455
456 selectedRegion.collapseToT0();
457
458 ProjectHistory::Get(project).PushState(
459 /* i18n-hint: (verb) past tense. Audacity has just cut the labeled audio
460 regions.*/
461 XO("Cut labeled audio regions to clipboard"),
462 /* i18n-hint: (verb)*/
463 XO("Cut Labeled Audio"));
464}
465
466void OnDeleteLabels(const CommandContext &context)
467{

Callers

nothing calls this directly

Calls 9

GetFunction · 0.85
EditClipboardByLabelFunction · 0.85
EditByLabelFunction · 0.85
ReadBoolMethod · 0.80
collapseToT0Method · 0.80
CopyMethod · 0.45
ClearAndAddCutLineMethod · 0.45
ClearMethod · 0.45
PushStateMethod · 0.45

Tested by

no test coverage detected