Skip to content

Commit

Permalink
Fix other vtests
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacWeiss committed Jul 30, 2020
1 parent 6349c97 commit eab53a9
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3523,10 +3523,8 @@ void Measure::stretchMeasure(qreal targetWidth)
if (!e) {
continue;
}
ElementType t = e->type();
int staffIdx = e->staffIdx();
if (t == ElementType::MEASURE_REPEAT || (t == ElementType::MMREST)
|| (t == ElementType::REST && toRest(e)->isFullMeasureRest())) {
int staffIdx = e->staffIdx();
if ((e->isRest() && toRest(e)->isFullMeasureRest()) || e->isMMRest() || e->isMeasureRepeat()) {
//
// element has to be centered in free space
// x1 - left measure position of free space
Expand All @@ -3544,30 +3542,27 @@ void Measure::stretchMeasure(qreal targetWidth)
qreal x1 = s1 ? s1->x() + s1->minRight() : 0;
qreal x2 = s2 ? s2->x() - s2->minLeft() : targetWidth;

if (isMMRest()) {
if (e->isMMRest()) {
MMRest* mmrest = toMMRest(e);
//
// center multimeasure rest
//
qreal d = score()->styleP(Sid::multiMeasureRestMargin);
qreal w = x2 - x1 - 2 * d;

mmrest->setWidth(w);
mmrest->layout();
e->setPos(x1 - s.x() + d, e->staff()->height() * .5); // center vertically in measure
} else if (e->isMeasureRepeat()
&& (toMeasureRepeat(e)->numMeasures() == 2 || toMeasureRepeat(e)->numMeasures() == 4)) {
// center on barline
e->setPos(x1 - s.x() + d, e->staff()->height() * .5);
} else if (e->isMeasureRepeat() && !(toMeasureRepeat(e)->numMeasures() % 2)) {
// two- or four-measure repeat, center on following barline
qreal measureWidth = x2 - s.x() + .5 * (styleP(Sid::barWidth));
e->rxpos() = measureWidth - .5 * e->width();
} else {
// center full measure rest or one-measure repeat
e->rxpos() = (x2 - x1 - e->width()) * .5 + x1 - s.x() + e->bbox().x();
// full measure rest or one-measure repeat, center within this measure
e->rxpos() = (x2 - x1 - e->width()) * .5 + x1 - s.x() - e->bbox().x();
}
s.createShape(staffIdx); // DEBUG
} else if (t == ElementType::REST) {
} else if (e->isRest()) {
e->rxpos() = 0;
} else if (t == ElementType::CHORD) {
} else if (e->isChord()) {
Chord* c = toChord(e);
c->layout2();
if (c->tremolo()) {
Expand All @@ -3578,7 +3573,7 @@ void Measure::stretchMeasure(qreal targetWidth)
tr->layout();
}
}
} else if (t == ElementType::BAR_LINE) {
} else if (e->isBarLine()) {
e->rypos() = 0.0;
// for end barlines, x position was set in createEndBarLines
if (s.segmentType() != SegmentType::EndBarLine) {
Expand Down

0 comments on commit eab53a9

Please sign in to comment.