Audacity 3.2.0
Functions | Variables
anonymous_namespace{WaveTrackAffordanceControls.cpp} Namespace Reference

Functions

auto FindAffordance (WaveTrack &track)
 
std::pair< std::shared_ptr< WaveTrack >, ChannelGroup::IntervalIterator< WaveTrack::Interval > > SelectedIntervalOfFocusedTrack (AudacityProject &project, bool wholeInterval=true)
 
const ReservedCommandFlagSomeClipIsSelectedFlag ()
 
const ReservedCommandFlagStretchedClipIsSelectedFlag ()
 
void OnEditClipName (const CommandContext &context)
 
void OnChangePitchAndSpeed (const CommandContext &context)
 
void OnRenderClipStretching (const CommandContext &context)
 
void OnPitchShift (const CommandContext &context, bool up)
 
void OnPitchUp (const CommandContext &context)
 
void OnPitchDown (const CommandContext &context)
 

Variables

AttachedItem sAttachment
 
AttachedItem sAttachment2
 
AttachedItem sAttachment3
 
AttachedItem sAttachment4
 
AttachedItem sAttachment5
 

Function Documentation

◆ FindAffordance()

auto anonymous_namespace{WaveTrackAffordanceControls.cpp}::FindAffordance ( WaveTrack track)

Definition at line 412 of file WaveTrackAffordanceControls.cpp.

413{
414 auto &view = WaveChannelView::GetFirst(track);
415 auto pAffordance = view.GetAffordanceControls();
416 return std::dynamic_pointer_cast<WaveTrackAffordanceControls>(
417 pAffordance );
418}
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.

References WaveChannelView::GetFirst().

Referenced by OnChangePitchAndSpeed(), OnEditClipName(), OnRenderClipStretching(), and SelectedIntervalOfFocusedTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnChangePitchAndSpeed()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnChangePitchAndSpeed ( const CommandContext context)

Definition at line 735 of file WaveTrackAffordanceControls.cpp.

736{
737 auto& project = context.project;
738
739 if (
740 auto pWaveTrack =
741 dynamic_cast<WaveTrack*>(TrackFocus::Get(project).Get()))
742 {
743 if (auto pAffordance = FindAffordance(*pWaveTrack))
744 pAffordance->StartEditSelectedClipSpeed(project);
745 }
746}
const auto project
AudacityProject & project
Track * Get()
Definition: TrackFocus.cpp:156
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:201

References FindAffordance(), BasicUI::Get(), TrackFocus::Get(), CommandContext::project, and project.

Here is the call graph for this function:

◆ OnEditClipName()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnEditClipName ( const CommandContext context)

Definition at line 720 of file WaveTrackAffordanceControls.cpp.

721{
722 auto &project = context.project;
723
724 if(auto pWaveTrack = dynamic_cast<WaveTrack *>(TrackFocus::Get(project).Get()))
725 {
726 if(auto pAffordance = FindAffordance(*pWaveTrack))
727 {
728 pAffordance->StartEditSelectedClipName(project);
729 // Refresh so the cursor appears
731 }
732 }
733}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
void RefreshTrack(Track *trk, bool refreshbacking=true)
Definition: TrackPanel.cpp:768

References FindAffordance(), BasicUI::Get(), TrackFocus::Get(), TrackPanel::Get(), CommandContext::project, project, and TrackPanel::RefreshTrack().

Here is the call graph for this function:

◆ OnPitchDown()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnPitchDown ( const CommandContext context)

Definition at line 780 of file WaveTrackAffordanceControls.cpp.

781{
782 OnPitchShift(context, false);
783}
void OnPitchShift(const CommandContext &context, bool up)

References OnPitchShift().

Here is the call graph for this function:

◆ OnPitchShift()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnPitchShift ( const CommandContext context,
bool  up 
)

Definition at line 761 of file WaveTrackAffordanceControls.cpp.

