Skip to content

Commit

Permalink
change alt-up/down to move by chord and track
Browse files Browse the repository at this point in the history
First move through current chord on current track, then move up and down
by track.
  • Loading branch information
MarcSabatella committed Aug 3, 2013
1 parent d9d6472 commit c2225d7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 66 deletions.
97 changes: 41 additions & 56 deletions libmscore/navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rest*>(element)->tick(), _is.track());
Rest* rest = static_cast<Rest*>(element);
re = prevTrack(rest);
}
else if (element->type() == Element::NOTE) {
// find segment
Chord* chord = static_cast<Note*>(element)->chord();
Segment* segment = chord->segment();

// collect all notes for this segment in noteList:
QList<Note*> 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<Chord*>(el)->notes());
qSort(rnl.begin(), rnl.end(), noteLessThan);
int idx = rnl.indexOf(static_cast<Note*>(element));
if (idx < rnl.size()-1)
++idx;
re = rnl.value(idx);
Chord* chord = static_cast<Note*>(element)->chord();
QList<Note*> notes = chord->notes();
// qSort(notes.begin(), notes.end(), noteLessThan);
int idx = notes.indexOf(static_cast<Note*>(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;
}

//---------------------------------------------------------
Expand All @@ -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<Rest*>(element)->tick(), _is.track());
Rest* rest = static_cast<Rest*>(element);
re = nextTrack(rest);
}
else if (element->type() == Element::NOTE) {
// find segment
Chord* chord = static_cast<Note*>(element)->chord();
Segment* segment = chord->segment();

// collect all notes for this segment in noteList:
QList<Note*> 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<Chord*>(el)->notes());
qSort(rnl.begin(), rnl.end(), noteLessThan);
int idx = rnl.indexOf(static_cast<Note*>(element));
if (idx)
--idx;
re = rnl.value(idx);
Chord* chord = static_cast<Note*>(element)->chord();
QList<Note*> notes = chord->notes();
// qSort(notes.begin(), notes.end(), noteLessThan);
int idx = notes.indexOf(static_cast<Note*>(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<Chord*>(re)->notes().back();
return (Note*)re;
re = ((Chord*)re)->notes().back();
return (ChordRest*)re;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -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
//---------------------------------------------------------

Expand Down Expand Up @@ -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
//---------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions mscore/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@
<key>pitch-up-octave</key>
<seq>Ctrl+Up</seq>
</SC>
<SC>
<key>up-chord</key>
<seq>Alt+Up</seq>
</SC>
<SC>
<key>top-chord</key>
<seq>Ctrl+Alt+Up</seq>
Expand All @@ -272,6 +276,10 @@
<key>pitch-down-octave</key>
<seq>Ctrl+Down</seq>
</SC>
<SC>
<key>down-chord</key>
<seq>Alt+Down</seq>
</SC>
<SC>
<key>bottom-chord</key>
<seq>Ctrl+Alt+Down</seq>
Expand All @@ -284,10 +292,6 @@
<key>prev-chord</key>
<seq>Left</seq>
</SC>
<SC>
<key>prev-track</key>
<seq>Alt+Up</seq>
</SC>
<SC>
<key>prev-measure</key>
<seq>Ctrl+Left</seq>
Expand All @@ -296,10 +300,6 @@
<key>next-chord</key>
<seq>Right</seq>
</SC>
<SC>
<key>next-track</key>
<seq>Alt+Down</seq>
</SC>
<SC>
<key>next-measure</key>
<seq>Ctrl+Right</seq>
Expand Down

0 comments on commit c2225d7

Please sign in to comment.