1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Implement scrolling for the note track vertical ruler

Command zooms in/out, and shift moves up and down.
This commit is contained in:
Pokechu22
2017-06-30 00:02:51 -07:00
committed by Paul Licameli
parent 58bd03419a
commit 0e21143cee
3 changed files with 41 additions and 6 deletions

View File

@@ -203,11 +203,42 @@ HitTestResult NoteTrackVRulerControls::HitTest
(const TrackPanelMouseEvent &evt,
const AudacityProject *)
{
#ifdef USE_MIDI
return NoteTrackVZoomHandle::HitTest(evt.event);
#else
return {};
#endif
}
#endif
unsigned NoteTrackVRulerControls::HandleWheelRotation
(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
{
using namespace RefreshCode;
const wxMouseEvent &event = evt.event;
if (!(event.ShiftDown() || event.CmdDown()))
return RefreshNone;
// Always stop propagation even if the ruler didn't change. The ruler
// is a narrow enough target.
evt.event.Skip(false);
const auto pTrack = FindTrack();
if (!pTrack)
return RefreshNone;
wxASSERT(pTrack->GetKind() == Track::Note);
auto steps = evt.steps;
const auto nt = static_cast<NoteTrack*>(pTrack.get());
if (event.CmdDown() && !event.ShiftDown()) {
nt->Zoom(evt.rect, evt.event.m_y, (int) (steps));
} else if (!event.CmdDown() && event.ShiftDown()) {
// Scroll some fixed number of notes, independent of zoom level or track height:
static const int movement = 6; // 6 semitones is half an octave
nt->SetBottomNote(nt->GetBottomNote() + (int) (steps * movement));
} else {
return RefreshNone;
}
pProject->ModifyState(true);
return RefreshCell | UpdateVRuler;
}
#endif

View File

@@ -27,6 +27,10 @@ public:
HitTestResult HitTest
(const TrackPanelMouseEvent &event,
const AudacityProject *pProject) override;
unsigned HandleWheelRotation
(const TrackPanelMouseEvent &event,
AudacityProject *pProject) override;
};
#endif