Audacity 3.2.0
Public Member Functions | List of all members
LabelEditActions::Handler Struct Reference
Inheritance diagram for LabelEditActions::Handler:
[legend]
Collaboration diagram for LabelEditActions::Handler:
[legend]

Public Member Functions

void OnEditLabels (const CommandContext &context)
 
void OnAddLabel (const CommandContext &context)
 
void OnAddLabelPlaying (const CommandContext &context)
 
void OnPasteNewLabel (const CommandContext &context)
 
void OnToggleTypeToCreateLabel (const CommandContext &WXUNUSED(context))
 
void OnCutLabels (const CommandContext &context)
 
void OnDeleteLabels (const CommandContext &context)
 
void OnSplitCutLabels (const CommandContext &context)
 
void OnSplitDeleteLabels (const CommandContext &context)
 
void OnSilenceLabels (const CommandContext &context)
 
void OnCopyLabels (const CommandContext &context)
 
void OnSplitLabels (const CommandContext &context)
 
void OnJoinLabels (const CommandContext &context)
 
void OnDisjoinLabels (const CommandContext &context)
 
void OnNewLabelTrack (const CommandContext &context)
 

Detailed Description

Definition at line 290 of file LabelMenus.cpp.

Member Function Documentation

◆ OnAddLabel()

void LabelEditActions::Handler::OnAddLabel ( const CommandContext context)
inline

Definition at line 298 of file LabelMenus.cpp.

299{
300 auto &project = context.project;
301 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
302
303 DoAddLabel(project, selectedRegion);
304}
AudacityProject & project
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
int DoAddLabel(AudacityProject &project, const SelectedRegion &region, bool preserveFocus=false)
Definition: LabelMenus.cpp:53

References anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), ViewInfo::Get(), CommandContext::project, and ViewInfo::selectedRegion.

Here is the call graph for this function:

◆ OnAddLabelPlaying()

void LabelEditActions::Handler::OnAddLabelPlaying ( const CommandContext context)
inline

Definition at line 306 of file LabelMenus.cpp.

307{
308 auto &project = context.project;
309 auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
310
311 auto gAudioIO = AudioIO::Get();
312 if (token > 0 &&
313 gAudioIO->IsStreamActive(token)) {
314 double indicator = gAudioIO->GetStreamTime();
315 DoAddLabel(project, SelectedRegion(indicator, indicator), true);
316 }
317}
static AudioIO * Get()
Definition: AudioIO.cpp:133
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)
Defines a selected portion of a project.

References anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), AudioIO::Get(), ProjectAudioIO::Get(), ProjectAudioIO::GetAudioIOToken(), and CommandContext::project.

Here is the call graph for this function:

◆ OnCopyLabels()

void LabelEditActions::Handler::OnCopyLabels ( const CommandContext context)
inline

Definition at line 568 of file LabelMenus.cpp.

569{
570 auto &project = context.project;
571 auto &tracks = TrackList::Get( project );
572 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
573
574 if( selectedRegion.isPoint() )
575 return;
576
577 auto copyfunc = [&](Track *track, double t0, double t1)
578 {
579 Track::Holder dest = nullptr;
580 track->TypeSwitch(
581 [&](WaveTrack *t)
582 {
583 dest = t->CopyNonconst(t0, t1);
584 });
585 return dest;
586 };
587 EditClipboardByLabel( project, tracks, selectedRegion, copyfunc );
588
589 ProjectHistory::Get( project ).PushState( XO( "Copied labeled audio regions to clipboard" ),
590 /* i18n-hint: (verb)*/
591 XO( "Copy Labeled Audio" ) );
592}
#define XO(s)
Definition: Internat.h:31
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:832
std::shared_ptr< Track > Holder
Definition: Track.h:368
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
Track::Holder CopyNonconst(double t0, double t1)
Definition: WaveTrack.cpp:782
void EditClipboardByLabel(AudacityProject &project, TrackList &tracks, const SelectedRegion &selectedRegion, EditDestFunction action)
Definition: LabelMenus.cpp:206

