Skip to content

Commit

Permalink
Merge pull request #41 from worldwideweary/3.x-www-0019-CommandNextPr…
Browse files Browse the repository at this point in the history
…evStaff

New Command: [Next/Previous Staff] without traversing voices.
  • Loading branch information
worldwideweary committed Oct 1, 2024
2 parents f567a17 + 05d267c commit ecbbbb7
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
10 changes: 10 additions & 0 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,16 @@ Element* Score::move(const QString& cmd)
if (noteEntryMode())
_is.moveInputPos(el);
}
else if (cmd == "next-staff" && cr) {
el = nextTrack(cr, true);
if (noteEntryMode())
_is.moveInputPos(el);
}
else if (cmd == "prev-staff" && cr) {
el = prevTrack(cr, true);
if (noteEntryMode())
_is.moveInputPos(el);
}
else if (cmd == "top-staff") {
el = cr ? cmdTopStaff(cr) : cmdTopStaff();
if (noteEntryMode())
Expand Down
23 changes: 18 additions & 5 deletions libmscore/navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ ChordRest* Score::downStaff(ChordRest* cr)
// that contains such an element
//---------------------------------------------------------

ChordRest* Score::nextTrack(ChordRest* cr)
ChordRest* Score::nextTrack(ChordRest* cr, bool skipVoices)
{
if (!cr)
return 0;
Expand All @@ -452,9 +452,16 @@ ChordRest* Score::nextTrack(ChordRest* cr)
while (!el) {
// find next non-empty track
while (++track < tracks) {
if (measure->hasVoice(track))
if (skipVoices) {
// Disregard voices and directly refer to next staff
if ((track % 4) != 0)
continue;
break;
}
else if (measure->hasVoice(track))
break;
}

// no more tracks, return original element
if (track == tracks)
return cr;
Expand All @@ -475,7 +482,7 @@ ChordRest* Score::nextTrack(ChordRest* cr)
// that contains such an element
//---------------------------------------------------------

ChordRest* Score::prevTrack(ChordRest* cr)
ChordRest* Score::prevTrack(ChordRest* cr, bool skipVoices)
{
if (!cr)
return 0;
Expand All @@ -486,8 +493,14 @@ ChordRest* Score::prevTrack(ChordRest* cr)

while (!el) {
// find next non-empty track
while (--track >= 0){
if (measure->hasVoice(track))
while (--track >= 0) {
if (skipVoices) {
// Disregard voices and directly refer to previous staff
if ((track % 4) != 0)
continue;
break;
}
else if (measure->hasVoice(track))
break;
}
// no more tracks, return original element
Expand Down
4 changes: 2 additions & 2 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ class Score : public QObject, public ScoreElement {
Note* getSelectedNote();
ChordRest* upStaff(ChordRest* cr);
ChordRest* downStaff(ChordRest* cr);
ChordRest* nextTrack(ChordRest* cr);
ChordRest* prevTrack(ChordRest* cr);
ChordRest* nextTrack(ChordRest* cr, bool skipVoices=false);
ChordRest* prevTrack(ChordRest* cr, bool skipVoices=false);

void padToggle(Pad p, const EditData& ed);
void addTempo();
Expand Down
2 changes: 2 additions & 0 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,8 @@ void ScoreView::cmd(const char* s)
"prev-chord",
"next-track",
"prev-track",
"next-staff",
"prev-staff",
"next-measure",
"prev-measure",
"next-system",
Expand Down
14 changes: 14 additions & 0 deletions mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,13 @@ Shortcut Shortcut::_sc[] = {
QT_TRANSLATE_NOOP("action","Previous Staff or Voice"),
QT_TRANSLATE_NOOP("action","Previous staff or voice")
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY,
"prev-staff",
QT_TRANSLATE_NOOP("action","Previous Staff"),
QT_TRANSLATE_NOOP("action","Previous staff")
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY,
Expand Down Expand Up @@ -1198,6 +1205,13 @@ Shortcut Shortcut::_sc[] = {
QT_TRANSLATE_NOOP("action","Next Staff or Voice"),
QT_TRANSLATE_NOOP("action","Next staff or voice")
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY,
"next-staff",
QT_TRANSLATE_NOOP("action","Next Staff"),
QT_TRANSLATE_NOOP("action","Next staff")
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL,
Expand Down

0 comments on commit ecbbbb7

Please sign in to comment.