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

Public Member Functions

 WaveTrackMenuTable ()
 
void InitUserData (void *pUserData) override
 Called before the menu items are appended. More...
 
 DECLARE_POPUP_MENU (WaveTrackMenuTable)
 
void OnMultiView (wxCommandEvent &event)
 
void OnSetDisplay (wxCommandEvent &event)
 Set the Display mode based on the menu choice in the Track Menu. More...
 
void OnChannelChange (wxCommandEvent &event)
 
void OnMergeStereo (wxCommandEvent &event)
 Merge two tracks into one stereo track ?? More...
 
void SplitStereo (bool stereo)
 Split a stereo track (or more-than-stereo?) into two (or more) tracks... More...
 
void OnSwapChannels (wxCommandEvent &event)
 Swap the left and right channels of a stero track... More...
 
void OnSplitStereo (wxCommandEvent &event)
 Split a stereo track into two tracks... More...
 
void OnSplitStereoMono (wxCommandEvent &event)
 Split a stereo track into two mono tracks... More...
 
- Public Member Functions inherited from ComputedPopupMenuTable< WaveTrackMenuTable, WaveTrackPopupMenuTable >
void Append (const Factory &factory)
 
- Public Member Functions inherited from WaveTrackPopupMenuTable
WaveTrackFindWaveTrack () const
 
int ReserveId ()
 
 PopupMenuTable (const Identifier &id, const TranslatableString &caption={})
 
- Public Member Functions inherited from PopupMenuTable
 PopupMenuTable (const Identifier &id, const TranslatableString &caption={})
 
const IdentifierId () const
 
const TranslatableStringCaption () const
 
const Registry::GroupItemGetRegistry () const
 
const std::shared_ptr< Registry::GroupItem > & Get (void *pUserData)
 
void Clear ()
 
- Public Member Functions inherited from PopupMenuHandler
 PopupMenuHandler ()=default
 
 PopupMenuHandler (const PopupMenuHandler &)=delete
 
PopupMenuHandleroperator= (const PopupMenuHandler &)=delete
 
virtual void InitUserData (void *pUserData)=0
 Called before the menu items are appended. More...
 

Static Public Member Functions

static WaveTrackMenuTableInstance ()
 
- Static Public Member Functions inherited from ComputedPopupMenuTable< WaveTrackMenuTable, WaveTrackPopupMenuTable >
static Registry::BaseItemPtr Computed (const Factory &factory)
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< PopupMenuBuildMenu (PopupMenuTable *pTable, void *pUserData=NULL)
 
static void ExtendMenu (PopupMenu &menu, PopupMenuTable &otherTable)
 
template<typename Table >
static Registry::BaseItemPtr Computed (const std::function< Registry::BaseItemPtr(Table &) > &factory)
 

Additional Inherited Members

- Public Types inherited from ComputedPopupMenuTable< WaveTrackMenuTable, WaveTrackPopupMenuTable >
using Factory = std::function< Registry::BaseItemPtr(WaveTrackMenuTable &) >
 
- Public Types inherited from PopupMenuTable
using Entry = PopupMenuTableEntry
 
- Public Attributes inherited from WaveTrackPopupMenuTable
PlayableTrackControls::InitMenuDatampData {}
 
- Protected Member Functions inherited from PopupMenuTable
virtual void Populate ()=0
 
void Append (Registry::BaseItemPtr pItem)
 
void Append (const Identifier &stringId, PopupMenuTableEntry::Type type, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init)
 
void AppendItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendRadioItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendCheckItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void BeginSection (const Identifier &name)
 
void EndSection ()
 
- Static Protected Member Functions inherited from PopupMenuTable
static TranslatableString MakeLabel (const TranslatableString &label, bool useExtra, const TranslatableString &extra)
 
- Protected Attributes inherited from WaveTrackPopupMenuTable
int mNextId = 0
 
- Protected Attributes inherited from PopupMenuTable
std::shared_ptr< Registry::GroupItemmTop
 
std::vector< Registry::GroupItem * > mStack
 
Identifier mId
 
TranslatableString mCaption
 
