From ab9ffd633c408865098c203d555d937d52ceaa0c Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Mon, 15 Aug 2016 14:30:06 +0200 Subject: [PATCH] fix #88171: Lyrics dash max distance as a parameter Turns the previously hard-coded max. distance between multiple dashes into a user configurable score style. __References__: - Issue: https://musescore.org/en/node/88171 - Original request with discussion and screen-shots: https://musescore.org/en/node/87841 Shamelessly stolen from PR #2294, which needed a non-trivial rebase --- libmscore/lyrics.cpp | 5 +++-- libmscore/lyrics.h | 1 - libmscore/style.cpp | 2 +- libmscore/style.h | 3 +++ mscore/editstyle.cpp | 1 + mscore/editstyle.ui | 26 ++++++++++++++++++++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/libmscore/lyrics.cpp b/libmscore/lyrics.cpp index 44d5a73f8b..e708d9e5d6 100644 --- a/libmscore/lyrics.cpp +++ b/libmscore/lyrics.cpp @@ -872,6 +872,7 @@ void LyricsLineSegment::layout() #endif qreal len = pos2().x(); qreal minDashLen = score()->styleS(StyleIdx::lyricsDashMinLength).val() * sp; + qreal maxDashDist = score()->styleS(StyleIdx::lyricsDashMaxDistance).val() * sp; if (len < minDashLen) { // if no room for a dash // if at end of system or dash is forced if (endOfSystem || score()->styleB(StyleIdx::lyricsDashForce)) { @@ -882,13 +883,13 @@ void LyricsLineSegment::layout() else // if within system or dash not forced _numOfDashes = 0; // draw no dash } - else if (len < (Lyrics::LYRICS_DASH_DEFAULT_STEP * TWICE * sp)) { // if no room for two dashes + else if (len < (maxDashDist * TWICE)) { // if no room for two dashes _numOfDashes = 1; // draw one dash if (_dashLength > len) // if no room for a full dash _dashLength = len; // shorten it } else - _numOfDashes = len / (Lyrics::LYRICS_DASH_DEFAULT_STEP * sp);// draw several dashes + _numOfDashes = len / (maxDashDist); // draw several dashes // adjust next lyrics horiz. position if too little a space forced to skip the dash if (_numOfDashes == 0 && nextLyr != nullptr && len > 0) diff --git a/libmscore/lyrics.h b/libmscore/lyrics.h index b358cfa660..4e696f6034 100644 --- a/libmscore/lyrics.h +++ b/libmscore/lyrics.h @@ -60,7 +60,6 @@ class Lyrics : public Text { // metrics for dashes and melisma; all in sp. units: static constexpr qreal MELISMA_DEFAULT_LINE_THICKNESS = 0.10; // for melisma line only; static constexpr qreal MELISMA_DEFAULT_PAD = 0.10; // the empty space before a melisma line - static constexpr qreal LYRICS_DASH_DEFAULT_STEP = 16.0; // the max. distance between dashes static constexpr qreal LYRICS_DASH_DEFAULT_PAD = 0.05; // the min. empty space before and after a dash // WORD_MIN_DISTANCE has never been implemented // static constexpr qreal LYRICS_WORD_MIN_DISTANCE = 0.33; // min. distance between lyrics from different words diff --git a/libmscore/style.cpp b/libmscore/style.cpp index 891b5953ab..2f6a19b27c 100644 --- a/libmscore/style.cpp +++ b/libmscore/style.cpp @@ -272,7 +272,7 @@ static const StyleType styleTypes[] { { StyleIdx::barGraceDistance, "barGraceDistance", Spatium(.6) }, { StyleIdx::lyricsDashMinLength, "lyricsDashMinLength", Spatium(0.4) }, { StyleIdx::lyricsDashMaxLength, "lyricsDashMaxLegth", Spatium(0.8) }, - + { StyleIdx::lyricsDashMaxDistance, "lyricsDashMaxDistance", Spatium(16.0) }, { StyleIdx::lyricsDashForce, "lyricsDashForce", QVariant(true) }, { StyleIdx::minVerticalDistance, "minVerticalDistance", Spatium(0.5) }, { StyleIdx::ornamentStyle, "ornamentStyle", int(MScore::OrnamentStyle::DEFAULT) }, diff --git a/libmscore/style.h b/libmscore/style.h index 6125aebcb7..462418e9d0 100644 --- a/libmscore/style.h +++ b/libmscore/style.h @@ -29,6 +29,8 @@ class Element; //--------------------------------------------------------- // StyleIdx +// +// Keep in sync with styleTypes[] in style.cpp //--------------------------------------------------------- enum class StyleIdx : int { @@ -269,6 +271,7 @@ enum class StyleIdx : int { barGraceDistance, lyricsDashMinLength, lyricsDashMaxLength, + lyricsDashMaxDistance, lyricsDashForce, minVerticalDistance, diff --git a/mscore/editstyle.cpp b/mscore/editstyle.cpp index 127d06b28c..b4357b4775 100644 --- a/mscore/editstyle.cpp +++ b/mscore/editstyle.cpp @@ -208,6 +208,7 @@ EditStyle::EditStyle(Score* s, QWidget* parent) { StyleIdx::smallClefMag, true, smallClefSize, 0 }, { StyleIdx::lyricsDashMinLength, false, lyricsDashMinLength, 0 }, { StyleIdx::lyricsDashMaxLength, false, lyricsDashMaxLength, 0 }, + { StyleIdx::lyricsDashMaxDistance, false, lyricsDashMaxDistance, 0 }, { StyleIdx::lyricsDashForce, false, lyricsDashForce, 0 }, { StyleIdx::lastSystemFillLimit, true, lastSystemFillThreshold, 0 }, { StyleIdx::genClef, false, genClef, 0 }, diff --git a/mscore/editstyle.ui b/mscore/editstyle.ui index af5e8f5ea4..05c0302b4c 100644 --- a/mscore/editstyle.ui +++ b/mscore/editstyle.ui @@ -4049,6 +4049,13 @@ + + + Max. dash distance: + + + + Always force dash @@ -4068,6 +4075,25 @@ + + + + sp + + + 0 + + + 1.000000000000000 + + + 1.000000000000000 + + + 16.000000000000000 + + +