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 414 of file WaveTrackAffordanceControls.cpp.

415{
416 auto &view = WaveChannelView::GetFirst(track);
417 auto pAffordance = view.GetAffordanceControls();
418 return std::dynamic_pointer_cast<WaveTrackAffordanceControls>(
419 pAffordance );
420}
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 737 of file WaveTrackAffordanceControls.cpp.

738{
739 auto& project = context.project;
740
741 if (
742 auto pWaveTrack =
743 dynamic_cast<WaveTrack*>(TrackFocus::Get(project).Get()))
744 {
745 if (auto pAffordance = FindAffordance(*pWaveTrack))
746 pAffordance->StartEditSelectedClipSpeed(project);
747 }
748}
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:202

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 722 of file WaveTrackAffordanceControls.cpp.

723{
724 auto &project = context.project;
725
726 if(auto pWaveTrack = dynamic_cast<WaveTrack *>(TrackFocus::Get(project).Get()))
727 {
728 if(auto pAffordance = FindAffordance(*pWaveTrack))
729 {
730 pAffordance->StartEditSelectedClipName(project);
731 // Refresh so the cursor appears
733 }
734 }
735}
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 782 of file WaveTrackAffordanceControls.cpp.

783{
784 OnPitchShift(context, false);
785}
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 763 of file WaveTrackAffordanceControls.cpp.

765{
766 auto [track, it] = SelectedIntervalOfFocusedTrack(context.project);
767 if (!track)
768 return;
769 const auto interval = *it;
770 if (interval->SetCentShift(interval->GetCentShift() + (up ? 100 : -100)))
772 .PushState(
773 XO("Pitch Shift"), XO("Changed Pitch Shift"),
775}
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 777 of file WaveTrackAffordanceControls.cpp.

778{
779 OnPitchShift(context, true);
780}

References OnPitchShift().

Here is the call graph for this function:

◆ OnRenderClipStretching()

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

Definition at line 750 of file WaveTrackAffordanceControls.cpp.

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

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 423 of file WaveTrackAffordanceControls.cpp.

424{
425 // Note that TrackFocus may change its state as a side effect, defining
426 // a track focus if there was none
427 auto track = TrackFocus::Get(project).Get();
428 if (!track)
429 return {};
430 if (
431 auto pWaveTrack =
432 std::dynamic_pointer_cast<WaveTrack>(track->shared_from_this()))
433 {
434 if (FindAffordance(*pWaveTrack)) {
435 auto &viewInfo = ViewInfo::Get(project);
436 const auto &intervals = pWaveTrack->Intervals();
437
438 auto it = std::find_if(
439 intervals.begin(), intervals.end(), [&](const auto& interval) {
440 if (wholeInterval)
441 return interval->Start() == viewInfo.selectedRegion.t0() &&
442 interval->End() == viewInfo.selectedRegion.t1();
443 else
444 return interval->Start() <= viewInfo.selectedRegion.t0() &&
445 interval->End() > viewInfo.selectedRegion.t0();
446 });
447
448 if(it != intervals.end())
449 return { pWaveTrack, it };
450 }
451 }
452 return {};
453}
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 456 of file WaveTrackAffordanceControls.cpp.

457{
459 [](const AudacityProject &project){
460 // const_cast isn't pretty but not harmful in this case
461 return SelectedIntervalOfFocusedTrack(const_cast<AudacityProject&>(project)).first != nullptr;
462 }
463 };
464 return flag;
465}
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 467 of file WaveTrackAffordanceControls.cpp.

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

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 791 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 797 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 804 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 810 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 816 of file WaveTrackAffordanceControls.cpp.