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:
@@ -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
|
||||
|
||||
@@ -27,6 +27,10 @@ public:
|
||||
HitTestResult HitTest
|
||||
(const TrackPanelMouseEvent &event,
|
||||
const AudacityProject *pProject) override;
|
||||
|
||||
unsigned HandleWheelRotation
|
||||
(const TrackPanelMouseEvent &event,
|
||||
AudacityProject *pProject) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user