std::unique_ptr< Registry::GroupItemmRegistry
 

Detailed Description

Definition at line 492 of file WaveTrackControls.cpp.

Constructor & Destructor Documentation

◆ WaveTrackMenuTable()

WaveTrackMenuTable::WaveTrackMenuTable ( )
inline

Member Function Documentation

◆ DECLARE_POPUP_MENU()

WaveTrackMenuTable::DECLARE_POPUP_MENU ( WaveTrackMenuTable  )

◆ InitUserData()

void WaveTrackMenuTable::InitUserData ( void *  pUserData)
overridevirtual

Called before the menu items are appended.

Store context data, if needed. May be called more than once before the menu opens. Pointer remains valid for the duration of any callback, if PopupMenuTable::BuildMenu() is called and the result's Popup() is called before any other menus are built.

Implements PopupMenuHandler.

Definition at line 529 of file WaveTrackControls.cpp.

530{
531 mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
532}
PlayableTrackControls::InitMenuData * mpData

References WaveTrackPopupMenuTable::mpData.

◆ Instance()

WaveTrackMenuTable & WaveTrackMenuTable::Instance ( )
static

Definition at line 523 of file WaveTrackControls.cpp.

524{
525 static WaveTrackMenuTable instance;
526 return instance;
527}

Referenced by WaveTrackControls::GetMenuExtension(), and GetWaveTrackMenuTable().

Here is the caller graph for this function:

◆ OnChannelChange()

void WaveTrackMenuTable::OnChannelChange ( wxCommandEvent &  event)

◆ OnMergeStereo()

void WaveTrackMenuTable::OnMergeStereo ( wxCommandEvent &  event)

Merge two tracks into one stereo track ??

Definition at line 810 of file WaveTrackControls.cpp.

811{
812 AudacityProject *const project = &mpData->project;
813 auto &tracks = TrackList::Get( *project );
814
815 WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
816 wxASSERT(pTrack);
817
818 auto partner = static_cast< WaveTrack * >
819 ( *tracks.Find( pTrack ).advance( 1 ) );
820
821 bool bBothMinimizedp =
822 ((TrackView::Get( *pTrack ).GetMinimized()) &&
823 (TrackView::Get( *partner ).GetMinimized()));
824
825 tracks.MakeMultiChannelTrack( *pTrack, 2, false );
826
827 // Set partner's parameters to match target.
828 partner->Merge(*pTrack);
829
830 pTrack->SetPan( 0.0f );
831 partner->SetPan( 0.0f );
832
833 // Set NEW track heights and minimized state
834 auto
835 &view = WaveTrackView::Get( *pTrack ),
836 &partnerView = WaveTrackView::Get( *partner );
837 view.SetMinimized(false);
838 partnerView.SetMinimized(false);
839 int AverageHeight = (view.GetHeight() + partnerView.GetHeight()) / 2;
840 view.SetExpandedHeight(AverageHeight);
841 partnerView.SetExpandedHeight(AverageHeight);
842 view.SetMinimized(bBothMinimizedp);
843 partnerView.SetMinimized(bBothMinimizedp);
844
845 partnerView.RestorePlacements( view.SavePlacements() );
846 partnerView.SetMultiView( view.GetMultiView() );
847
848 ProjectHistory::Get( *project ).PushState(
849 /* i18n-hint: The string names a track */
850 XO("Made '%s' a stereo track").Format( pTrack->GetName() ),
851 XO("Make Stereo"));
852
853 using namespace RefreshCode;
855}
XO("Cut/Copy/Paste")
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Abstract base class used in importing a file.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
wxString GetName() const
Definition: Track.h:467
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:487
bool GetMinimized() const
Definition: TrackView.h:52
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
void SetPan(float newPan) override
Definition: WaveTrack.cpp:405
void Merge(const Track &orig) override
Definition: WaveTrack.cpp:179
static WaveTrackView & Get(WaveTrack &track)
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References RefreshCode::FixScrollbars, ProjectHistory::Get(), TrackList::Get(), TrackView::Get(), WaveTrackView::Get(), TrackView::GetMinimized(), Track::GetName(), WaveTrack::Merge(), WaveTrackPopupMenuTable::mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, WaveTrack::SetPan(), and XO().

