Skip to content

Commit

Permalink
Merge pull request #6350 from njvdberg/issue-307946-slashes-and-rests
Browse files Browse the repository at this point in the history
Fix #307946 Fix #307945 - Strange behavior with chord alignment.
  • Loading branch information
anatoly-os committed Jul 28, 2020
2 parents a8c4e00 + 084770c commit 97b80bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions libmscore/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ void Harmony::layout()
// setOffset(propertyDefault(Pid::OFFSET).toPointF());

layout1();
setPos(calculateBoundingRect());
}

//---------------------------------------------------------
Expand All @@ -1336,11 +1337,13 @@ void Harmony::layout1()
// calculateBoundingRect
//---------------------------------------------------------

void Harmony::calculateBoundingRect()
QPoint Harmony::calculateBoundingRect()
{
const qreal ypos = (placeBelow() && staff()) ? staff()->height() : 0.0;
const FretDiagram* fd = (parent() && parent()->isFretDiagram()) ? toFretDiagram(parent()) : nullptr;
const qreal cw = symWidth(SymId::noteheadBlack);
qreal newx = 0.0;
qreal newy = 0.0;

if (textList.empty()) {
TextBase::layout1();
Expand All @@ -1363,7 +1366,8 @@ void Harmony::calculateBoundingRect()
yy = ypos - ((align() & Align::BOTTOM) ? _harmonyHeight - bbox().height() : 0.0);
}

setPos(xx, yy);
newx = xx;
newy = yy;
}
else {
QRectF bb;
Expand All @@ -1385,15 +1389,17 @@ void Harmony::calculateBoundingRect()
else if (align() & Align::HCENTER)
xx = fd->centerX() - bb.width() / 2.0;

setPos(0.0, ypos - yy - score()->styleP(Sid::harmonyFretDist));
newx = 0.0;
newy = ypos - yy - score()->styleP(Sid::harmonyFretDist);
}
else {
if (align() & Align::RIGHT)
xx = -bb.x() -bb.width() + cw;
else if (align() & Align::HCENTER)
xx = -bb.x() -bb.width() / 2.0 + cw / 2.0;

setPos(0.0, ypos);
newx = 0.0;
newy = ypos;
}

for (TextSegment* ts : textList)
Expand All @@ -1415,6 +1421,7 @@ void Harmony::calculateBoundingRect()

}
}
return QPoint(newx, newy);
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/harmony.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Harmony final : public TextBase {
void spatiumChanged(qreal oldValue, qreal newValue) override;
void localSpatiumChanged(qreal oldValue, qreal newValue) override;
void setHarmony(const QString& s);
void calculateBoundingRect();
QPoint calculateBoundingRect();
qreal xShapeOffset() const;

QString userName() const override;
Expand Down

0 comments on commit 97b80bc

Please sign in to comment.