Skip to content

Commit

Permalink
style option for lyrics verse number alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Aug 26, 2016
1 parent 2582577 commit 653fc53
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 62 deletions.
40 changes: 21 additions & 19 deletions libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ void Lyrics::layout1()

//
// parse leading verse number and/or punctuation, so we can factor it into layout separately
// TODO: provide a way to disable this
//
bool hasNumber = false; // _verseNumber;
qreal centerAdjust = 0.0;
Expand All @@ -294,24 +293,27 @@ void Lyrics::layout1()
// 2) at least one other character (indicating start of actual lyric)
// 3) string of non-word characters at end of syllable
//QRegularExpression leadingPattern("(^[\\d\\W]+)([^\\d\\W]+)");
QRegularExpression punctuationPattern("(^[\\d\\W]*)([^\\d\\W].*?)([\\d\\W]*$)", QRegularExpression::UseUnicodePropertiesOption);
QRegularExpressionMatch punctuationMatch = punctuationPattern.match(s);
if (punctuationMatch.hasMatch()) {
// leading and trailing punctuation
QString lp = punctuationMatch.captured(1);
QString tp = punctuationMatch.captured(3);
// actual lyric
//QString actualLyric = punctuationMatch.captured(2);
Text leading(*this);
leading.setPlainText(lp);
leading.layout1();
Text trailing(*this);
trailing.setPlainText(tp);
trailing.layout1();
leftAdjust = leading.width();
centerAdjust = leading.width() - trailing.width();
if (!lp.isEmpty() && lp[0].isDigit())
hasNumber = true;

if (score()->styleB(StyleIdx::lyricsAlignVerseNumber)) {
QRegularExpression punctuationPattern("(^[\\d\\W]*)([^\\d\\W].*?)([\\d\\W]*$)", QRegularExpression::UseUnicodePropertiesOption);
QRegularExpressionMatch punctuationMatch = punctuationPattern.match(s);
if (punctuationMatch.hasMatch()) {
// leading and trailing punctuation
QString lp = punctuationMatch.captured(1);
QString tp = punctuationMatch.captured(3);
// actual lyric
//QString actualLyric = punctuationMatch.captured(2);
Text leading(*this);
leading.setPlainText(lp);
leading.layout1();
Text trailing(*this);
trailing.setPlainText(tp);
trailing.layout1();
leftAdjust = leading.width();
centerAdjust = leading.width() - trailing.width();
if (!lp.isEmpty() && lp[0].isDigit())
hasNumber = true;
}
}

ChordRest* cr = chordRest();
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static const StyleType styleTypes[] {
{ StyleIdx::lyricsDashMaxLength, "lyricsDashMaxLegth", Spatium(0.8) },
{ StyleIdx::lyricsDashMaxDistance, "lyricsDashMaxDistance", Spatium(16.0) },
{ StyleIdx::lyricsDashForce, "lyricsDashForce", QVariant(true) },
{ StyleIdx::lyricsAlignVerseNumber, "lyricsAlignVerseNumber", true },

{ StyleIdx::figuredBassFontFamily, "figuredBassFontFamily", QString("MScoreBC") },

Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum class StyleIdx : int {
lyricsDashMaxLength,
lyricsDashMaxDistance,
lyricsDashForce,
lyricsAlignVerseNumber,

figuredBassFontFamily,
figuredBassFontSize,
Expand Down
16 changes: 11 additions & 5 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::lyricsPosBelow, false, lyricsPosBelow, resetLyricsPosBelow },
{ StyleIdx::lyricsMinTopDistance, false, lyricsMinTopDistance, resetLyricsMinTopDistance },
{ StyleIdx::lyricsMinBottomDistance, false, lyricsMinBottomDistance, resetLyricsMinBottomDistance },
{ StyleIdx::lyricsLineHeight, true, lyricsLineHeight, resetLyricsLineHeight },
{ StyleIdx::lyricsDashMinLength, false, lyricsDashMinLength, resetLyricsDashMinLength },
{ StyleIdx::lyricsDashMaxLength, false, lyricsDashMaxLength, resetLyricsDashMaxLength },
{ StyleIdx::lyricsDashMaxDistance, false, lyricsDashMaxDistance, resetLyricsDashMaxDistance },
{ StyleIdx::lyricsDashForce, false, lyricsDashForce, resetLyricsDashForce },
{ StyleIdx::lyricsAlignVerseNumber, false, lyricsAlignVerseNumber, resetLyricsAlignVerseNumber },

{ StyleIdx::systemFrameDistance, false, systemFrameDistance, 0 },
{ StyleIdx::frameSystemDistance, false, frameSystemDistance, 0 },
{ StyleIdx::minMeasureWidth, false, minMeasureWidth_2, resetMinMeasureWidth },
Expand Down Expand Up @@ -194,7 +201,6 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::tupletMaxSlope, false, tupletMaxSlope, resetTupletMaxSlope },
{ StyleIdx::tupletOufOfStaff, false, tupletOutOfStaff, 0 },

{ StyleIdx::lyricsLineHeight, true, lyricsLineHeight, resetLyricsLineHeight },
{ StyleIdx::repeatBarTips, false, showRepeatBarTips, 0 },
{ StyleIdx::startBarlineSingle, false, showStartBarlineSingle, 0 },
{ StyleIdx::startBarlineMultiple, false, showStartBarlineMultiple, 0 },
Expand All @@ -211,10 +217,6 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::smallStaffMag, true, smallStaffSize, 0 },
{ StyleIdx::smallNoteMag, true, smallNoteSize, 0 },
{ StyleIdx::smallClefMag, true, smallClefSize, 0 },
{ StyleIdx::lyricsDashMinLength, false, lyricsDashMinLength, resetLyricsDashMinLength },
{ StyleIdx::lyricsDashMaxLength, false, lyricsDashMaxLength, resetLyricsDashMaxLength },
{ StyleIdx::lyricsDashMaxDistance, false, lyricsDashMaxDistance, resetLyricsDashMaxDistance },
{ StyleIdx::lyricsDashForce, false, lyricsDashForce, resetLyricsDashForce },
{ StyleIdx::lastSystemFillLimit, true, lastSystemFillThreshold, 0 },
{ StyleIdx::genClef, false, genClef, 0 },
{ StyleIdx::genKeysig, false, genKeysig, 0 },
Expand Down Expand Up @@ -261,6 +263,10 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::autoplaceVerticalAlignRange, false, autoplaceVerticalAlignRange, resetAutoplaceVerticalAlignRange },
};