Here is the call graph for this function:

◆ OnMultiView()

void WaveTrackMenuTable::OnMultiView ( wxCommandEvent &  event)

Definition at line 713 of file WaveTrackControls.cpp.

714{
715 const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
716 const auto &view = WaveTrackView::Get( *pTrack );
717 bool multi = !view.GetMultiView();
718 const auto &displays = view.GetDisplays();
719 const auto display = displays.empty()
720 ? WaveTrackViewConstants::Waveform : displays.begin()->id;
721 for (const auto channel : TrackList::Channels(pTrack)) {
722 auto &channelView = WaveTrackView::Get( *channel );
723 channelView.SetMultiView( multi );
724
725 // Whichever sub-view was on top stays on top
726 // If going into Multi-view, it will be 1/nth the height.
727 // If exiting multi-view, it will be full height.
728 channelView.SetDisplay(display, !multi);
729 }
730}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544

References TrackList::Channels(), WaveTrackView::Get(), and WaveTrackViewConstants::Waveform.

Here is the call graph for this function:

◆ OnSetDisplay()

void WaveTrackMenuTable::OnSetDisplay ( wxCommandEvent &  event)

Set the Display mode based on the menu choice in the Track Menu.

Definition at line 733 of file WaveTrackControls.cpp.

734{
735 int idInt = event.GetId();
736 wxASSERT(idInt >= OnSetDisplayId &&
737 idInt <= lastDisplayId);
738 const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
739
740 auto id = AllTypes()[ idInt - OnSetDisplayId ].id;
741
742 auto &view = WaveTrackView::Get( *pTrack );
743 if ( view.GetMultiView() ) {
744 for (auto channel : TrackList::Channels(pTrack)) {
745 if ( !WaveTrackView::Get( *channel )
746 .ToggleSubView( WaveTrackView::Display{ id } ) ) {
747 // Trying to toggle off the last sub-view. It was refused.
748 // Decide what to do here. Turn off multi-view instead?
749 // PRL: I don't agree that it makes sense
750 }
751 else
753 }
754 }
755 else {
756 const auto displays = view.GetDisplays();
757 const bool wrongType =
758 !(displays.size() == 1 && displays[0].id == id);
759 if (wrongType) {
760 for (auto channel : TrackList::Channels(pTrack)) {
761 WaveTrackView::Get( *channel )
763 }
764
765 AudacityProject *const project = &mpData->project;
766 ProjectHistory::Get( *project ).ModifyState(true);
767
768 using namespace RefreshCode;
770 }
771 }
772}
@ lastDisplayId
@ OnSetDisplayId
static std::vector< WaveTrackSubViewType > AllTypes()
int id
void ModifyState(bool bWantsAutoSave)
void SetDisplay(Display display, bool exclusive=true)

References AllTypes(), TrackList::Channels(), ProjectHistory::Get(), WaveTrackView::Get(), id, lastDisplayId, ProjectHistory::ModifyState(), WaveTrackPopupMenuTable::mpData, OnSetDisplayId, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, WaveTrackView::SetDisplay(), and RefreshCode::UpdateVRuler.

Here is the call graph for this function:

◆ OnSplitStereo()

void WaveTrackMenuTable::OnSplitStereo ( wxCommandEvent &  event)

Split a stereo track into two tracks...

Definition at line 920 of file WaveTrackControls.cpp.

921{
922 SplitStereo(true);
923 WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
924 AudacityProject *const project = &mpData->project;
925 ProjectHistory::Get( *project ).PushState(
926 /* i18n-hint: The string names a track */
927 XO("Split stereo track '%s'").Format( pTrack->GetName() ),
928 XO("Split"));
929
930 using namespace RefreshCode;
932}
void SplitStereo(bool stereo)
Split a stereo track (or more-than-stereo?) into two (or more) tracks...

References RefreshCode::FixScrollbars, ProjectHistory::Get(), Track::GetName(), WaveTrackPopupMenuTable::mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, SplitStereo(), and XO().

