Skip to content

Commit

Permalink
handle special case if all measure stretches in a system are zero
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer authored and lasconic committed Jun 17, 2015
1 parent 0b0f19a commit 37e54f6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ QList<System*> Score::layoutSystemRow(qreal rowWidth, bool isFirstSystem, bool u
if (mb->type() == Element::Type::HBOX)
minWidth += point(((Box*)mb)->boxWidth());
else if (mb->type() == Element::Type::MEASURE) {
Measure* m = (Measure*)mb;
Measure* m = static_cast<Measure*>(mb);
if (needRelayout)
m->setDirty();
minWidth += m->minWidth2();
Expand All @@ -2996,6 +2996,20 @@ QList<System*> Score::layoutSystemRow(qreal rowWidth, bool isFirstSystem, bool u
}
minWidth += system->leftMargin();
}
bool zeroStretch;
if (totalWeight < 0.01) {
zeroStretch = true;
foreach(System* system, sl) {
foreach (MeasureBase* mb, system->measures()) {
if (mb->type() == Element::Type::MEASURE) {
Measure* m = static_cast<Measure*>(mb);
totalWeight += m->ticks();
}
}
}
}
else
zeroStretch = false;

// stretch incomplete row
qreal rest;
Expand Down Expand Up @@ -3027,7 +3041,7 @@ QList<System*> Score::layoutSystemRow(qreal rowWidth, bool isFirstSystem, bool u
}
mb->setPos(pos);
Measure* m = static_cast<Measure*>(mb);
qreal weight = m->ticks() * m->userStretch();
qreal weight = m->ticks() * (zeroStretch ? 1.0 : m->userStretch());
ww = m->minWidth2() + rest * weight;
m->layoutWidth(ww);
}
Expand Down

0 comments on commit 37e54f6

Please sign in to comment.