lyricsPlacement->clear();
lyricsPlacement->addItem(tr("Above"), int(Element::Placement::ABOVE));
lyricsPlacement->addItem(tr("Above"), int(Element::Placement::BELOW));

autoplaceVerticalAlignRange->clear();
autoplaceVerticalAlignRange->addItem(tr("Segment"), int(VerticalAlignRange::SEGMENT));
autoplaceVerticalAlignRange->addItem(tr("Measure"), int(VerticalAlignRange::MEASURE));
Expand Down
99 changes: 61 additions & 38 deletions mscore/editstyle.ui
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>19</number>
<number>0</number>
</property>
<widget class="QWidget" name="Page1">
<layout class="QVBoxLayout" name="verticalLayout_20">
Expand Down Expand Up @@ -6992,6 +6992,22 @@
<string>Lyrics Text</string>
</property>
<layout class="QGridLayout" name="gridLayout_23">
<item row="1" column="0">
<widget class="QLabel" name="label_132">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Position Above</string>
</property>
<property name="buddy">
<cstring>lyricsPosAbove</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="lyricsLineHeight">
<property name="suffix">
Expand Down Expand Up @@ -7059,22 +7075,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_132">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Position Above</string>
</property>
<property name="buddy">
<cstring>lyricsPosAbove</cstring>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_31">
<property name="orientation">
Expand Down Expand Up @@ -7187,23 +7187,6 @@
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="resetLyricsMinBottomDistance">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Min. bottom margin' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="lyricsPosBelow">
<property name="sizePolicy">
Expand Down Expand Up @@ -7242,6 +7225,9 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="lyricsPlacement"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="resetLyricsPosBelow">
<property name="toolTip">
Expand All @@ -7266,9 +7252,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="lyricsPlacement"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="resetLyricsPlacement">
<property name="toolTip">
Expand All @@ -7286,6 +7269,47 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="lyricsAlignVerseNumber">
<property name="text">
<string>Align Verse Number</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="resetLyricsMinBottomDistance">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Min. bottom margin' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QToolButton" name="resetLyricsAlignVerseNumber">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Min. bottom margin' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -7780,7 +7804,6 @@
<tabstop>lyricsMinTopDistance</tabstop>
<tabstop>resetLyricsMinTopDistance</tabstop>
<tabstop>lyricsMinBottomDistance</tabstop>
<tabstop>resetLyricsMinBottomDistance</tabstop>
<tabstop>lyricsDashMinLength</tabstop>
<tabstop>resetLyricsDashMinLength</tabstop>
<tabstop>lyricsDashMaxLength</tabstop>
Expand Down

0 comments on commit 653fc53

Please sign in to comment.