Skip to content

Commit

Permalink
Fix dashes after repeats
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Feb 19, 2025
1 parent 45576d7 commit 6ee3fed
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6101,16 +6101,17 @@ void NotationInteraction::navigateToNextSyllable()
nextSegment = nullptr;
}

if (!nextSegment && !hasFollowingRepeat) {
if (!nextSegment && !hasFollowingRepeat && !hasPrecedingRepeat) {
return;
}

endEditText();

// look for the lyrics we are moving from; may be the current lyrics or a previous one
// we are extending with several dashes
Lyrics* fromLyrics = 0;
while (segment) {
Lyrics* fromLyrics = nullptr;
Segment* curSeg = segment;
while (segment && segmentsAreAdjacentInRepeatStructure(segment, curSeg)) {
ChordRest* cr = toChordRest(segment->element(track));
if (!cr) {
segment = segment->prev1(SegmentType::ChordRest);
Expand All @@ -6123,26 +6124,67 @@ void NotationInteraction::navigateToNextSyllable()
segment = segment->prev1(SegmentType::ChordRest);
}

if (!nextSegment && hasFollowingRepeat && fromLyrics) {
// Allow dash with no end syllable if there is a repeat
if (!nextSegment) {
score()->startCmd(TranslatableString("undoableAction", "Navigate to next syllable"));
switch (fromLyrics->syllabic()) {
case LyricsSyllabic::BEGIN:
case LyricsSyllabic::MIDDLE:
break;
case LyricsSyllabic::SINGLE:
fromLyrics->undoChangeProperty(Pid::SYLLABIC, int(LyricsSyllabic::BEGIN));
break;
case LyricsSyllabic::END:
fromLyrics->undoChangeProperty(Pid::SYLLABIC, int(LyricsSyllabic::MIDDLE));
break;
if (fromLyrics && hasFollowingRepeat) {
// Allow dash with no end syllable if there is a repeat
switch (fromLyrics->syllabic()) {
case LyricsSyllabic::BEGIN:
case LyricsSyllabic::MIDDLE:
break;
case LyricsSyllabic::SINGLE:
fromLyrics->undoChangeProperty(Pid::SYLLABIC, int(LyricsSyllabic::BEGIN));
break;
case LyricsSyllabic::END:
fromLyrics->undoChangeProperty(Pid::SYLLABIC, int(LyricsSyllabic::MIDDLE));
break;
}
fromLyrics->undoChangeProperty(Pid::LYRIC_TICKS, Fraction(0, 1));
score()->setLayoutAll();
score()->endCmd();
return;
}
fromLyrics->undoChangeProperty(Pid::LYRIC_TICKS, Fraction(0, 1));

score()->endCmd();
score()->setLayoutAll();
if (hasPrecedingRepeat) {
score()->endCmd();
// No from lyrics - create incoming partial dash
PartialLyricsLine* dash = Factory::createPartialLyricsLine(score()->dummy());
dash->setIsEndMelisma(false);
dash->setNo(verse);
dash->setPlacement(placement);
dash->setTick(initialCR->tick());
dash->setTicks(Fraction(0, 1));
dash->setTrack(initialCR->track());
dash->setTrack2(initialCR->track());

score()->undoAddElement(dash);

// Don't advance cursor

Lyrics* toLyrics = Factory::createLyrics(initialCR);
toLyrics->setTrack(track);
toLyrics->setParent(initialCR);

toLyrics->setNo(verse);
const TextStyleType styleType(toLyrics->isEven() ? TextStyleType::LYRICS_EVEN : TextStyleType::LYRICS_ODD);
toLyrics->setTextStyleType(styleType);

toLyrics->setPlacement(placement);
toLyrics->setPropertyFlags(Pid::PLACEMENT, pFlags);
toLyrics->setSyllabic(LyricsSyllabic::END);
toLyrics->setFontStyle(fStyle);
toLyrics->setPropertyFlags(Pid::FONT_STYLE, fFlags);

score()->undoAddElement(toLyrics);
score()->endCmd();
score()->select(toLyrics, SelectType::SINGLE, 0);
score()->setLayoutAll();
startEditText(toLyrics, PointF());
toLyrics->selectAll(toLyrics->cursor());
showItem(toLyrics);

return;
return;
}
}

score()->startCmd(TranslatableString("undoableAction", "Navigate to next syllable"));
Expand Down

0 comments on commit 6ee3fed

Please sign in to comment.