mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-20 23:51:18 +01:00
Add support for zooming to show all notes, separate from max zoom
This is now the behavior of Zoom Reset, with Max Zoom being given the previous behavior. Shift+Right-Click alternates between the two -- it zooms to all notes, unless it currently is zoomed to all notes in which case it performs a max zoom. This fixes Bug 2093. It also fixes Bug 1815, by performing the all-notes zoom when importing a track.
This commit is contained in:
@@ -1047,6 +1047,37 @@ void NoteTrack::ZoomTo(const wxRect &rect, int start, int end)
|
||||
SetNoteRange(pitch1, pitch2);
|
||||
}
|
||||
|
||||
void NoteTrack::ZoomAllNotes()
|
||||
{
|
||||
Alg_iterator iterator( &GetSeq(), false );
|
||||
iterator.begin();
|
||||
Alg_event_ptr evt;
|
||||
|
||||
// Go through all of the notes, finding the minimum and maximum value pitches.
|
||||
bool hasNotes = false;
|
||||
int minPitch = MaxPitch;
|
||||
int maxPitch = MinPitch;
|
||||
|
||||
while (NULL != (evt = iterator.next())) {
|
||||
if (evt->is_note()) {
|
||||
int pitch = (int) evt->get_pitch();
|
||||
hasNotes = true;
|
||||
if (pitch < minPitch)
|
||||
minPitch = pitch;
|
||||
if (pitch > maxPitch)
|
||||
maxPitch = pitch;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasNotes) {
|
||||
// Semi-arbitary default values:
|
||||
minPitch = 48;
|
||||
maxPitch = 72;
|
||||
}
|
||||
|
||||
SetNoteRange(minPitch, maxPitch);
|
||||
}
|
||||
|
||||
NoteTrackDisplayData::NoteTrackDisplayData(const NoteTrack* track, const wxRect &r)
|
||||
{
|
||||
auto span = track->GetTopNote() - track->GetBottomNote() + 1; // + 1 to make sure it includes both
|
||||
|
||||
Reference in New Issue
Block a user