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

Public Member Functions

 WaveColorMenuTable ()
 
 DECLARE_POPUP_MENU (WaveColorMenuTable)
 
void InitUserData (void *pUserData) override
 Called before the menu items are appended. More...
 
int IdOfWaveColor (int WaveColor)
 Converts a WaveColor enumeration to a wxWidgets menu item Id. More...
 
void OnWaveColorChange (wxCommandEvent &event)
 
- 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
 

Static Public Member Functions

static WaveColorMenuTableInstance ()
 
- 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)
 

Public Attributes

PlayableTrackControls::InitMenuDatampData {}
 
int OnInstrument1ID
 
int OnInstrument2ID
 
int OnInstrument3ID
 
int OnInstrument4ID
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
using Entry = PopupMenuTableEntry
 
- 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 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 1070 of file WaveformView.cpp.

Constructor & Destructor Documentation

◆ WaveColorMenuTable()

WaveColorMenuTable::WaveColorMenuTable ( )
inline

Definition at line 1072 of file WaveformView.cpp.

1072 : PopupMenuTable{ "WaveColor", XO("&Wave Color") } {}

References XO.

Member Function Documentation

◆ DECLARE_POPUP_MENU()

WaveColorMenuTable::DECLARE_POPUP_MENU ( WaveColorMenuTable  )

◆ IdOfWaveColor()

int WaveColorMenuTable::IdOfWaveColor ( int  WaveColor)

Converts a WaveColor enumeration to a wxWidgets menu item Id.

Definition at line 1140 of file WaveformView.cpp.

1141 { return OnInstrument1ID + WaveColor;}

◆ InitUserData()

void WaveColorMenuTable::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 1093 of file WaveformView.cpp.

1094 {
1095  mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
1096 }

References mpData.

◆ Instance()

WaveColorMenuTable & WaveColorMenuTable::Instance ( )
static

Definition at line 1087 of file WaveformView.cpp.

1088 {
1089  static WaveColorMenuTable instance;
1090  return instance;
1091 }

◆ OnWaveColorChange()

void WaveColorMenuTable::OnWaveColorChange ( wxCommandEvent &  event)

Handles the selection from the WaveColor submenu of the track menu.

Definition at line 1145 of file WaveformView.cpp.

1146 {
1147  int id = event.GetId();
1148  wxASSERT(id >= OnInstrument1ID && id <= OnInstrument4ID);
1149  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
1150 
1151  int newWaveColor = id - OnInstrument1ID;
1152 
1153  AudacityProject *const project = &mpData->project;
1154 
1155  for (auto channel : TrackList::Channels(pTrack))
1156  channel->SetWaveColorIndex(newWaveColor);
1157 
1158  ProjectHistory::Get( *project )
1159  .PushState(XO("Changed '%s' to %s")
1160  .Format( pTrack->GetName(), GetWaveColorStr(newWaveColor) ),
1161  XO("WaveColor Change"));
1162 
1163  using namespace RefreshCode;
1165 }

References TrackList::Channels(), RefreshCode::FixScrollbars, ProjectHistory::Get(), anonymous_namespace{WaveformView.cpp}::GetWaveColorStr(), mpData, OnInstrument1ID, OnInstrument4ID, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, and XO.

Here is the call graph for this function:

Member Data Documentation

◆ mpData

PlayableTrackControls::InitMenuData* WaveColorMenuTable::mpData {}

Definition at line 1079 of file WaveformView.cpp.

Referenced by InitUserData(), and OnWaveColorChange().

◆ OnInstrument1ID

int WaveColorMenuTable::OnInstrument1ID

Definition at line 1084 of file WaveformView.cpp.

Referenced by OnWaveColorChange().

◆ OnInstrument2ID

int WaveColorMenuTable::OnInstrument2ID

Definition at line 1084 of file WaveformView.cpp.

◆ OnInstrument3ID

int WaveColorMenuTable::OnInstrument3ID

Definition at line 1084 of file WaveformView.cpp.

◆ OnInstrument4ID

int WaveColorMenuTable::OnInstrument4ID

Definition at line 1084 of file WaveformView.cpp.

Referenced by OnWaveColorChange().


The documentation for this struct was generated from the following file:
WaveColorMenuTable
Definition: WaveformView.cpp:1071
RefreshCode::FixScrollbars
@ FixScrollbars
Definition: RefreshCode.h:27
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
PopupMenuTable
Definition: PopupMenuTable.h:115
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
Format
Abstract base class used in importing a file.
XO
#define XO(s)
Definition: Internat.h:31
CommonTrackControls::InitMenuData::result
unsigned result
Definition: CommonTrackControls.h:39
WaveColorMenuTable::OnInstrument4ID
int OnInstrument4ID
Definition: WaveformView.cpp:1084
CommonTrackControls::InitMenuData::project
AudacityProject & project
Definition: CommonTrackControls.h:36
WaveColorMenuTable::mpData
PlayableTrackControls::InitMenuData * mpData
Definition: WaveformView.cpp:1079
WaveColorMenuTable::OnInstrument1ID
int OnInstrument1ID
Definition: WaveformView.cpp:1084
CommonTrackControls::InitMenuData
Definition: CommonTrackControls.h:34
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
CommonTrackControls::InitMenuData::pTrack
Track * pTrack
Definition: CommonTrackControls.h:37
anonymous_namespace{WaveformView.cpp}::GetWaveColorStr
const TranslatableString GetWaveColorStr(int colorIndex)
Definition: WaveformView.cpp:1101
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26