Skip to content

Commit

Permalink
Bare min. from musescore#9068 to be able to port musescore#9137 to 3.x
Browse files Browse the repository at this point in the history
(Very partial) backport of musescore#9068, the rest is too large for too litle
benefit (mainly due to the missing UI) and also requires C++17.
  • Loading branch information
asattely authored and Jojo-Schmitz committed May 12, 2022
1 parent 25a72d8 commit 381fc3a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libmscore/measure.cpp
Expand Up @@ -4596,4 +4596,26 @@ void Measure::computeMinWidth()
computeMinWidth(s, x, isSystemHeader);
}

qreal Measure::computeFirstSegmentXPosition(Segment* segment)
{
qreal x = 0;

Shape ls(QRectF(0.0, 0.0, 0.0, spatium() * 4));

x = segment->minLeft(ls);

if (segment->isChordRestType())
x += score()->styleP(hasAccidental(segment) ? Sid::barAccidentalDistance : Sid::barNoteDistance);
else if (segment->isClefType() || segment->isHeaderClefType())
x += score()->styleP(Sid::clefLeftMargin);
else if (segment->isKeySigType())
x = qMax(x, score()->styleP(Sid::keysigLeftMargin));
else if (segment->isTimeSigType())
x = qMax(x, score()->styleP(Sid::timesigLeftMargin));

x += segment->extraLeadingSpace().val() * spatium();

return x;
}

}
3 changes: 3 additions & 0 deletions libmscore/measure.h
Expand Up @@ -279,6 +279,9 @@ class Measure final : public MeasureBase {
void checkTrailer();
void setStretchedWidth(qreal);
void layoutStaffLines();

qreal computeFirstSegmentXPosition(Segment* segment);

};

} // namespace Ms
Expand Down

0 comments on commit 381fc3a

Please sign in to comment.