From c2225d7b8326729b0225b51eb4721700e2d9250d Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Fri, 2 Aug 2013 19:12:23 -0600 Subject: [PATCH] change alt-up/down to move by chord and track First move through current chord on current track, then move up and down by track. --- libmscore/navigate.cpp | 97 +++++++++++++++++---------------------- libmscore/score.h | 4 +- mscore/data/shortcuts.xml | 16 +++---- 3 files changed, 51 insertions(+), 66 deletions(-) diff --git a/libmscore/navigate.cpp b/libmscore/navigate.cpp index b068ab1ab50f..ff0101dbd61e 100644 --- a/libmscore/navigate.cpp +++ b/libmscore/navigate.cpp @@ -119,43 +119,37 @@ static bool noteLessThan(const Note* n1, const Note* n2) //--------------------------------------------------------- // upAlt -// select next higher pitched note in chord +// return next higher pitched note in chord +// move to previous track if at top of chord //--------------------------------------------------------- -Note* Score::upAlt(Element* element) +ChordRest* Score::upAlt(Element* element) { Element* re = 0; if (element->type() == Element::REST) { - if (_is.track() <= 0) - return 0; - _is.setTrack(_is.track() - 1); - re = searchNote(static_cast(element)->tick(), _is.track()); + Rest* rest = static_cast(element); + re = prevTrack(rest); } else if (element->type() == Element::NOTE) { - // find segment - Chord* chord = static_cast(element)->chord(); - Segment* segment = chord->segment(); - - // collect all notes for this segment in noteList: - QList rnl; - int tracks = nstaves() * VOICES; - for (int track = 0; track < tracks; ++track) { - Element* el = segment->element(track); - if (!el || el->type() != Element::CHORD) - continue; - rnl.append(static_cast(el)->notes()); - qSort(rnl.begin(), rnl.end(), noteLessThan); - int idx = rnl.indexOf(static_cast(element)); - if (idx < rnl.size()-1) - ++idx; - re = rnl.value(idx); + Chord* chord = static_cast(element)->chord(); + QList notes = chord->notes(); + // qSort(notes.begin(), notes.end(), noteLessThan); + int idx = notes.indexOf(static_cast(element)); + if (idx < notes.size()-1) { + ++idx; + re = notes.value(idx); + } + else { + re = prevTrack(chord); + if (re->track() == chord->track()) + re = element; } } if (re == 0) return 0; if (re->type() == Element::CHORD) re = ((Chord*)re)->notes().front(); - return (Note*)re; + return (ChordRest*)re; } //--------------------------------------------------------- @@ -170,46 +164,37 @@ Note* Score::upAltCtrl(Note* note) const //--------------------------------------------------------- // downAlt -// goto next note with lower pitch in chord or to -// top note in next staff +// return next lower pitched note in chord +// move to previous track if at bottom of chord //--------------------------------------------------------- -Note* Score::downAlt(Element* element) +ChordRest* Score::downAlt(Element* element) { Element* re = 0; - int staves = nstaves(); if (element->type() == Element::REST) { - if ((_is.track() + 1) >= staves * VOICES) - return 0; - _is.setTrack(_is.track() + 1); - re = searchNote(static_cast(element)->tick(), _is.track()); + Rest* rest = static_cast(element); + re = nextTrack(rest); } else if (element->type() == Element::NOTE) { - // find segment - Chord* chord = static_cast(element)->chord(); - Segment* segment = chord->segment(); - - // collect all notes for this segment in noteList: - QList rnl; - int tracks = nstaves() * VOICES; - for (int track = 0; track < tracks; ++track) { - Element* el = segment->element(track); - if (!el || el->type() != Element::CHORD) - continue; - rnl.append(static_cast(el)->notes()); - qSort(rnl.begin(), rnl.end(), noteLessThan); - int idx = rnl.indexOf(static_cast(element)); - if (idx) - --idx; - re = rnl.value(idx); + Chord* chord = static_cast(element)->chord(); + QList notes = chord->notes(); + // qSort(notes.begin(), notes.end(), noteLessThan); + int idx = notes.indexOf(static_cast(element)); + if (idx > 0) { + --idx; + re = notes.value(idx); + } + else { + re = nextTrack(chord); + if (re->track() == chord->track()) + re = element; } } - if (re == 0) return 0; if (re->type() == Element::CHORD) - re = static_cast(re)->notes().back(); - return (Note*)re; + re = ((Chord*)re)->notes().back(); + return (ChordRest*)re; } //--------------------------------------------------------- @@ -271,8 +256,8 @@ ChordRest* Score::downStaff(ChordRest* cr) //--------------------------------------------------------- // nextTrack -// returns note at or just previous to current (cr) position -// in next non-empty track for this measure +// returns note at or just before current (cr) position +// in next track for this measure // that contains such an element //--------------------------------------------------------- @@ -307,8 +292,8 @@ ChordRest* Score::nextTrack(ChordRest* cr) //--------------------------------------------------------- // prevTrack -// returns ChordRest at or just previous to current (cr) position -// in previous non-empty track for this measure +// returns ChordRest at or just before current (cr) position +// in previous track for this measure // that contains such an element //--------------------------------------------------------- diff --git a/libmscore/score.h b/libmscore/score.h index 49d882225fec..537adc0d0b1b 100644 --- a/libmscore/score.h +++ b/libmscore/score.h @@ -363,9 +363,9 @@ class Score : public QObject { void cmdSetBeamMode(BeamMode); void cmdFlip(); Note* getSelectedNote(); - Note* upAlt(Element*); + ChordRest* upAlt(Element*); Note* upAltCtrl(Note*) const; - Note* downAlt(Element*); + ChordRest* downAlt(Element*); Note* downAltCtrl(Note*) const; ChordRest* upStaff(ChordRest* cr); ChordRest* downStaff(ChordRest* cr); diff --git a/mscore/data/shortcuts.xml b/mscore/data/shortcuts.xml index 0289da7ec871..b5a0bf49b6c2 100644 --- a/mscore/data/shortcuts.xml +++ b/mscore/data/shortcuts.xml @@ -252,6 +252,10 @@ pitch-up-octave Ctrl+Up + + up-chord + Alt+Up + top-chord Ctrl+Alt+Up @@ -272,6 +276,10 @@ pitch-down-octave Ctrl+Down + + down-chord + Alt+Down + bottom-chord Ctrl+Alt+Down @@ -284,10 +292,6 @@ prev-chord Left - - prev-track - Alt+Up - prev-measure Ctrl+Left @@ -296,10 +300,6 @@ next-chord Right - - next-track - Alt+Down - next-measure Ctrl+Right