From b180b079a561ae801b6d81bdf66aa7345cb6afab Mon Sep 17 00:00:00 2001 From: XiaoMigros Date: Thu, 27 Nov 2025 18:30:27 +0100 Subject: [PATCH] Implode honours grace note transposition --- src/engraving/editing/edit.cpp | 43 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/engraving/editing/edit.cpp b/src/engraving/editing/edit.cpp index 5db13a5d308c8..781483a95fb6c 100644 --- a/src/engraving/editing/edit.cpp +++ b/src/engraving/editing/edit.cpp @@ -5208,14 +5208,11 @@ void Score::cloneVoice(track_idx_t strack, track_idx_t dtrack, Segment* sf, cons } } - if (oe->isChord()) { - Chord* och = toChord(ocr); - Chord* nch = toChord(ncr); - - size_t n = och->notes().size(); + auto cloneChord = [&](Chord* oldChord, Chord* newChord) { + size_t n = oldChord->notes().size(); for (size_t i = 0; i < n; ++i) { - Note* on = och->notes().at(i); - Note* nn = nch->notes().at(i); + Note* on = oldChord->notes().at(i); + Note* nn = newChord->notes().at(i); staff_idx_t idx = track2staff(dtrack); Fraction tick = oseg->tick(); Interval v = staff(idx) ? staff(idx)->transpose(tick) : Interval(); @@ -5270,32 +5267,40 @@ void Score::cloneVoice(track_idx_t strack, track_idx_t dtrack, Segment* sf, cons } } // two note tremolo - if (och->tremoloTwoChord()) { - if (och == och->tremoloTwoChord()->chord1()) { + if (oldChord->tremoloTwoChord()) { + if (oldChord == oldChord->tremoloTwoChord()->chord1()) { if (tremolo) { LOGD("unconnected two note tremolo"); } if (link) { - tremolo = item_cast(och->tremoloTwoChord()->linkedClone()); + tremolo = item_cast(oldChord->tremoloTwoChord()->linkedClone()); } else { - tremolo = item_cast(och->tremoloTwoChord()->clone()); + tremolo = item_cast(oldChord->tremoloTwoChord()->clone()); } - tremolo->setScore(nch->score()); - tremolo->setParent(nch); - tremolo->setTrack(nch->track()); - tremolo->setChords(nch, nullptr); - nch->setTremoloTwoChord(tremolo); - } else if (och == och->tremoloTwoChord()->chord2()) { + tremolo->setScore(newChord->score()); + tremolo->setParent(newChord); + tremolo->setTrack(newChord->track()); + tremolo->setChords(newChord, nullptr); + newChord->setTremoloTwoChord(tremolo); + } else if (oldChord == oldChord->tremoloTwoChord()->chord2()) { if (!tremolo) { LOGD("first note for two note tremolo missing"); } else { - tremolo->setChords(tremolo->chord1(), nch); - nch->setTremoloTwoChord(tremolo); + tremolo->setChords(tremolo->chord1(), newChord); + newChord->setTremoloTwoChord(tremolo); } } else { LOGD("inconsistent two note tremolo"); } } + }; + if (oe->isChord()) { + cloneChord(toChord(ocr), toChord(ncr)); + for (size_t i = 0; i < toChord(ocr)->graceNotes().size(); ++i) { + Chord* ogc = toChord(ocr)->graceNotes().at(i); + Chord* ngc = toChord(ncr)->graceNotes().at(i); + cloneChord(ogc, ngc); + } } // Add element