Skip to content

Commit

Permalink
add style parameter for autoplace lyrics
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Aug 18, 2016
1 parent 61ae4e7 commit 06bd541
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 146 deletions.
2 changes: 1 addition & 1 deletion libmscore/chordrest.cpp
Expand Up @@ -1479,7 +1479,7 @@ Shape ChordRest::shape() const
x2 = qMax(x2, x1 + l->bbox().width() + margin);
}
if (x2 > x1)
shape.add(QRectF(x1, 0.0, x2-x1, 2.0));
shape.add(QRectF(x1, 0.0, x2-x1, 0.0));
return shape;
}
}
Expand Down
1 change: 0 additions & 1 deletion libmscore/hairpin.cpp
Expand Up @@ -508,7 +508,6 @@ void Hairpin::setHairpinType(Type val)

void Hairpin::layout()
{
printf("Hairpin::layout\n");
setPos(0.0, 0.0);
TextLine::layout();
}
Expand Down
13 changes: 8 additions & 5 deletions libmscore/layout.cpp
Expand Up @@ -3376,7 +3376,9 @@ System* Score::collectSystem(LayoutContext& lc)
// vertical align lyrics
//

qreal margin = spatium() * .5;
qreal lyricsMinTopDistance = styleP(StyleIdx::lyricsMinTopDistance);
qreal lyricsMinBottomDistance = styleP(StyleIdx::lyricsMinBottomDistance);

for (MeasureBase* mb : system->measures()) {
if (!mb->isMeasure())
continue;
Expand All @@ -3397,7 +3399,7 @@ System* Score::collectSystem(LayoutContext& lc)
for (Lyrics* l : cr->lyrics()) {
if (l) {
l->rUserYoffset() = 0.0;
sh.add(l->bbox().adjusted(-margin, 0.0, margin, 0.0).translated(l->pos()));
sh.add(l->bbox().translated(l->pos()));
}
}
// lyrics shapes must be moved, so first remove them from segment
Expand All @@ -3406,8 +3408,8 @@ System* Score::collectSystem(LayoutContext& lc)
for (Lyrics* l : cr->lyrics()) {
if (l && l->autoplace()) {
qreal y = s.staffShape(staffIdx).minVerticalDistance(sh);
if (y > 0.0)
yMax = qMax(yMax, y);
if (y > -lyricsMinTopDistance)
yMax = qMax(yMax, y + lyricsMinTopDistance);
}
}
}
Expand All @@ -3424,7 +3426,8 @@ System* Score::collectSystem(LayoutContext& lc)
for (Lyrics* l : cr->lyrics()) {
if (l && l->autoplace()) {
l->rUserYoffset() = yMax;
sh.add(l->bbox().translated(l->pos()));
sh.add(l->bbox().translated(l->pos())
.adjusted(0.0, 0.0, 0.0, lyricsMinBottomDistance));
}
}
s.staffShape(staffIdx).add(sh);
Expand Down
3 changes: 2 additions & 1 deletion libmscore/style.cpp
Expand Up @@ -55,7 +55,8 @@ static const StyleType styleTypes[] {
{ StyleIdx::minSystemDistance, "minSystemDistance", Spatium(8.5) },
{ StyleIdx::maxSystemDistance, "maxSystemDistance", Spatium(15.0) },
{ StyleIdx::lyricsDistance, "lyricsDistance", Spatium(2.0) },
{ StyleIdx::lyricsMinBottomDistance, "lyricsMinBottomDistance", Spatium(4.0) },
{ StyleIdx::lyricsMinTopDistance, "lyricsMinTopDistance", Spatium(1.0) },
{ StyleIdx::lyricsMinBottomDistance, "lyricsMinBottomDistance", Spatium(3.0) },
{ StyleIdx::lyricsLineHeight, "lyricsLineHeight", 1.0 },
{ StyleIdx::figuredBassFontFamily, "figuredBassFontFamily", QString("MScoreBC") },

Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Expand Up @@ -44,6 +44,7 @@ enum class StyleIdx : int {
maxSystemDistance,

lyricsDistance,
lyricsMinTopDistance,
lyricsMinBottomDistance,
lyricsLineHeight,

Expand Down
7 changes: 4 additions & 3 deletions mscore/editstyle.cpp
Expand Up @@ -76,8 +76,9 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::akkoladeDistance, false, akkoladeDistance, 0 },
{ StyleIdx::minSystemDistance, false, minSystemDistance, 0 },
{ StyleIdx::maxSystemDistance, false, maxSystemDistance, 0 },
{ StyleIdx::lyricsDistance, false, lyricsDistance, 0 },
{ StyleIdx::lyricsMinBottomDistance, false, lyricsMinBottomDistance, 0 },
{ StyleIdx::lyricsDistance, false, lyricsDistance, resetLyricsDistance },
{ StyleIdx::lyricsMinTopDistance, false, lyricsMinTopDistance, resetLyricsMinTopDistance },
{ StyleIdx::lyricsMinBottomDistance, false, lyricsMinBottomDistance, resetLyricsMinBottomDistance },
{ StyleIdx::systemFrameDistance, false, systemFrameDistance, 0 },
{ StyleIdx::frameSystemDistance, false, frameSystemDistance, 0 },
{ StyleIdx::minMeasureWidth, false, minMeasureWidth_2, resetMinMeasureWidth },
Expand Down Expand Up @@ -189,7 +190,7 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
{ StyleIdx::tupletMaxSlope, false, tupletMaxSlope, resetTupletMaxSlope },
{ StyleIdx::tupletOufOfStaff, false, tupletOutOfStaff, 0 },

{ StyleIdx::lyricsLineHeight, true, lyricsLineHeight, 0 },
{ StyleIdx::lyricsLineHeight, true, lyricsLineHeight, resetLyricsLineHeight },
{ StyleIdx::repeatBarTips, false, showRepeatBarTips, 0 },
{ StyleIdx::startBarlineSingle, false, showStartBarlineSingle, 0 },
{ StyleIdx::startBarlineMultiple, false, showStartBarlineMultiple, 0 },
Expand Down

0 comments on commit 06bd541

Please sign in to comment.