1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

Move code for Note track menu items

This commit is contained in:
Paul Licameli 2015-07-31 19:36:42 -04:00 committed by Paul Licameli
parent 01d5d30b7e
commit ba5f6ce411
3 changed files with 35 additions and 37 deletions

View File

@ -286,9 +286,6 @@ template < class CLIPPEE, class CLIPVAL >
enum {
TrackPanelFirstID = 2000,
OnUpOctaveID,
OnDownOctaveID,
OnChannelLeftID,
OnChannelRightID,
OnChannelMonoID,
@ -346,7 +343,6 @@ BEGIN_EVENT_TABLE(TrackPanel, OverlayPanel)
EVT_KILL_FOCUS(TrackPanel::OnKillFocus)
EVT_CONTEXT_MENU(TrackPanel::OnContextMenu)
EVT_MENU_RANGE(OnUpOctaveID, OnDownOctaveID, TrackPanel::OnChangeOctave)
EVT_MENU_RANGE(OnChannelLeftID, OnChannelMonoID,
TrackPanel::OnChannelChange)
EVT_MENU_RANGE(OnWaveformID, OnSpectrumID, TrackPanel::OnSetDisplay)
@ -471,8 +467,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
mWaveTrackMenu = NULL;
mChannelItemsInsertionPoint = 0;
mNoteTrackMenu = NULL;
mTrackArtist = std::make_unique<TrackArtist>();
mTrackArtist->SetMargins(1, kTopMargin, kRightMargin, kBottomMargin);
@ -626,11 +620,6 @@ void TrackPanel::BuildMenus(void)
mWaveTrackMenu->Append(0, _("Rat&e"), (mRateMenu = rateMenu.release()));
/* build the pop-down menu used on note (MIDI) tracks */
mNoteTrackMenu = std::make_unique<wxMenu>();
mNoteTrackMenu->Append(OnUpOctaveID, _("Up &Octave"));
mNoteTrackMenu->Append(OnDownOctaveID, _("Down Octa&ve"));
/*
mRulerWaveformMenu = std::make_unique<wxMenu>();
BuildVRulerMenuItems
@ -668,7 +657,6 @@ void TrackPanel::DeleteMenus(void)
mRateMenu = mFormatMenu = nullptr;
mWaveTrackMenu.reset();
mNoteTrackMenu.reset();
mRulerWaveformMenu.reset();
mRulerSpectrumMenu.reset();
}
@ -5984,11 +5972,6 @@ void TrackPanel::OnTrackMenu(Track *t)
}
}
#if defined(USE_MIDI)
if (t->GetKind() == Track::Note)
theMenu = mNoteTrackMenu.get();
#endif
if (theMenu) {
//We need to find the location of the menu rectangle.
const wxRect rect = FindTrackRect(t,true);
@ -6771,24 +6754,6 @@ void TrackPanel::OnZoomFitVertical(wxCommandEvent &)
HandleWaveTrackVZoom(static_cast<WaveTrack*>(mPopupMenuTarget), true, true);
}
/// This only applies to MIDI tracks. Presumably, it shifts the
/// whole sequence by an octave.
void TrackPanel::OnChangeOctave(wxCommandEvent & event)
{
#if defined(USE_MIDI)
wxASSERT(event.GetId() == OnUpOctaveID
|| event.GetId() == OnDownOctaveID);
wxASSERT(mPopupMenuTarget->GetKind() == Track::Note);
NoteTrack *t = (NoteTrack *) mPopupMenuTarget;
bool bDown = (OnDownOctaveID == event.GetId());
t->SetBottomNote(t->GetBottomNote() + ((bDown) ? -12 : 12));
MakeParentModifyState(true);
Refresh(false);
#endif
}
/// Determines which cell is under the mouse
/// @param mouseX - mouse X position.
/// @param mouseY - mouse Y position.

View File

@ -489,7 +489,6 @@ protected:
virtual void MakeParentModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
virtual void OnChangeOctave (wxCommandEvent &event);
virtual void OnChannelChange(wxCommandEvent &event);
virtual void OnSpectrogramSettings(wxCommandEvent &event);
virtual void OnSetDisplay (wxCommandEvent &event);
@ -794,7 +793,6 @@ protected:
size_t mChannelItemsInsertionPoint {};
std::unique_ptr<wxMenu>
mNoteTrackMenu,
mRulerWaveformMenu, mRulerSpectrumMenu;
// These sub-menus are owned by parent menus,

View File

@ -21,6 +21,8 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../../TrackPanelMouseEvent.h"
#include "../../../../NoteTrack.h"
#include "../../../../widgets/PopupMenuTable.h"
#include "../../../../Project.h"
#include "../../../../RefreshCode.h"
NoteTrackControls::NoteTrackControls()
{
@ -85,6 +87,8 @@ public:
}
TrackControls::InitMenuData *mpData;
void OnChangeOctave(wxCommandEvent &);
};
NoteTrackMenuTable &NoteTrackMenuTable::Instance()
@ -93,12 +97,43 @@ NoteTrackMenuTable &NoteTrackMenuTable::Instance()
return instance;
}
enum {
OnUpOctaveID = 30000,
OnDownOctaveID,
};
/// This only applies to MIDI tracks. Presumably, it shifts the
/// whole sequence by an octave.
void NoteTrackMenuTable::OnChangeOctave(wxCommandEvent &event)
{
NoteTrack *const pTrack = static_cast<NoteTrack*>(mpData->pTrack);
wxASSERT(event.GetId() == OnUpOctaveID
|| event.GetId() == OnDownOctaveID);
wxASSERT(pTrack->GetKind() == Track::Note);
const bool bDown = (OnDownOctaveID == event.GetId());
pTrack->SetBottomNote
(pTrack->GetBottomNote() + ((bDown) ? -12 : 12));
AudacityProject *const project = ::GetActiveProject();
project->ModifyState(true);
mpData->result = RefreshCode::RefreshAll;
}
BEGIN_POPUP_MENU(NoteTrackMenuTable)
POPUP_MENU_SEPARATOR()
POPUP_MENU_ITEM(OnUpOctaveID, _("Up &Octave"), OnChangeOctave)
POPUP_MENU_ITEM(OnDownOctaveID, _("Down Octa&ve"), OnChangeOctave)
END_POPUP_MENU()
PopupMenuTable *NoteTrackControls::GetMenuExtension(Track *)
{
#if defined(USE_MIDI)
return &NoteTrackMenuTable::Instance();
#else
return NULL;
#endif
}
#endif