Skip to content

Commit

Permalink
center one-line staff
Browse files Browse the repository at this point in the history
  • Loading branch information
sammik committed Dec 30, 2023
1 parent 602a95d commit 06516e4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/engraving/dom/stafftypechange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,21 @@ bool StaffTypeChange::setProperty(Pid propertyId, const PropertyValue& v)
case Pid::STEP_OFFSET:
m_staffType->setStepOffset(v.toInt());
break;
case Pid::STAFF_LINES:
m_staffType->setLines(v.toInt());
break;
case Pid::STAFF_LINES: {
int linesOld = m_staffType->lines();
int linesNew = v.toInt();
Spatium yOffset = m_staffType->yoffset();

// if change to one line staff, center by setting y offset 2
if (linesNew == 1 && linesOld != 1) {
m_staffType->setYoffset(yOffset + Spatium(2));
} else if (linesOld == 1 && linesNew != 1) {
m_staffType->setYoffset(yOffset - Spatium(2));
}

m_staffType->setLines(linesNew);
}
break;
case Pid::LINE_DISTANCE:
m_staffType->setLineDistance(v.value<Spatium>());
break;
Expand Down

0 comments on commit 06516e4

Please sign in to comment.