From 06516e48d02016becc2c538800d3331e358ee812 Mon Sep 17 00:00:00 2001 From: sammik Date: Sat, 2 Dec 2023 09:43:52 +0100 Subject: [PATCH] center one-line staff --- src/engraving/dom/stafftypechange.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/engraving/dom/stafftypechange.cpp b/src/engraving/dom/stafftypechange.cpp index d443fbad0fe76..671c816d7c53d 100644 --- a/src/engraving/dom/stafftypechange.cpp +++ b/src/engraving/dom/stafftypechange.cpp @@ -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()); break;