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

Static Public Member Functions

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

Private Member Functions

 FormatMenuTable ()
 
 DECLARE_POPUP_MENU (FormatMenuTable)
 
void InitMenu (Menu *pMenu, void *pUserData) override
 
void DestroyMenu () override
 
int IdOfFormat (int format)
 
void OnFormatChange (wxCommandEvent &event)
 

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 239 of file WaveTrackControls.cpp.

Constructor & Destructor Documentation

FormatMenuTable::FormatMenuTable ( )
inlineprivate

Definition at line 241 of file WaveTrackControls.cpp.

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

Member Function Documentation

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

Implements PopupMenuTable.

Definition at line 250 of file WaveTrackControls.cpp.

References WaveColorMenuTable::mpData.

251  {
252  mpData = NULL;
253  }
TrackControls::InitMenuData * mpData
int FormatMenuTable::IdOfFormat ( int  format)
private
void FormatMenuTable::InitMenu ( Menu pMenu,
void *  pUserData 
)
overrideprivatevirtual

Implements PopupMenuTable.

Definition at line 268 of file WaveTrackControls.cpp.

References GetActiveProject(), WaveTrack::GetSampleFormat(), WaveColorMenuTable::mpData, On16BitID, OnFloatID, and TrackControls::InitMenuData::pTrack.

269 {
270  mpData = static_cast<TrackControls::InitMenuData*>(pUserData);
271  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
272  auto formatId = IdOfFormat(pTrack->GetSampleFormat());
273  SetMenuChecks(*pMenu, [=](int id){ return id == formatId; });
274 
275  AudacityProject *const project = ::GetActiveProject();
276  bool unsafe = project->IsAudioActive();
277  for (int i = On16BitID; i <= OnFloatID; i++) {
278  pMenu->Enable(i, !unsafe);
279  }
280 }
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
int IdOfFormat(int format)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:146
TrackControls::InitMenuData * mpData
FormatMenuTable & FormatMenuTable::Instance ( )
static

Definition at line 262 of file WaveTrackControls.cpp.

263 {
264  static FormatMenuTable instance;
265  return instance;
266 }
void FormatMenuTable::OnFormatChange ( wxCommandEvent &  event)
private

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

Definition at line 311 of file WaveTrackControls.cpp.

References _(), WaveTrack::ConvertToSampleFormat(), RefreshCode::FixScrollbars, floatSample, GetActiveProject(), WaveTrack::GetKind(), Track::GetLink(), Track::GetName(), WaveTrack::GetSampleFormat(), GetSampleFormatStr(), int16Sample, int24Sample, WaveColorMenuTable::mpData, On16BitID, On24BitID, OnFloatID, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, TrackControls::InitMenuData::result, and Track::Wave.

312 {
313  int id = event.GetId();
314  wxASSERT(id >= On16BitID && id <= OnFloatID);
315  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
316  wxASSERT(pTrack && pTrack->GetKind() == Track::Wave);
317 
318  sampleFormat newFormat = int16Sample;
319 
320  switch (id) {
321  case On16BitID:
322  newFormat = int16Sample;
323  break;
324  case On24BitID:
325  newFormat = int24Sample;
326  break;
327  case OnFloatID:
328  newFormat = floatSample;
329  break;
330  default:
331  // ERROR -- should not happen
332  wxASSERT(false);
333  break;
334  }
335  if (newFormat == pTrack->GetSampleFormat())
336  return; // Nothing to do.
337 
338  AudacityProject *const project = ::GetActiveProject();
339  pTrack->ConvertToSampleFormat(newFormat);
340 
341  // Assume partner is wave or null
342  const auto partner = static_cast<WaveTrack*>(pTrack->GetLink());
343  if (partner)
344  partner->ConvertToSampleFormat(newFormat);
345 
346  /* i18n-hint: The strings name a track and a format */
347  project->PushState(wxString::Format(_("Changed '%s' to %s"),
348  pTrack->GetName(),
349  GetSampleFormatStr(newFormat)),
350  _("Format Change"));
351 
352  using namespace RefreshCode;
354 }
int GetKind() const override
Definition: WaveTrack.h:121
GetSampleFormatStr(int24Sample)
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
sampleFormat
Definition: Types.h:188
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void ConvertToSampleFormat(sampleFormat format)
Definition: WaveTrack.cpp:486
wxString GetName() const
Definition: Track.h:271
_("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
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:146
TrackControls::InitMenuData * mpData

Member Data Documentation

TrackControls::InitMenuData* FormatMenuTable::mpData
private

Definition at line 255 of file WaveTrackControls.cpp.


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