Skip to content

Commit 7e8ee79

Browse files
committed
overwrite notes
1 parent 0605fba commit 7e8ee79

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/engraving/editing/edit.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,8 +2042,10 @@ static Tie* createAndAddTie(Note* startNote, Note* endNote)
20422042

20432043
void Score::cmdAddTie(bool addToChord)
20442044
{
2045-
const std::vector<Note*> noteList = cmdTieNoteList(selection(), noteEntryMode());
2045+
std::vector<Note*> noteList = cmdTieNoteList(selection(), noteEntryMode());
20462046
std::vector<EngravingItem*> toSelect;
2047+
std::sort(noteList.begin(), noteList.end(), [](const Note* a, const Note* b) { return a->track() < b->track(); });
2048+
track_idx_t track = noteList[0]->chord()->track();
20472049

20482050
if (noteList.empty()) {
20492051
LOGD("no notes selected");
@@ -2088,7 +2090,9 @@ void Score::cmdAddTie(bool addToChord)
20882090
}
20892091

20902092
bool addFlag = lastAddedChord != nullptr;
2091-
2093+
if (c->track() != track) {
2094+
addFlag = false;
2095+
}
20922096
// try to re-use existing note or chord
20932097
Note* n = nullptr;
20942098
if (addToChord && cr->isChord()) {
@@ -2099,8 +2103,6 @@ void Score::cmdAddTie(bool addToChord)
20992103
} else {
21002104
addFlag = true; // re-use chord
21012105
}
2102-
} else if (!noteEntryMode()) {
2103-
addFlag = false;
21042106
}
21052107

21062108
// if no note to re-use, create one
@@ -2128,7 +2130,7 @@ void Score::cmdAddTie(bool addToChord)
21282130
//n->setTpc(note->tpc());
21292131
createAndAddTie(note, nnote);
21302132

2131-
if (!addFlag || nnote->chord()->tick() >= lastAddedChord->tick() || nnote->chord()->isGrace()) {
2133+
if (!addFlag || nnote->chord()->tick() >= lastAddedChord->tick() || nnote->chord()->isGrace() || nnote->chord()->track() != lastAddedChord->track()) {
21322134
break;
21332135
} else {
21342136
note = nnote;
@@ -2189,7 +2191,7 @@ Tie* Score::cmdToggleTie()
21892191
const bool shouldTieListSelection = noteList.size() >= 2 && !singleTick;
21902192

21912193
if (singleTick /* i.e. all notes are in the same tick */ && !allHaveExistingNextNoteToTieTo) {
2192-
cmdAddTie(true);
2194+
cmdAddTie();
21932195
return nullptr;
21942196
}
21952197

0 commit comments

Comments
 (0)