Skip to content

Commit

Permalink
Manually merged #6350 to master
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly-os committed Jul 28, 2020
1 parent 23ceafc commit 0286820
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions libmscore/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ void Harmony::layout()
// setOffset(propertyDefault(Pid::OFFSET).toPointF());

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

//---------------------------------------------------------
Expand All @@ -1377,11 +1378,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 @@ -1405,7 +1408,8 @@ void Harmony::calculateBoundingRect()
yy = ypos - ((align() & Align::BOTTOM) ? _harmonyHeight - bbox().height() : 0.0);
}

setPos(xx, yy);
newx = xx;
newy = yy;
} else {
QRectF bb;
for (TextSegment* ts : textList) {
Expand All @@ -1429,15 +1433,17 @@ void Harmony::calculateBoundingRect()
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 @@ -1459,6 +1465,8 @@ 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 @@ -209,7 +209,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 0286820

Please sign in to comment.