1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

refactor the construction of the track pop-down menu into a function to avoid repeating the code multiple times to do the same thing. This makes extending the track pop-down menu, and eventually breaking this class up, much easier

This commit is contained in:
RichardAsh1981@gmail.com 2013-10-30 22:07:06 +00:00
parent 398b5153c7
commit be4f39c9c7
2 changed files with 27 additions and 20 deletions

View File

@ -645,12 +645,9 @@ void TrackPanel::BuildMenus(void)
mFormatMenu->AppendCheckItem(On24BitID, GetSampleFormatStr(int24Sample));
mFormatMenu->AppendCheckItem(OnFloatID, GetSampleFormatStr(floatSample));
/* build the pop-down menu used on wave (sampled audio) tracks */
mWaveTrackMenu = new wxMenu();
mWaveTrackMenu->Append(OnSetNameID, _("N&ame..."));
mWaveTrackMenu->AppendSeparator();
mWaveTrackMenu->Append(OnMoveUpID, _("Move Track U&p"));
mWaveTrackMenu->Append(OnMoveDownID, _("Move Track &Down"));
mWaveTrackMenu->AppendSeparator();
BuildCommonDropMenuItems(mWaveTrackMenu); // does name, up/down etc
mWaveTrackMenu->Append(OnWaveformID, _("Wa&veform"));
mWaveTrackMenu->Append(OnWaveformDBID, _("Waveform (d&B)"));
mWaveTrackMenu->Append(OnSpectrumID, _("&Spectrogram"));
@ -669,29 +666,20 @@ void TrackPanel::BuildMenus(void)
mWaveTrackMenu->AppendSeparator();
mWaveTrackMenu->Append(0, _("Set Rat&e"), mRateMenu);
/* build the pop-down menu used on note (MIDI) tracks */
mNoteTrackMenu = new wxMenu();
mNoteTrackMenu->Append(OnSetNameID, _("N&ame..."));
mNoteTrackMenu->AppendSeparator();
mNoteTrackMenu->Append(OnMoveUpID, _("Move Track U&p"));
mNoteTrackMenu->Append(OnMoveDownID, _("Move Track &Down"));
mNoteTrackMenu->AppendSeparator();
BuildCommonDropMenuItems(mNoteTrackMenu); // does name, up/down etc
mNoteTrackMenu->Append(OnUpOctaveID, _("Up &Octave"));
mNoteTrackMenu->Append(OnDownOctaveID, _("Down Octa&ve"));
/* build the pop-down menu used on label tracks */
mLabelTrackMenu = new wxMenu();
mLabelTrackMenu->Append(OnSetNameID, _("N&ame..."));
mLabelTrackMenu->AppendSeparator();
BuildCommonDropMenuItems(mLabelTrackMenu); // does name, up/down etc
mLabelTrackMenu->Append(OnSetFontID, _("&Font..."));
mLabelTrackMenu->AppendSeparator();
mLabelTrackMenu->Append(OnMoveUpID, _("Move Track U&p"));
mLabelTrackMenu->Append(OnMoveDownID, _("Move Track &Down"));
/* build the pop-down menu used on time warping tracks */
mTimeTrackMenu = new wxMenu();
mTimeTrackMenu->Append(OnSetNameID, _("N&ame..."));
mTimeTrackMenu->AppendSeparator();
mTimeTrackMenu->Append(OnMoveUpID, _("Move Track U&p"));
mTimeTrackMenu->Append(OnMoveDownID, _("Move Track &Down"));
mTimeTrackMenu->AppendSeparator();
BuildCommonDropMenuItems(mTimeTrackMenu); // does name, up/down etc
mTimeTrackMenu->Append(OnTimeTrackLinID, _("&Linear"));
mTimeTrackMenu->Append(OnTimeTrackLogID, _("L&ogarithmic"));
mTimeTrackMenu->AppendSeparator();
@ -704,6 +692,16 @@ void TrackPanel::BuildMenus(void)
mLabelTrackInfoMenu->Append(OnPasteSelectedTextID, _("Paste"));
}
void TrackPanel::BuildCommonDropMenuItems(wxMenu * menu)
{
menu->Append(OnSetNameID, _("N&ame..."));
menu->AppendSeparator();
menu->Append(OnMoveUpID, _("Move Track U&p"));
menu->Append(OnMoveDownID, _("Move Track &Down"));
menu->AppendSeparator();
}
void TrackPanel::DeleteMenus(void)
{
// Note that the submenus (mRateMenu, ...)

View File

@ -181,6 +181,7 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
virtual ~ TrackPanel();
virtual void BuildMenus(void);
virtual void DeleteMenus(void);
virtual void UpdatePrefs();
@ -270,6 +271,14 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
protected:
virtual MixerBoard* GetMixerBoard();
/** @brief Populates the track pop-down menu with the common set of
* initial items.
*
* Ensures that all pop-down menus start with Name, and the commands for moving
* the track around, via a single set of code.
* @param menu the menu to add the commands to.
*/
virtual void BuildCommonDropMenuItems(wxMenu * menu);
virtual bool IsUnsafe();
virtual bool HandleLabelTrackMouseEvent(LabelTrack * lTrack, wxRect &r, wxMouseEvent & event);
virtual bool HandleTrackLocationMouseEvent(WaveTrack * track, wxRect &r, wxMouseEvent &event);