Skip to content

Commit

Permalink
Center one-line staff
Browse files Browse the repository at this point in the history
Backport of musescore#20767
  • Loading branch information
sammik authored and Jojo-Schmitz committed Apr 22, 2024
1 parent 7578489 commit 815e522
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions libmscore/stafftypechange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,25 @@ bool StaffTypeChange::setProperty(Pid propertyId, const QVariant& v)
case Pid::STEP_OFFSET:
m_staffType->setStepOffset(v.toInt());
break;
case Pid::STAFF_LINES:
m_staffType->setLines(v.toInt());
case Pid::STAFF_LINES: {
int linesOld = m_staffType->lines();
int linesNew = v.toInt();

// if change to one line staff, center by setting y offset 2 Spatium * lineDistance
if (linesNew == 1 && linesOld != 1)
m_staffType->setYoffset(Spatium(2 * m_staffType->lineDistance()));
else if (linesOld == 1 && linesNew != 1)
m_staffType->setYoffset(Spatium(0));
m_staffType->setLines(linesNew);
}
break;
case Pid::LINE_DISTANCE:
case Pid::LINE_DISTANCE: {
Spatium yOffset = m_staffType->yoffset() - 2 * m_staffType->lineDistance();
m_staffType->setLineDistance(v.value<Spatium>());
if (m_staffType->lines() == 1) {
m_staffType->setYoffset(yOffset + Spatium(2 * m_staffType->lineDistance()));
}
}
break;
case Pid::STAFF_SHOW_BARLINES:
m_staffType->setShowBarlines(v.toBool());
Expand Down

0 comments on commit 815e522

Please sign in to comment.