Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Command: [Next/Previous Staff] without traversing voices. #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2416,6 +2416,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 @@ -1128,6 +1128,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 @@ -1191,6 +1198,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
Loading