Skip to content

Commit

Permalink
Merge pull request #24755 from mike-spa/returnOldLyricsDashDistribution
Browse files Browse the repository at this point in the history
Return to old lyrics dash distrubution
  • Loading branch information
mike-spa committed Sep 20, 2024
1 parent 772897f commit 02699b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/engraving/rendering/dev/lyricslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,13 @@ void LyricsLayout::layoutDashes(LyricsLineSegment* item)
bool isDashOnFirstSyllable = lyricsLine->tick2() == system->firstMeasure()->tick();
double curLength = endX - startX;
double dashMinLength = style.styleMM(Sid::lyricsDashMinLength);
int dashCount = std::floor(curLength / style.styleMM(Sid::lyricsDashMaxDistance));
bool firstAndLastGapAreHalf = style.styleB(Sid::lyricsDashFirstAndLastGapAreHalf);
bool forceDash = style.styleB(Sid::lyricsDashForce)
|| (style.styleB(Sid::lyricsShowDashIfSyllableOnFirstNote) && isDashOnFirstSyllable);
double maxDashDistance = style.styleMM(Sid::lyricsDashMaxDistance);
int dashCount = firstAndLastGapAreHalf && curLength > maxDashDistance ? std::ceil(curLength / maxDashDistance)
: std::floor(curLength / maxDashDistance);

if (curLength > dashMinLength || forceDash) {
dashCount = std::max(dashCount, 1);
}
Expand All @@ -381,7 +385,7 @@ void LyricsLayout::layoutDashes(LyricsLineSegment* item)
double dashWidth = std::min(curLength, style.styleMM(Sid::lyricsDashMaxLength).val());

bool dashesLeftAligned = lyricsDashSystemStart != LyricsDashSystemStart::STANDARD && !item->isSingleBeginType();
double dashDist = curLength / (dashesLeftAligned ? dashCount : dashCount + 1);
double dashDist = curLength / (dashesLeftAligned || firstAndLastGapAreHalf ? dashCount : dashCount + 1);
double xDash = 0.0;
if (dashesLeftAligned) {
for (int i = 0; i < dashCount; ++i) {
Expand All @@ -390,7 +394,11 @@ void LyricsLayout::layoutDashes(LyricsLineSegment* item)
}
} else {
for (int i = 0; i < dashCount; ++i) {
xDash += dashDist;
if (firstAndLastGapAreHalf && i == 0) {
xDash += 0.5 * dashDist;
} else {
xDash += dashDist;
}
item->mutldata()->addDash(LineF(PointF(xDash - 0.5 * dashWidth, 0.0), PointF(xDash + 0.5 * dashWidth, 0.0)));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/engraving/style/styledef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
styleDef(lyricsDashMaxLength, Spatium(0.6)),
styleDef(lyricsDashMaxDistance, Spatium(16.0)),
styleDef(lyricsDashForce, true),
styleDef(lyricsDashFirstAndLastGapAreHalf, true),
styleDef(lyricsAlignVerseNumber, true),
styleDef(lyricsLineThickness, Spatium(0.1)),
styleDef(lyricsMelismaAlign, Align(AlignH::LEFT, AlignV::BASELINE)),
Expand Down
1 change: 1 addition & 0 deletions src/engraving/style/styledef.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ enum class Sid {
lyricsDashMaxLength,
lyricsDashMaxDistance,
lyricsDashForce,
lyricsDashFirstAndLastGapAreHalf,
lyricsAlignVerseNumber,
lyricsLineThickness,
lyricsMelismaAlign,
Expand Down

0 comments on commit 02699b6

Please sign in to comment.