Skip to content

Commit

Permalink
Note Entry: Range selection will begin on current chord first. Also, …
Browse files Browse the repository at this point in the history
…Range Selections will not get "stuck" when segments don't match between staves
  • Loading branch information
worldwideweary committed Oct 3, 2024
1 parent a0017d6 commit f2d3463
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,21 +2674,44 @@ Element* Score::move(const QString& cmd)

Element* Score::selectMove(const QString& cmd)
{
ChordRest* cr;
if (selection().activeCR())
cr = selection().activeCR();
else
cr = selection().lastChordRest();
if (!cr && noteEntryMode())
ChordRest* cr = nullptr;
auto icr = inputState().cr();
auto itrack = inputState().track();
auto singleElement = selection().element();
bool noteEntryMode = inputState().noteEntryMode();

if (noteEntryMode && !icr && singleElement && singleElement->track() != itrack) {
return nullptr;
}

cr = selection().activeCR() ? selection().activeCR() : selection().lastChordRest();

if (noteEntryMode && !cr) {
cr = inputState().cr();
if (!cr)
return 0;
}

if (!cr) {
return nullptr;
}

ChordRest* el = 0;
if (cmd == "select-next-chord")
el = nextChordRest(cr, true);
else if (cmd == "select-prev-chord")
el = prevChordRest(cr, true);
bool selectSelf = noteEntryMode && !selection().isRange();
ChordRest* el = nullptr;
if (cmd == "select-next-chord") {
if (!selectSelf && !cr->nextSegmentAfterCR(SegmentType::ChordRest)) {
selectSelf = true;
}
el = selectSelf ? cr : nextChordRest(cr, true);
}
else if (cmd == "select-prev-chord") {
if (!selectSelf) {
if (auto ps = cr->segment()->prev()) {
if (auto pcr = ps->nextChordRest(cr->track())) {
if (pcr == cr && !selection().isRange()) {
selectSelf = true;
}}}
}
el = selectSelf ? cr : prevChordRest(cr, true);
}
else if (cmd == "select-next-measure")
el = nextMeasure(cr, true, true);
else if (cmd == "select-prev-measure")
Expand Down Expand Up @@ -2718,9 +2741,9 @@ Element* Score::selectMove(const QString& cmd)
el = measure->last()->nextChordRest(cr->track(), true);
}
else if (cmd == "select-staff-above")
el = upStaff(cr);
el = selectSelf ? cr : upStaff(cr);
else if (cmd == "select-staff-below")
el = downStaff(cr);
el = selectSelf ? cr : downStaff(cr);
if (el)
select(el, SelectType::RANGE, el->staffIdx());
return el;
Expand Down

0 comments on commit f2d3463

Please sign in to comment.