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

Static Public Member Functions

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

Private Member Functions

 TrackMenuTable ()
 
 DECLARE_POPUP_MENU (TrackMenuTable)
 
void OnSetName (wxCommandEvent &)
 
void OnMoveTrack (wxCommandEvent &event)
 
void InitUserData (void *pUserData) override
 Called before the menu items are appended. More...
 
void UpdatePrefs () override
 
- Private Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdateSelectedPrefs (int id)
 

Private Attributes

CommonTrackControls::InitMenuDatampData {}
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
using Entry = PopupMenuTableEntry
 
- 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
 
- 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
 
- Static Private Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Detailed Description

Definition at line 82 of file CommonTrackControls.cpp.

Constructor & Destructor Documentation

◆ TrackMenuTable()

TrackMenuTable::TrackMenuTable ( )
inlineprivate

Definition at line 86 of file CommonTrackControls.cpp.

87  : PopupMenuTable{ "Track" }
88  {}

Member Function Documentation

◆ DECLARE_POPUP_MENU()

TrackMenuTable::DECLARE_POPUP_MENU ( TrackMenuTable  )
private

◆ InitUserData()

void TrackMenuTable::InitUserData ( void *  pUserData)
overrideprivatevirtual

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 115 of file CommonTrackControls.cpp.

116 {
117  mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
118 }

References mpData.

◆ Instance()

TrackMenuTable & TrackMenuTable::Instance ( )
static

Definition at line 109 of file CommonTrackControls.cpp.

110 {
111  static TrackMenuTable instance;
112  return instance;
113 }

Referenced by CommonTrackControls::DoContextMenu().

Here is the caller graph for this function:

◆ OnMoveTrack()

void TrackMenuTable::OnMoveTrack ( wxCommandEvent &  event)
private

Definition at line 249 of file CommonTrackControls.cpp.

250 {
251  AudacityProject *const project = &mpData->project;
253  switch (event.GetId()) {
254  default:
255  wxASSERT(false);
256  case OnMoveUpID:
257  choice = TrackUtilities::OnMoveUpID; break;
258  case OnMoveDownID:
259  choice = TrackUtilities::OnMoveDownID; break;
260  case OnMoveTopID:
261  choice = TrackUtilities::OnMoveTopID; break;
262  case OnMoveBottomID:
263  choice = TrackUtilities::OnMoveBottomID; break;
264  }
265 
266  TrackUtilities::DoMoveTrack(*project, mpData->pTrack, choice);
267 
268  // MoveTrack already refreshed TrackPanel, which means repaint will happen.
269  // This is a harmless redundancy:
271 }

References TrackUtilities::DoMoveTrack(), mpData, OnMoveBottomID, TrackUtilities::OnMoveBottomID, OnMoveDownID, TrackUtilities::OnMoveDownID, OnMoveTopID, TrackUtilities::OnMoveTopID, OnMoveUpID, TrackUtilities::OnMoveUpID, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, RefreshCode::RefreshAll, and CommonTrackControls::InitMenuData::result.

Here is the call graph for this function:

◆ OnSetName()

void TrackMenuTable::OnSetName ( wxCommandEvent &  )
private

Definition at line 221 of file CommonTrackControls.cpp.

222 {
223  Track *const pTrack = mpData->pTrack;
224  if (pTrack)
225  {
226  AudacityProject *const proj = &mpData->project;
227  const wxString oldName = pTrack->GetName();
228 
230  Command.mName = oldName;
231  // Bug 1837 : We need an OK/Cancel result if we are to enter a blank string.
232  bool bResult = Command.PromptUser( &GetProjectFrame( *proj ) );
233  if (bResult)
234  {
235  wxString newName = Command.mName;
236  for (auto channel : TrackList::Channels(pTrack))
237  channel->SetName(newName);
238 
239  ProjectHistory::Get( *proj )
240  .PushState(
241  XO("Renamed '%s' to '%s'").Format( oldName, newName ),
242  XO("Name Change"));
243 
245  }
246  }
247 }

References TrackList::Channels(), MenuTable::Command(), ProjectHistory::Get(), Track::GetName(), GetProjectFrame(), mpData, CommonTrackControls::InitMenuData::project, CommonTrackControls::InitMenuData::pTrack, ProjectHistory::PushState(), RefreshCode::RefreshAll, CommonTrackControls::InitMenuData::result, and XO.

Here is the call graph for this function:

◆ UpdatePrefs()

void TrackMenuTable::UpdatePrefs ( )
inlineoverrideprivatevirtual

Implements PrefsListener.

Definition at line 102 of file CommonTrackControls.cpp.

103  {
104  // Because labels depend on keyboard preferences
106  }

References PopupMenuTable::Clear().

Here is the call graph for this function:

Member Data Documentation

◆ mpData

CommonTrackControls::InitMenuData* TrackMenuTable::mpData {}
private

Definition at line 100 of file CommonTrackControls.cpp.

Referenced by InitUserData(), OnMoveTrack(), and OnSetName().


The documentation for this class was generated from the following file:
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
Track::GetName
wxString GetName() const
Definition: Track.h:423
PopupMenuTable
Definition: PopupMenuTable.h:115
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1505
Format
Abstract base class used in importing a file.
XO
#define XO(s)
Definition: Internat.h:31
TrackUtilities::OnMoveDownID
@ OnMoveDownID
Definition: TrackUtilities.h:20
CommonTrackControls::InitMenuData::result
unsigned result
Definition: CommonTrackControls.h:39
CommonTrackControls::InitMenuData::project
AudacityProject & project
Definition: CommonTrackControls.h:36
TrackUtilities::MoveChoice
MoveChoice
Definition: TrackUtilities.h:19
OnMoveTopID
@ OnMoveTopID
Definition: CommonTrackControls.cpp:78
OnMoveUpID
@ OnMoveUpID
Definition: CommonTrackControls.cpp:76
TrackUtilities::OnMoveTopID
@ OnMoveTopID
Definition: TrackUtilities.h:20
CommonTrackControls::InitMenuData
Definition: CommonTrackControls.h:34
TrackMenuTable::mpData
CommonTrackControls::InitMenuData * mpData
Definition: CommonTrackControls.cpp:100
PopupMenuTable::Clear
void Clear()
Definition: PopupMenuTable.h:155
TrackMenuTable
Definition: CommonTrackControls.cpp:85
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
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
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition: ProjectWindows.cpp:72
TrackUtilities::OnMoveBottomID
@ OnMoveBottomID
Definition: TrackUtilities.h:20
TrackUtilities::OnMoveUpID
@ OnMoveUpID
Definition: TrackUtilities.h:20
OnMoveBottomID
@ OnMoveBottomID
Definition: CommonTrackControls.cpp:79
OnMoveDownID
@ OnMoveDownID
Definition: CommonTrackControls.cpp:77
CommonTrackControls::InitMenuData::pTrack
Track * pTrack
Definition: CommonTrackControls.h:37
TrackUtilities::DoMoveTrack
void DoMoveTrack(AudacityProject &project, Track *target, MoveChoice choice)
Move a track up, down, to top or to bottom.
Definition: TrackUtilities.cpp:199
SetTrackNameCommand
Definition: CommonTrackControls.cpp:189
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26