References WaveTrack::CopyNonconst(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnCutLabels()

void LabelEditActions::Handler::OnCutLabels ( const CommandContext context)
inline

Definition at line 392 of file LabelMenus.cpp.

393{
394 auto &project = context.project;
395 auto &tracks = TrackList::Get( project );
396 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
397
398 if( selectedRegion.isPoint() )
399 return;
400
401 // Because of grouping the copy may need to operate on different tracks than
402 // the clear, so we do these actions separately.
403 auto copyfunc = [&](Track *track, double t0, double t1)
404 {
405 Track::Holder dest = nullptr;
406 track->TypeSwitch(
407 [&](WaveTrack *t)
408 {
409 dest = t->CopyNonconst(t0, t1);
410 }
411 );
412 return dest;
413 };
414 EditClipboardByLabel( project, tracks, selectedRegion, copyfunc );
415
416 bool enableCutlines = gPrefs->ReadBool(wxT( "/GUI/EnableCutLines"), false);
417 auto editfunc = [&](Track *track, double t0, double t1)
418 {
419 track->TypeSwitch(
420 [&](WaveTrack *t)
421 {
422 if (enableCutlines)
423 {
424 t->ClearAndAddCutLine(t0, t1);
425 }
426 else
427 {
428 t->Clear(t0, t1);
429 }
430 },
431 [&](Track *t)
432 {
433 t->Clear(t0, t1);
434 }
435 );
436 };
437 EditByLabel(project, tracks, selectedRegion, editfunc);
438
439 selectedRegion.collapseToT0();
440
442 /* i18n-hint: (verb) past tense. Audacity has just cut the labeled audio
443 regions.*/
444 XO( "Cut labeled audio regions to clipboard" ),
445 /* i18n-hint: (verb)*/
446 XO( "Cut Labeled Audio" ) );
447}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:71
void ClearAndAddCutLine(double t0, double t1)
Definition: WaveTrack.cpp:794
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:788
void EditByLabel(AudacityProject &project, TrackList &tracks, const SelectedRegion &selectedRegion, EditFunction action)
Definition: LabelMenus.cpp:167

References WaveTrack::Clear(), WaveTrack::ClearAndAddCutLine(), WaveTrack::CopyNonconst(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), gPrefs, CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, Track::TypeSwitch(), wxT(), and XO.

Here is the call graph for this function:

◆ OnDeleteLabels()

void LabelEditActions::Handler::OnDeleteLabels ( const CommandContext context)
inline

Definition at line 449 of file LabelMenus.cpp.

450{
451 auto &project = context.project;
452 auto &tracks = TrackList::Get( project );
453 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
454
455 if( selectedRegion.isPoint() )
456 return;
457
458 auto editfunc = [&](Track *track, double t0, double t1)
459 {
460 track->Clear(t0, t1);
461 };
462 EditByLabel(project, tracks, selectedRegion, editfunc);
463
464 selectedRegion.collapseToT0();
465
467 /* i18n-hint: (verb) Audacity has just deleted the labeled audio regions*/
468 XO( "Deleted labeled audio regions" ),
469 /* i18n-hint: (verb)*/
470 XO( "Delete Labeled Audio" ) );
471}
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0

References Track::Clear(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, and XO.

Here is the call graph for this function:

◆ OnDisjoinLabels()

void LabelEditActions::Handler::OnDisjoinLabels ( const CommandContext context)
inline

Definition at line 650 of file LabelMenus.cpp.

651{
652 auto &project = context.project;
653 auto &tracks = TrackList::Get( project );
654 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
655
656 if( selectedRegion.isPoint() )
657 return;
658
659 auto editfunc = [&](Track *track, double t0, double t1)
660 {
661 track->TypeSwitch(
662 [&](WaveTrack *t)
663 {
664 wxBusyCursor busy;
665 t->Disjoin(t0, t1);
666 }
667 );
668 };
669 EditByLabel(project, tracks, selectedRegion, editfunc);
670
672 /* i18n-hint: (verb) Audacity has just detached the labeled audio regions.
673 This message appears in history and tells you about something
674 Audacity has done.*/
675 XO( "Detached labeled audio regions" ),
676 /* i18n-hint: (verb)*/
677 XO( "Detach Labeled Audio" ) );
678}
void Disjoin(double t0, double t1)
Definition: WaveTrack.cpp:1647

References WaveTrack::Disjoin(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnEditLabels()

void LabelEditActions::Handler::OnEditLabels ( const CommandContext context)
inline

Definition at line 292 of file LabelMenus.cpp.

293{
294 auto &project = context.project;
296}
static void DoEditLabels(AudacityProject &project, LabelTrack *lt=nullptr, int index=-1)

References LabelTrackView::DoEditLabels(), and CommandContext::project.

Here is the call graph for this function:

◆ OnJoinLabels()

void LabelEditActions::Handler::OnJoinLabels ( const CommandContext context)
inline

Definition at line 622 of file LabelMenus.cpp.

623{
624 auto &project = context.project;
625 auto &tracks = TrackList::Get( project );
626 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
627
628 if( selectedRegion.isPoint() )
629 return;
630
631 auto editfunc = [&](Track *track, double t0, double t1)
632 {
633 track->TypeSwitch(
634 [&](WaveTrack *t)
635 {
636 t->Join(t0, t1);
637 }
638 );
639 };
640 EditByLabel(project, tracks, selectedRegion, editfunc);
641
643 /* i18n-hint: (verb) Audacity has just joined the labeled audio (points or
644 regions) */
645 XO( "Joined labeled audio (points or regions)" ),
646 /* i18n-hint: (verb) */
647 XO( "Join Labeled Audio" ) );
648}
void Join(double t0, double t1)
Definition: WaveTrack.cpp:1718

References anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), WaveTrack::Join(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnNewLabelTrack()

void LabelEditActions::Handler::OnNewLabelTrack ( const CommandContext context)
inline

Definition at line 680 of file LabelMenus.cpp.

681{
682 auto &project = context.project;
683 auto &tracks = TrackList::Get( project );
684
685 auto track = LabelTrack::Create(tracks);
686
688
689 track->SetSelected(true);
690
691 ProjectHistory::Get( project )
692 .PushState(XO("Created new label track"), XO("New Track"));
693
694 TrackFocus::Get(project).Set(track);
695 track->EnsureVisible();
696}
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
Definition: LabelTrack.cpp:71
Track * Get()
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:97
void SelectNone(AudacityProject &project)

References LabelTrack::Create(), Track::EnsureVisible(), TrackFocus::Get(), ProjectHistory::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), SelectUtilities::SelectNone(), and XO.

Here is the call graph for this function:

◆ OnPasteNewLabel()

void LabelEditActions::Handler::OnPasteNewLabel ( const CommandContext context)
inline

Definition at line 321 of file LabelMenus.cpp.

322{
323 auto &project = context.project;
324 auto &tracks = TrackList::Get( project );
325 auto &trackPanel = TrackPanel::Get( project );
326 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
327
328 bool bPastedSomething = false;
329
330 {
331 auto trackRange = tracks.Selected< const LabelTrack >();
332 if (trackRange.empty())
333 {
334 // If there are no selected label tracks, try to choose the first label
335 // track after some other selected track
336 Track *t = *tracks.Selected().begin()
337 .Filter( &Track::Any )
338 .Filter<LabelTrack>();
339
340 // If no match found, add one
341 if (!t)
342 t = LabelTrack::Create(tracks);
343
344 // Select this track so the loop picks it up
345 t->SetSelected(true);
346 }
347 }
348
349 LabelTrack *plt = NULL; // the previous track
350 for ( auto lt : tracks.Selected< LabelTrack >() )
351 {
352 // Unselect the last label, so we'll have just one active label when
353 // we're done
354 if (plt)
356
357 // Add a NEW label, paste into it
358 // Paul L: copy whatever defines the selected region, not just times
359 auto &view = LabelTrackView::Get( *lt );
360 view.AddLabel(selectedRegion);
361 if (view.PasteSelectedText( context.project, selectedRegion.t0(),
362 selectedRegion.t1() ))
363 bPastedSomething = true;
364
365 // Set previous track
366 plt = lt;
367 }
368
369 // plt should point to the last label track pasted to -- ensure it's visible
370 // and set focus
371 if (plt) {
372 TrackFocus::Get(project).Set(plt);
373 plt->EnsureVisible();
374 trackPanel.SetFocus();
375 }
376
377 if (bPastedSomething) {
379 XO("Pasted from the clipboard"), XO("Paste Text to New Label"));
380 }
381}
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:89
static LabelTrackView & Get(LabelTrack &)
virtual void SetSelected(bool s)
Definition: Track.cpp:87
bool Any() const
Definition: Track.cpp:399
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230

References Track::Any(), LabelTrack::Create(), Track::EnsureVisible(), TrackFocus::Get(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), TrackPanel::Get(), LabelTrackView::Get(), CommandContext::project, ProjectHistory::PushState(), LabelTrackView::ResetTextSelection(), ViewInfo::selectedRegion, Track::SetSelected(), and XO.

Here is the call graph for this function:

◆ OnSilenceLabels()

void LabelEditActions::Handler::OnSilenceLabels ( const CommandContext context)
inline

Definition at line 541 of file LabelMenus.cpp.

542{
543 auto &project = context.project;
544 auto &tracks = TrackList::Get( project );
545 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
546
547 if( selectedRegion.isPoint() )
548 return;
549
550 auto editfunc = [&](Track *track, double t0, double t1)
551 {
552 track->TypeSwitch(
553 [&](WaveTrack *t)
554 {
555 t->Silence(t0, t1);
556 }
557 );
558 };
559 EditByLabel(project, tracks, selectedRegion, editfunc);
560
562 /* i18n-hint: (verb)*/
563 XO( "Silenced labeled audio regions" ),
564 /* i18n-hint: (verb)*/
565 XO( "Silence Labeled Audio" ) );
566}
void Silence(double t0, double t1) override
Definition: WaveTrack.cpp:1582

References anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, WaveTrack::Silence(), Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnSplitCutLabels()

void LabelEditActions::Handler::OnSplitCutLabels ( const CommandContext context)
inline

Definition at line 473 of file LabelMenus.cpp.

474{
475 auto &project = context.project;
476 auto &tracks = TrackList::Get( project );
477 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
478
479 if( selectedRegion.isPoint() )
480 return;
481
482 auto copyfunc = [&](Track *track, double t0, double t1)
483 {
484 Track::Holder dest = nullptr;
485 track->TypeSwitch(
486 [&](WaveTrack *t)
487 {
488 dest = t->SplitCut(t0, t1);
489 },
490 [&](Track *t)
491 {
492 dest = t->Copy(t0, t1);
493 t->Silence(t0, t1);
494 }
495 );
496 return dest;
497 };
498 EditClipboardByLabel( project, tracks, selectedRegion, copyfunc );
499
501 /* i18n-hint: (verb) Audacity has just split cut the labeled audio
502 regions*/
503 XO( "Split Cut labeled audio regions to clipboard" ),
504 /* i18n-hint: (verb) Do a special kind of cut on the labels*/
505 XO( "Split Cut Labeled Audio" ) );
506}
Track::Holder SplitCut(double t0, double t1)
Definition: WaveTrack.cpp:640
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:716

References WaveTrack::Copy(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, WaveTrack::Silence(), WaveTrack::SplitCut(), Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnSplitDeleteLabels()

void LabelEditActions::Handler::OnSplitDeleteLabels ( const CommandContext context)
inline

Definition at line 508 of file LabelMenus.cpp.

509{
510 auto &project = context.project;
511 auto &tracks = TrackList::Get( project );
512 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
513
514 if( selectedRegion.isPoint() )
515 return;
516
517 auto editfunc = [&](Track *track, double t0, double t1)
518 {
519 track->TypeSwitch(
520 [&](WaveTrack *t)
521 {
522 t->SplitDelete(t0, t1);
523 },
524 [&](Track *t)
525 {
526 t->Silence(t0, t1);
527 }
528 );
529 };
530 EditByLabel(project, tracks, selectedRegion, editfunc);
531
533 /* i18n-hint: (verb) Audacity has just done a special kind of DELETE on
534 the labeled audio regions */
535 XO( "Split Deleted labeled audio regions" ),
536 /* i18n-hint: (verb) Do a special kind of DELETE on labeled audio
537 regions */
538 XO( "Split Delete Labeled Audio" ) );
539}
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1175

References anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, WaveTrack::Silence(), WaveTrack::SplitDelete(), Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnSplitLabels()

void LabelEditActions::Handler::OnSplitLabels ( const CommandContext context)
inline

Definition at line 594 of file LabelMenus.cpp.

595{
596 auto &project = context.project;
597 auto &tracks = TrackList::Get( project );
598 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
599
600 if( selectedRegion.isPoint() )
601 return;
602
603 auto editfunc = [&](Track *track, double t0, double t1)
604 {
605 track->TypeSwitch(
606 [&](WaveTrack *t)
607 {
608 t->Split(t0, t1);
609 }
610 );
611 };
612 EditByLabel(project, tracks, selectedRegion, editfunc);
613
615 /* i18n-hint: (verb) past tense. Audacity has just split the labeled
616 audio (a point or a region)*/
617 XO( "Split labeled audio (points or regions)" ),
618 /* i18n-hint: (verb)*/
619 XO( "Split Labeled Audio" ) );
620}
void Split(double t0, double t1)
Definition: WaveTrack.cpp:2527

References anonymous_namespace{LabelMenus.cpp}::EditByLabel(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, WaveTrack::Split(), Track::TypeSwitch(), and XO.

Here is the call graph for this function:

◆ OnToggleTypeToCreateLabel()

void LabelEditActions::Handler::OnToggleTypeToCreateLabel ( const CommandContext WXUNUSEDcontext)
inline

Definition at line 383 of file LabelMenus.cpp.

384{
385 bool typeToCreateLabel;
386 gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, false);
387 gPrefs->Write(wxT("/GUI/TypeToCreateLabel"), !typeToCreateLabel);
388 gPrefs->Flush();
390}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static void ModifyAllProjectToolbarMenus()
Definition: Menus.cpp:592

References FileConfig::Flush(), gPrefs, MenuManager::ModifyAllProjectToolbarMenus(), and wxT().

Here is the call graph for this function:

The documentation for this struct was generated from the following file: