Skip to content
Open
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
143 changes: 106 additions & 37 deletions src/engraving/editing/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3017,32 +3017,68 @@
if (noteEntryMode()) {
m_is.moveToNextInputPos();
}
std::vector<EngravingItem*> els = selection().elements();
deselectAll();

// selection "cursor"
// find next chordrest, which might be a grace note
// this may override note input cursor
el = nextChordRest(cr);
for (EngravingItem* e : els) {
if (!e->isNote() && !e->isRest()) {
continue;
}
ChordRest* cr = nullptr;

Check warning on line 3027 in src/engraving/editing/cmd.cpp

View workflow job for this annotation

GitHub Actions / windows_x64

declaration of 'cr' hides previous local declaration
size_t noteLevel = 0;
if (e->isNote()) {
Note* n = toNote(e);
Chord* c = n->chord();
cr = toChordRest(c);
for (size_t i = 0; i < c->notes().size(); i++) {
if (c->notes()[i] == n) {
noteLevel = i;
break;
}
}
} else {
cr = toChordRest(toRest(e));
}

// Skip gap rests if we're not in note entry mode...
while (!noteEntryMode() && el && el->isRest() && toRest(el)->isGap()) {
el = nextChordRest(toChordRest(el));
}
if (el && noteEntryMode()) {
// do not use if not in original or new measure (don't skip measures)
Measure* m = toChordRest(el)->measure();
Segment* nis = m_is.segment();
Measure* nim = nis ? nis->measure() : nullptr;
if (m != oim && m != nim) {
el = cr;
// use cr

// selection "cursor"
// find next chordrest, which might be a grace note
// this may override note input cursor

el = nextChordRest(cr);

// Skip gap rests if we're not in note entry mode...
while (!noteEntryMode() && el && el->isRest() && toRest(el)->isGap()) {
el = nextChordRest(toChordRest(el));
}
// do not use if new input segment is current cr
// this means input cursor just caught up to current selection
else if (cr && nis == cr->segment()) {
if (el && noteEntryMode()) {
// do not use if not in original or new measure (don't skip measures)
Measure* m = toChordRest(el)->measure();
Segment* nis = m_is.segment();
Measure* nim = nis ? nis->measure() : nullptr;
if (m != oim && m != nim) {
el = cr;
}
// do not use if new input segment is current cr
// this means input cursor just caught up to current selection
else if (cr && nis == cr->segment()) {
el = cr;
}
} else if (!el) {
el = cr;
}
} else if (!el) {
el = cr;

if (el->isChord()) {
Chord* ch = toChord(el);
if (noteLevel > ch->notes().size() - 1) {
noteLevel = ch->notes().size() - 1;
}
el = ch->notes()[noteLevel]; // originally downNote
}
select(el, SelectType::ADD, 0);
}
return el;
} else if (cmd == u"prev-chord" && cr) {
// note input cursor
if (noteEntryMode() && m_is.segment()) {
Expand All @@ -3065,28 +3101,61 @@
// selection "cursor"
// find previous chordrest, which might be a grace note
// this may override note input cursor
el = prevChordRest(cr);
std::vector<EngravingItem*> els = selection().elements();
deselectAll();

// Skip gap rests if we're not in note entry mode...
while (!noteEntryMode() && el && el->isRest() && toRest(el)->isGap()) {
el = prevChordRest(toChordRest(el));
}
if (el && noteEntryMode()) {
// do not use if not in original or new measure (don't skip measures)
Measure* m = toChordRest(el)->measure();
Segment* nis = m_is.segment();
Measure* nim = nis ? nis->measure() : nullptr;
if (m != oim && m != nim) {
el = cr;
for (EngravingItem* e : els) {
if (!e->isNote() && !e->isRest()) {
continue;
}
ChordRest* cr = nullptr;

Check warning on line 3111 in src/engraving/editing/cmd.cpp

View workflow job for this annotation

GitHub Actions / windows_x64

declaration of 'cr' hides previous local declaration
size_t noteLevel = 0;
if (e->isNote()) {
Note* n = toNote(e);
Chord* c = n->chord();
cr = toChordRest(c);
for (size_t i = 0; i < c->notes().size(); i++) {
if (c->notes()[i] == n) {
noteLevel = i;
break;
}
}
} else {
cr = toChordRest(toRest(e));
}

el = prevChordRest(cr);

// Skip gap rests if we're not in note entry mode...
while (!noteEntryMode() && el && el->isRest() && toRest(el)->isGap()) {
el = prevChordRest(toChordRest(el));
}
// do not use if new input segment is current cr
// this means input cursor just caught up to current selection
else if (cr && nis == cr->segment()) {
if (el && noteEntryMode()) {
// do not use if not in original or new measure (don't skip measures)
Measure* m = toChordRest(el)->measure();
Segment* nis = m_is.segment();
Measure* nim = nis ? nis->measure() : nullptr;
if (m != oim && m != nim) {
el = cr;
}
// do not use if new input segment is current cr
// this means input cursor just caught up to current selection
else if (cr && nis == cr->segment()) {
el = cr;
}
} else if (!el) {
el = cr;
}
} else if (!el) {
el = cr;
if (el->isChord()) {
Chord* ch = toChord(el);
if (noteLevel > ch->notes().size() - 1) {
noteLevel = ch->notes().size() - 1;
}
el = ch->notes()[noteLevel]; // originally downNote
}
select(el, SelectType::ADD, 0);
}
return el;
} else if (cmd == u"next-measure") {
if (box && box->nextMeasure() && box->nextMeasure()->first()) {
el = box->nextMeasure()->first()->nextChordRest(0, false);
Expand Down
Loading