Audacity  2.2.2
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 87 of file TrackControls.cpp.

Constructor & Destructor Documentation

TrackMenuTable::TrackMenuTable ( )
inlineprivate

Definition at line 89 of file TrackControls.cpp.

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

Member Function Documentation

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

Implements PopupMenuTable.

Definition at line 101 of file TrackControls.cpp.

References mpData.

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

Implements PopupMenuTable.

Definition at line 115 of file TrackControls.cpp.

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

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

Definition at line 109 of file TrackControls.cpp.

Referenced by TrackControls::DoContextMenu().

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

Definition at line 233 of file TrackControls.cpp.

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

234 {
235  AudacityProject *const project = GetActiveProject();
237  switch (event.GetId()) {
238  default:
239  wxASSERT(false);
240  case OnMoveUpID:
241  choice = AudacityProject::OnMoveUpID; break;
242  case OnMoveDownID:
243  choice = AudacityProject::OnMoveDownID; break;
244  case OnMoveTopID:
245  choice = AudacityProject::OnMoveTopID; break;
246  case OnMoveBottomID:
247  choice = AudacityProject::OnMoveBottomID; break;
248  }
249 
250  project->MoveTrack(mpData->pTrack, choice);
251 
252  // MoveTrack already refreshed TrackPanel, which means repaint will happen.
253  // This is a harmless redundancy:
255 }
TrackControls::InitMenuData * mpData
void MoveTrack(Track *target, MoveChoice choice)
Move a track up, down, to top or to bottom.
Definition: Menus.cpp:4191
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void TrackMenuTable::OnSetName ( wxCommandEvent &  )
private

Definition at line 197 of file TrackControls.cpp.

References _(), GetActiveProject(), Track::GetLink(), Track::GetLinked(), AudacityProject::GetMixerBoard(), Track::GetName(), mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, TrackControls::InitMenuData::result, Track::SetName(), and MixerBoard::UpdateName().

198 {
199  Track *const pTrack = mpData->pTrack;
200  if (pTrack)
201  {
202  AudacityProject *const proj = ::GetActiveProject();
203  const wxString oldName = pTrack->GetName();
204 
205  SetTrackNameCommand Command;
206  Command.mName = oldName;
207  // Bug 1837 : We need an OK/Cancel result if we are to enter a blank string.
208  bool bResult = Command.PromptUser( proj );
209  if (bResult)
210  {
211  wxString newName = Command.mName;
212  pTrack->SetName(newName);
213  // if we have a linked channel this name should change as well
214  // (otherwise sort by name and time will crash).
215  if (pTrack->GetLinked())
216  pTrack->GetLink()->SetName(newName);
217 
218  MixerBoard *const pMixerBoard = proj->GetMixerBoard();
219  auto pt = dynamic_cast<PlayableTrack*>(pTrack);
220  if (pt && pMixerBoard)
221  pMixerBoard->UpdateName(pt);
222 
223  proj->PushState(wxString::Format(_("Renamed '%s' to '%s'"),
224  oldName,
225  newName),
226  _("Name Change"));
227 
229  }
230  }
231 }
TrackControls::InitMenuData * mpData
bool GetLinked() const
Definition: Track.h:279
MixerBoard * GetMixerBoard()
Definition: Project.h:516
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
wxString GetName() const
Definition: Track.h:271
An AudioTrack that can be played and stopped.
Definition: Track.h:376
void UpdateName(const PlayableTrack *pTrack)
_("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:4702
void SetName(const wxString &n)
Definition: Track.h:272
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308

Member Data Documentation

TrackControls::InitMenuData* TrackMenuTable::mpData
private

Definition at line 106 of file TrackControls.cpp.

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


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