diff --git a/src/engraving/dom/lyrics.cpp b/src/engraving/dom/lyrics.cpp index 8780fc9c45a4d..29c1ff76dbe87 100644 --- a/src/engraving/dom/lyrics.cpp +++ b/src/engraving/dom/lyrics.cpp @@ -407,6 +407,9 @@ bool Lyrics::setProperty(Pid propertyId, const PropertyValue& v) if (Lyrics* l = prevLyrics(this)) { l->setNeedRemoveInvalidSegments(); } + if (Lyrics* l = nextLyrics(this)) { + setNeedRemoveInvalidSegments(); + } setPlacement(newVal); } } diff --git a/src/engraving/dom/navigate.cpp b/src/engraving/dom/navigate.cpp index 4fe13eacd1015..10df72d585b17 100644 --- a/src/engraving/dom/navigate.cpp +++ b/src/engraving/dom/navigate.cpp @@ -1039,4 +1039,25 @@ Lyrics* prevLyrics(const Lyrics* lyrics) } return nullptr; } + +Lyrics* nextLyrics(const Lyrics* lyrics) +{ + Segment* seg = lyrics->explicitParent() ? lyrics->segment() : nullptr; + if (!seg) { + return nullptr; + } + Segment* nextSegment = seg; + while ((nextSegment = nextSegment->next1(mu::engraving::SegmentType::ChordRest))) { + const track_idx_t strack = lyrics->staffIdx() * VOICES; + const track_idx_t etrack = strack + VOICES; + for (track_idx_t track = strack; track < etrack; ++track) { + EngravingItem* el = nextSegment->element(track); + Lyrics* nextLyrics = el && el->isChord() ? toChordRest(el)->lyrics(lyrics->no(), lyrics->placement()) : nullptr; + if (nextLyrics) { + return nextLyrics; + } + } + } + return nullptr; +} } diff --git a/src/engraving/dom/navigate.h b/src/engraving/dom/navigate.h index e886403bb56c3..0944539244111 100644 --- a/src/engraving/dom/navigate.h +++ b/src/engraving/dom/navigate.h @@ -31,5 +31,6 @@ extern int pitch2y(int pitch, int enh, int clefOffset, int key, int& prefix, con extern ChordRest* nextChordRest(const ChordRest* cr, bool skipGrace = false, bool skipMeasureRepeatRests = true); extern ChordRest* prevChordRest(const ChordRest* cr, bool skipGrace = false, bool skipMeasureRepeatRests = true); extern Lyrics* prevLyrics(const Lyrics* lyrics); +extern Lyrics* nextLyrics(const Lyrics* lyrics); } // namespace mu::engraving #endif diff --git a/src/engraving/rendering/dev/lyricslayout.cpp b/src/engraving/rendering/dev/lyricslayout.cpp index dbad74b0ac040..1f0b6f5899fe8 100644 --- a/src/engraving/rendering/dev/lyricslayout.cpp +++ b/src/engraving/rendering/dev/lyricslayout.cpp @@ -215,6 +215,7 @@ void LyricsLayout::layout(LyricsLine* item, LayoutContext& ctx) item->lyrics()->no(), item->lyrics()->placement() )); + item->setTrack2(item->nextLyrics() ? item->nextLyrics()->track() : item->track()); item->setTick2(item->nextLyrics() ? item->nextLyrics()->segment()->tick() : item->tick()); } diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 98f8e2202518a..75e69b0d8cc24 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -5049,6 +5049,7 @@ void NotationInteraction::navigateToNextSyllable() } mu::engraving::Lyrics* lyrics = toLyrics(m_editData.element); track_idx_t track = lyrics->track(); + track_idx_t toLyricTrack = track; mu::engraving::Segment* segment = lyrics->segment(); int verse = lyrics->no(); mu::engraving::PlacementV placement = lyrics->placement(); @@ -5065,7 +5066,8 @@ void NotationInteraction::navigateToNextSyllable() const track_idx_t etrack = strack + VOICES; for (track_idx_t t = strack; t < etrack; ++t) { el = nextSegment->element(t); - if (el && el->isChord()) { + if (el && el->isChord() && toChord(el)->lyrics(verse, placement)) { + toLyricTrack = t; break; } } @@ -5098,7 +5100,7 @@ void NotationInteraction::navigateToNextSyllable() } score()->startCmd(); - ChordRest* cr = toChordRest(nextSegment->element(track)); + ChordRest* cr = toChordRest(nextSegment->element(toLyricTrack)); mu::engraving::Lyrics* toLyrics = cr->lyrics(verse, placement); // If no lyrics in current track, check others