Audacity  2.3.1
Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrackMenuTable Class Reference
Inheritance diagram for TrackMenuTable:
PopupMenuTable TranslatableArray< std::vector< PopupMenuTableEntry > >

Static Public Member Functions

static TrackMenuTableInstance ()
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< MenuBuildMenu (wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData=NULL)
 

Private Member Functions

 TrackMenuTable ()
 
 DECLARE_POPUP_MENU (TrackMenuTable)
 
void OnSetName (wxCommandEvent &)
 
void OnMoveTrack (wxCommandEvent &event)
 
void InitMenu (Menu *pMenu, void *pUserData) override
 
void DestroyMenu () override
 

Private Attributes

TrackControls::InitMenuDatampData
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
typedef PopupMenuTableEntry Entry
 
- Public Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
 TranslatableArray ()
 
const std::vector
< PopupMenuTableEntry > & 
Get ()
 
- Protected Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
virtual void Populate ()=0
 
void Invalidate (wxCommandEvent &evt)
 
- Protected Attributes inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
std::vector< PopupMenuTableEntrymContents
 

Detailed Description

Definition at line 88 of file TrackControls.cpp.

Constructor & Destructor Documentation

TrackMenuTable::TrackMenuTable ( )
inlineprivate

Definition at line 90 of file TrackControls.cpp.

90 : mpData(NULL) {}
TrackControls::InitMenuData * mpData

Member Function Documentation

TrackMenuTable::DECLARE_POPUP_MENU ( TrackMenuTable  )
private
void TrackMenuTable::DestroyMenu ( )
inlineoverrideprivatevirtual

Implements PopupMenuTable.

Definition at line 102 of file TrackControls.cpp.

References mpData.

103  {
104  mpData = nullptr;
105  }
TrackControls::InitMenuData * mpData
void TrackMenuTable::InitMenu ( Menu pMenu,
void *  pUserData 
)
overrideprivatevirtual

Implements PopupMenuTable.

Definition at line 116 of file TrackControls.cpp.

References TrackList::CanMoveDown(), TrackList::CanMoveUp(), GetActiveProject(), AudacityProject::GetTracks(), mpData, OnMoveBottomID, OnMoveDownID, OnMoveTopID, OnMoveUpID, and TrackControls::InitMenuData::pTrack.

117 {
118  mpData = static_cast<TrackControls::InitMenuData*>(pUserData);
119  Track *const pTrack = mpData->pTrack;
120 
121  TrackList *const tracks = GetActiveProject()->GetTracks();
122 
123  pMenu->Enable(OnMoveUpID, tracks->CanMoveUp(pTrack));
124  pMenu->Enable(OnMoveDownID, tracks->CanMoveDown(pTrack));
125  pMenu->Enable(OnMoveTopID, tracks->CanMoveUp(pTrack));
126  pMenu->Enable(OnMoveBottomID, tracks->CanMoveDown(pTrack));
127 }
bool CanMoveDown(Track *t) const
Definition: Track.cpp:973
TrackControls::InitMenuData * mpData
bool CanMoveUp(Track *t) const
Definition: Track.cpp:968
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:191
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
TrackList * GetTracks()
Definition: Project.h:209
TrackMenuTable & TrackMenuTable::Instance ( )
static

Definition at line 110 of file TrackControls.cpp.

Referenced by TrackControls::DoContextMenu().

111 {
112  static TrackMenuTable instance;
113  return instance;
114 }
void TrackMenuTable::OnMoveTrack ( wxCommandEvent &  event)
private

Definition at line 226 of file TrackControls.cpp.

References TrackActions::DoMoveTrack(), GetActiveProject(), mpData, TrackActions::OnMoveBottomID, TrackActions::OnMoveDownID, TrackActions::OnMoveTopID, TrackActions::OnMoveUpID, TrackControls::InitMenuData::pTrack, RefreshCode::RefreshAll, and TrackControls::InitMenuData::result.

227 {
228  AudacityProject *const project = GetActiveProject();
230  switch (event.GetId()) {
231  default:
232  wxASSERT(false);
233  case OnMoveUpID:
234  choice = TrackActions::OnMoveUpID; break;
235  case OnMoveDownID:
236  choice = TrackActions::OnMoveDownID; break;
237  case OnMoveTopID:
238  choice = TrackActions::OnMoveTopID; break;
239  case OnMoveBottomID:
240  choice = TrackActions::OnMoveBottomID; break;
241  }
242 
243  TrackActions::DoMoveTrack(*project, mpData->pTrack, choice);
244 
245  // MoveTrack already refreshed TrackPanel, which means repaint will happen.
246  // This is a harmless redundancy:
248 }
TrackControls::InitMenuData * mpData
void DoMoveTrack(AudacityProject &project, Track *target, MoveChoice choice)
Move a track up, down, to top or to bottom.
Definition: TrackMenus.cpp:719
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
void TrackMenuTable::OnSetName ( wxCommandEvent &  )
private

Definition at line 198 of file TrackControls.cpp.

References _(), TrackList::Channels(), MenuTable::Command(), GetActiveProject(), Track::GetName(), mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, and TrackControls::InitMenuData::result.

199 {
200  Track *const pTrack = mpData->pTrack;
201  if (pTrack)
202  {
203  AudacityProject *const proj = ::GetActiveProject();
204  const wxString oldName = pTrack->GetName();
205 
206  SetTrackNameCommand Command;
207  Command.mName = oldName;
208  // Bug 1837 : We need an OK/Cancel result if we are to enter a blank string.
209  bool bResult = Command.PromptUser( proj );
210  if (bResult)
211  {
212  wxString newName = Command.mName;
213  for (auto channel : TrackList::Channels(pTrack))
214  channel->SetName(newName);
215 
216  proj->PushState(wxString::Format(_("Renamed '%s' to '%s'"),
217  oldName,
218  newName),
219  _("Name Change"));
220 
222  }
223  }
224 }
TrackControls::InitMenuData * mpData
std::unique_ptr< CommandItem > Command(const wxString &name, const wxString &label_in, bool hasDialog, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, const CommandManager::Options &options={})
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:191
wxString GetName() const
Definition: Track.h:376
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4611
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1356

Member Data Documentation

TrackControls::InitMenuData* TrackMenuTable::mpData
private

Definition at line 107 of file TrackControls.cpp.

Referenced by DestroyMenu(), InitMenu(), OnMoveTrack(), and OnSetName().


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