763{
764 auto [track, it] = SelectedIntervalOfFocusedTrack(context.project);
765 if (!track)
766 return;
767 const auto interval = *it;
768 if (interval->SetCentShift(interval->GetCentShift() + (up ? 100 : -100)))
770 .PushState(
771 XO("Pitch Shift"), XO("Changed Pitch Shift"),
773}
XO("Cut/Copy/Paste")
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
std::pair< std::shared_ptr< WaveTrack >, ChannelGroup::IntervalIterator< WaveTrack::Interval > > SelectedIntervalOfFocusedTrack(AudacityProject &project, bool wholeInterval=true)

References CONSOLIDATE, ProjectHistory::Get(), CommandContext::project, ProjectHistory::PushState(), SelectedIntervalOfFocusedTrack(), and XO().

Referenced by OnPitchDown(), and OnPitchUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPitchUp()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnPitchUp ( const CommandContext context)

Definition at line 775 of file WaveTrackAffordanceControls.cpp.

776{
777 OnPitchShift(context, true);
778}

References OnPitchShift().

Here is the call graph for this function:

◆ OnRenderClipStretching()

void anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnRenderClipStretching ( const CommandContext context)

Definition at line 748 of file WaveTrackAffordanceControls.cpp.

749{
750 auto& project = context.project;
751
752 if (
753 auto pWaveTrack =
754 dynamic_cast<WaveTrack*>(TrackFocus::Get(project).Get()))
755 {
756 if (auto pAffordance = FindAffordance(*pWaveTrack))
757 pAffordance->OnRenderClipStretching(project);
758 }
759}

References FindAffordance(), BasicUI::Get(), TrackFocus::Get(), CommandContext::project, and project.

Here is the call graph for this function:

◆ SelectedIntervalOfFocusedTrack()

std::pair< std::shared_ptr< WaveTrack >, ChannelGroup::IntervalIterator< WaveTrack::Interval > > anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedIntervalOfFocusedTrack ( AudacityProject project,
bool  wholeInterval = true 
)

Definition at line 421 of file WaveTrackAffordanceControls.cpp.

422{
423 // Note that TrackFocus may change its state as a side effect, defining
424 // a track focus if there was none
425 auto track = TrackFocus::Get(project).Get();
426 if (!track)
427 return {};
428 if (
429 auto pWaveTrack =
430 std::dynamic_pointer_cast<WaveTrack>(track->shared_from_this()))
431 {
432 if (FindAffordance(*pWaveTrack)) {
433 auto &viewInfo = ViewInfo::Get(project);
434 const auto &intervals = pWaveTrack->Intervals();
435
436 auto it = std::find_if(
437 intervals.begin(), intervals.end(), [&](const auto& interval) {
438 if (wholeInterval)
439 return interval->Start() == viewInfo.selectedRegion.t0() &&
440 interval->End() == viewInfo.selectedRegion.t1();
441 else
442 return interval->Start() <= viewInfo.selectedRegion.t0() &&
443 interval->End() > viewInfo.selectedRegion.t0();
444 });
445
446 if(it != intervals.end())
447 return { pWaveTrack, it };
448 }
449 }
450 return {};
451}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References FindAffordance(), TrackFocus::Get(), ViewInfo::Get(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), and project.

Referenced by OnPitchShift(), WaveTrackAffordanceControls::OnRenderClipStretching(), SomeClipIsSelectedFlag(), WaveTrackAffordanceControls::StartEditSelectedClipName(), WaveTrackAffordanceControls::StartEditSelectedClipSpeed(), and StretchedClipIsSelectedFlag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SomeClipIsSelectedFlag()

const ReservedCommandFlag & anonymous_namespace{WaveTrackAffordanceControls.cpp}::SomeClipIsSelectedFlag ( )

Definition at line 454 of file WaveTrackAffordanceControls.cpp.

455{
457 [](const AudacityProject &project){
458 // const_cast isn't pretty but not harmful in this case
459 return SelectedIntervalOfFocusedTrack(const_cast<AudacityProject&>(project)).first != nullptr;
460 }
461 };
462 return flag;
463}
static std::once_flag flag
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

References flag, project, and SelectedIntervalOfFocusedTrack().

Here is the call graph for this function:

◆ StretchedClipIsSelectedFlag()

const ReservedCommandFlag & anonymous_namespace{WaveTrackAffordanceControls.cpp}::StretchedClipIsSelectedFlag ( )

Definition at line 465 of file WaveTrackAffordanceControls.cpp.

466{
468 [](const AudacityProject &project){
469 // const_cast isn't pretty but not harmful in this case
470 auto result = SelectedIntervalOfFocusedTrack(
471 const_cast<AudacityProject&>(project));
472
473 auto interval = *result.second;
474 return interval != nullptr && interval->HasPitchOrSpeed();
475 }
476 };
477 return flag;
478}

References flag, project, and SelectedIntervalOfFocusedTrack().

Here is the call graph for this function:

Variable Documentation

◆ sAttachment

AttachedItem anonymous_namespace{WaveTrackAffordanceControls.cpp}::sAttachment
Initial value:
{
Command( L"RenameClip", XXO("&Rename Clip..."),
wxT("Edit/Other/Clip")
}
wxT("CloseDown"))
XXO("&Cut/Copy/Paste Toolbar")
constexpr auto Command
Definition: MenuRegistry.h:456

Definition at line 789 of file WaveTrackAffordanceControls.cpp.

◆ sAttachment2

AttachedItem anonymous_namespace{WaveTrackAffordanceControls.cpp}::sAttachment2
Initial value:
{
L"ChangePitchAndSpeed", XXO("&Pitch and Speed..."), OnChangePitchAndSpeed,
AlwaysEnabledFlag, Options { wxT("Ctrl+Shift+P") }),
wxT("Edit/Other/Clip")
}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34

Definition at line 795 of file WaveTrackAffordanceControls.cpp.

◆ sAttachment3

AttachedItem anonymous_namespace{WaveTrackAffordanceControls.cpp}::sAttachment3
Initial value:
{
Command( L"RenderPitchAndSpeed", XXO("Render Pitch and &Speed"),
wxT("Edit/Other/Clip")
}

Definition at line 802 of file WaveTrackAffordanceControls.cpp.

◆ sAttachment4

AttachedItem anonymous_namespace{WaveTrackAffordanceControls.cpp}::sAttachment4
Initial value:
{
Command( L"PitchUp", XXO("Pitch &Up"),
wxT("Edit/Other/Clip")
}

Definition at line 808 of file WaveTrackAffordanceControls.cpp.

◆ sAttachment5

AttachedItem anonymous_namespace{WaveTrackAffordanceControls.cpp}::sAttachment5
Initial value:
{
Command( L"PitchDown", XXO("Pitch &Down"),
wxT("Edit/Other/Clip")
}

Definition at line 814 of file WaveTrackAffordanceControls.cpp.