Here is the call graph for this function:

◆ OnSplitStereoMono()

void WaveTrackMenuTable::OnSplitStereoMono ( wxCommandEvent &  event)

Split a stereo track into two mono tracks...

Definition at line 935 of file WaveTrackControls.cpp.

936{
937 SplitStereo(false);
938 WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
939 AudacityProject *const project = &mpData->project;
940 ProjectHistory::Get( *project ).PushState(
941 /* i18n-hint: The string names a track */
942 XO("Split Stereo to Mono '%s'").Format( pTrack->GetName() ),
943 XO("Split to Mono"));
944
945 using namespace RefreshCode;
947}

References RefreshCode::FixScrollbars, ProjectHistory::Get(), Track::GetName(), WaveTrackPopupMenuTable::mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, SplitStereo(), and XO().

Here is the call graph for this function:

◆ OnSwapChannels()

void WaveTrackMenuTable::OnSwapChannels ( wxCommandEvent &  event)

Swap the left and right channels of a stero track...

Definition at line 890 of file WaveTrackControls.cpp.

891{
892 AudacityProject *const project = &mpData->project;
893
894 WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
895 auto channels = TrackList::Channels( pTrack );
896 if (channels.size() != 2)
897 return;
898
899 auto &trackFocus = TrackFocus::Get( *project );
900 Track *const focused = trackFocus.Get();
901 const bool hasFocus = channels.contains( focused );
902
903 auto partner = *channels.rbegin();
904
905 if (TrackList::SwapChannels(*pTrack)) {
906 auto &tracks = TrackList::Get( *project );
907 if (hasFocus)
908 trackFocus.Set(partner);
909
910 ProjectHistory::Get( *project ).PushState(
911 /* i18n-hint: The string names a track */
912 XO("Swapped Channels in '%s'").Format( pTrack->GetName() ),
913 XO("Swap Channels"));
914 }
915
917}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
Track * Get()
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
static bool SwapChannels(Track &track)
If the given track is one of a pair of channels, swap them.
Definition: Track.cpp:654

References TrackList::Channels(), TrackFocus::Get(), ProjectHistory::Get(), TrackList::Get(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), Track::GetName(), WaveTrackPopupMenuTable::mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, TrackList::SwapChannels(), and XO().

Here is the call graph for this function:

◆ SplitStereo()

void WaveTrackMenuTable::SplitStereo ( bool  stereo)

Split a stereo track (or more-than-stereo?) into two (or more) tracks...

Definition at line 858 of file WaveTrackControls.cpp.

859{
860 WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
861 wxASSERT(pTrack);
862 AudacityProject *const project = &mpData->project;
863 auto channels = TrackList::Channels( pTrack );
864
865 int totalHeight = 0;
866 int nChannels = 0;
867 for (auto channel : channels) {
868 // Keep original stereo track name.
869 channel->SetName(pTrack->GetName());
870 auto &view = TrackView::Get( *channel );
871 if (stereo)
872 channel->SetPanFromChannelType();
873
874 //make sure no channel is smaller than its minimum height
875 if (view.GetHeight() < view.GetMinimizedHeight())
876 view.SetExpandedHeight(view.GetMinimizedHeight());
877 totalHeight += view.GetHeight();
878 ++nChannels;
879 }
880
881 TrackList::Get( *project ).UnlinkChannels( *pTrack );
882 int averageHeight = totalHeight / nChannels;
883
884 for (auto channel : channels)
885 // Make tracks the same height
886 TrackView::Get( *channel ).SetExpandedHeight( averageHeight );
887}
void UnlinkChannels(Track &track)
Removes linkage if track belongs to a group.
Definition: Track.cpp:747
void SetExpandedHeight(int height)
Definition: TrackView.cpp:172

References TrackList::Channels(), TrackList::Get(), TrackView::Get(), Track::GetName(), WaveTrackPopupMenuTable::mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, TrackView::SetExpandedHeight(), and TrackList::UnlinkChannels().

Referenced by OnSplitStereo(), and OnSplitStereoMono().

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

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