From 413edf2820a861737efc920df97d8d9d82e4987e Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 21 Jun 2015 22:44:55 -0400 Subject: [PATCH 1/3] Cascade the four move commands of the track control menu... ... Note that "M" accelarator conflicts for now with "Mono" for wave tracks, but there is no conflict with time and label tracks. --- src/TrackPanel.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 8b8db3c70..2d01d5a71 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -156,6 +156,9 @@ is time to refresh some aspect of the screen. *//*****************************************************************/ +// This conditional compilation switch does not need to be seen +// in any other file, so I define it here, not in Experimental.h -- PRL +#define EXPERIMENTAL_CASCADE_TCP_MENU #include "Audacity.h" #include "Experimental.h" @@ -781,12 +784,34 @@ void TrackPanel::BuildCommonDropMenuItems(wxMenu * menu) { menu->Append(OnSetNameID, _("N&ame...")); menu->AppendSeparator(); - menu->Append(OnMoveUpID, _("Move Track &Up")); - menu->Append(OnMoveDownID, _("Move Track &Down")); - menu->Append(OnMoveTopID, _("Move Track to &Top")); - menu->Append(OnMoveBottomID, _("Move Track to &Bottom")); - menu->AppendSeparator(); + wxMenu *theMenu; +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + wxMenu *const moveMenu = new wxMenu(); + menu->Append(0, _("&Move"), moveMenu); + theMenu = moveMenu; + wxString names[] = { + _("&Up"), + _("&Down"), + _("To &Top"), + _("To &Bottom"), + }; +#else + theMenu = menu; + wxString names[] = { + _("Move Track &Up"), + _("Move Track &Down"), + _("Move Track to &Top"), + _("Move Track to &Bottom"), + }; +#endif + + theMenu->Append(OnMoveUpID, names[0]); + theMenu->Append(OnMoveDownID, names[1]); + theMenu->Append(OnMoveTopID, names[2]); + theMenu->Append(OnMoveBottomID, names[3]); + + menu->AppendSeparator(); } // static From cc08bba27a8ae4c6d30387c13f35a8edd434e663 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 15 Jun 2015 19:38:19 -0400 Subject: [PATCH 2/3] Make a Channels sub-menu, and change accelerators to be more mnemonic... ... Also removes the conflict at top menu level over M accelerator. Make one Channel sub-menu for mono and one for stereo, and swap correct one in, whenever the parent menu opens. --- src/TrackPanel.cpp | 112 ++++++++++++++++++++++++++++++++++++--------- src/TrackPanel.h | 4 ++ 2 files changed, 94 insertions(+), 22 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 2d01d5a71..4e52a34f1 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -339,6 +339,8 @@ enum { OnTimeTrackLogID, OnTimeTrackLogIntID, + ChannelMenuID, + // Reserve an ample block of ids for waveform scale types OnFirstWaveformScaleID, OnLastWaveformScaleID = OnFirstWaveformScaleID + 9, @@ -559,6 +561,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, mNoteTrackMenu = NULL; mLabelTrackMenu = NULL; mTimeTrackMenu = NULL; + mHiddenChannelMenu = mChannelMenuMono = mChannelMenuStereo = NULL; mRulerWaveformMenu = mRulerSpectrumMenu = NULL; @@ -737,14 +740,49 @@ void TrackPanel::BuildMenus(void) mWaveTrackMenu->Append(OnViewSettingsID, _("&View Settings...")); mWaveTrackMenu->AppendSeparator(); - mWaveTrackMenu->AppendRadioItem(OnChannelMonoID, _("&Mono")); - mWaveTrackMenu->AppendRadioItem(OnChannelLeftID, _("&Left Channel")); - mWaveTrackMenu->AppendRadioItem(OnChannelRightID, _("&Right Channel")); - mWaveTrackMenu->Append(OnMergeStereoID, _("Ma&ke Stereo Track")); - mWaveTrackMenu->Append(OnSwapChannelsID, _("Swap Stereo &Channels")); - mWaveTrackMenu->Append(OnSplitStereoID, _("Spl&it Stereo Track")); - mWaveTrackMenu->Append(OnSplitStereoMonoID, _("Split Stereo to Mo&no")); + // Handle the channels items + { +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + mChannelMenuMono = new wxMenu(); + mChannelMenuStereo = new wxMenu(); + mHiddenChannelMenu = mChannelMenuMono; + mWaveTrackMenu->Append(ChannelMenuID, _("&Channels"), mChannelMenuStereo); + wxString names[] = { + _("&Mono"), + _("&Left"), + _("&Right"), + _("Make &Stereo"), + + _("S&wap"), + _("S&plit"), + _("Split to &Mono"), + }; +#else + mChannelMenuMono = mChannelMenuStereo = mWaveTrackMenu; + mHiddenChannelMenu = NULL; + wxString names[] = { + _("&Mono"), + _("&Left Channel"), + _("&Right Channel"), + _("Ma&ke Stereo Track"), + + _("Swap Stereo &Channels"), + _("Spl&it Stereo Track"), + _("Split Stereo to Mo&no"), + }; +#endif + + mChannelMenuMono->AppendRadioItem(OnChannelMonoID, names[0]); + mChannelMenuMono->AppendRadioItem(OnChannelLeftID, names[1]); + mChannelMenuMono->AppendRadioItem(OnChannelRightID, names[2]); + mChannelMenuMono->Append(OnMergeStereoID, names[3]); + + mChannelMenuStereo->Append(OnSwapChannelsID, names[4]); + mChannelMenuStereo->Append(OnSplitStereoID, names[5]); + mChannelMenuStereo->Append(OnSplitStereoMonoID, names[6]); + } mWaveTrackMenu->AppendSeparator(); + mWaveTrackMenu->Append(0, _("Set Sample &Format"), mFormatMenu); mWaveTrackMenu->AppendSeparator(); mWaveTrackMenu->Append(0, _("Set Rat&e"), mRateMenu); @@ -831,6 +869,13 @@ void TrackPanel::DeleteMenus(void) { // Note that the submenus (mRateMenu, ...) // are deleted by their parent + + // ... except for this special swapping of the Channel sub-menus. + // One of them is not managed by the main popup menu. + if (mHiddenChannelMenu) + delete mHiddenChannelMenu; + mHiddenChannelMenu = mChannelMenuMono = mChannelMenuStereo = NULL; + if (mWaveTrackMenu) { delete mWaveTrackMenu; mWaveTrackMenu = NULL; @@ -8349,7 +8394,6 @@ void TrackPanel::OnTrackMenu(Track *t) mPopupMenuTarget = t; - bool canMakeStereo = false; Track *next = mTracks->GetNext(t); wxMenu *theMenu = NULL; @@ -8365,31 +8409,55 @@ void TrackPanel::OnTrackMenu(Track *t) if (t->GetKind() == Track::Wave) { theMenu = mWaveTrackMenu; - if (next && !t->GetLinked() && !next->GetLinked() - && t->GetKind() == Track::Wave - && next->GetKind() == Track::Wave) - canMakeStereo = true; - theMenu->Enable(OnSwapChannelsID, t->GetLinked()); - theMenu->Enable(OnMergeStereoID, canMakeStereo); - theMenu->Enable(OnSplitStereoID, t->GetLinked()); - theMenu->Enable(OnSplitStereoMonoID, t->GetLinked()); + const bool isMono = !t->GetLinked(); + wxMenu *const correctSubMenu = + isMono ? mChannelMenuMono : mChannelMenuStereo; + + const bool canMakeStereo = isMono && + (next && !next->GetLinked() + && t->GetKind() == Track::Wave + && next->GetKind() == Track::Wave); + mChannelMenuMono->Enable(OnMergeStereoID, canMakeStereo); // We only need to set check marks. Clearing checks causes problems on Linux (bug 851) switch (t->GetChannel()) { case Track::LeftChannel: - theMenu->Check(OnChannelLeftID, true); + mChannelMenuMono->Check(OnChannelLeftID, true); break; case Track::RightChannel: - theMenu->Check(OnChannelRightID, true); + mChannelMenuMono->Check(OnChannelRightID, true); break; default: - theMenu->Check(OnChannelMonoID, true); + mChannelMenuMono->Check(OnChannelMonoID, true); } - theMenu->Enable(OnChannelMonoID, !t->GetLinked()); - theMenu->Enable(OnChannelLeftID, !t->GetLinked()); - theMenu->Enable(OnChannelRightID, !t->GetLinked()); +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + // Swap in appropriate Channels sub-menu. + if (correctSubMenu == mHiddenChannelMenu) { + wxMenu *const otherSubMenu = + isMono ? mChannelMenuStereo : mChannelMenuMono; + size_t position; + wxMenuItem *const pItem = + theMenu->FindChildItem(ChannelMenuID, &position); + wxASSERT(pItem->GetSubMenu() == otherSubMenu); + theMenu->Remove(pItem); + pItem->SetSubMenu(0); + delete pItem; + theMenu->Insert(position, ChannelMenuID, + isMono ? _("&Channel") : _("&Channels"), + correctSubMenu); + mHiddenChannelMenu = otherSubMenu; + } +#else + mChannelMenuStereo->Enable(OnSwapChannelsID, !isMono); + mChannelMenuStereo->Enable(OnSplitStereoID, !isMono); + mChannelMenuStereo->Enable(OnSplitStereoMonoID, !isMono); + + mChannelMenuMono->Enable(OnChannelMonoID, isMono); + mChannelMenuMono->Enable(OnChannelLeftID, isMono); + mChannelMenuMono->Enable(OnChannelRightID, isMono); +#endif const int display = static_cast(t)->GetDisplay(); theMenu->Check( diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 9603c4b54..aeb484f8f 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -830,6 +830,10 @@ protected: wxMenu *mRulerWaveformMenu; wxMenu *mRulerSpectrumMenu; + wxMenu *mChannelMenuMono; + wxMenu *mChannelMenuStereo; + wxMenu *mHiddenChannelMenu; + Track *mPopupMenuTarget; friend class TrackPanelAx; From 47e1df2525d1b001f3e6b4bf2f62329864f6a095 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 21 Jun 2015 22:45:37 -0400 Subject: [PATCH 3/3] Shorten remaining names in Wave Track Control menu, change accelerators.... ... also changed "Set Range" in Time track to R to avoid conflict --- src/TrackPanel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 4e52a34f1..c1c221466 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -783,9 +783,19 @@ void TrackPanel::BuildMenus(void) } mWaveTrackMenu->AppendSeparator(); +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + mWaveTrackMenu->Append(0, _("&Format"), mFormatMenu); +#else mWaveTrackMenu->Append(0, _("Set Sample &Format"), mFormatMenu); +#endif + mWaveTrackMenu->AppendSeparator(); + +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + mWaveTrackMenu->Append(0, _("&Rate"), mRateMenu); +#else mWaveTrackMenu->Append(0, _("Set Rat&e"), mRateMenu); +#endif /* build the pop-down menu used on note (MIDI) tracks */ mNoteTrackMenu = new wxMenu(); @@ -804,7 +814,11 @@ void TrackPanel::BuildMenus(void) mTimeTrackMenu->Append(OnTimeTrackLinID, _("&Linear")); mTimeTrackMenu->Append(OnTimeTrackLogID, _("L&ogarithmic")); mTimeTrackMenu->AppendSeparator(); +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + mTimeTrackMenu->Append(OnSetTimeTrackRangeID, _("Set &Range...")); +#else mTimeTrackMenu->Append(OnSetTimeTrackRangeID, _("Set Ra&nge...")); +#endif mTimeTrackMenu->AppendCheckItem(OnTimeTrackLogIntID, _("Logarithmic &Interpolation")); mRulerWaveformMenu = new wxMenu(); @@ -820,7 +834,11 @@ void TrackPanel::BuildMenus(void) void TrackPanel::BuildCommonDropMenuItems(wxMenu * menu) { +#ifdef EXPERIMENTAL_CASCADE_TCP_MENU + menu->Append(OnSetNameID, _("&Name...")); +#else menu->Append(OnSetNameID, _("N&ame...")); +#endif menu->AppendSeparator(); wxMenu *theMenu;