Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #22098: staff distance with hidden staves #25960

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class ExportMusicXml : public muse::Injectable
void keysigTimesig(const Measure* m, const Part* p);
void chordAttributes(Chord* chord, Notations& notations, Technical& technical, TrillHash& trillStart, TrillHash& trillStop);
void wavyLineStartStop(const ChordRest* cr, Notations& notations, Ornaments& ornaments, TrillHash& trillStart, TrillHash& trillStop);
void print(const Measure* const m, const int partNr, const int firstStaffOfPart, const int nrStavesInPart,
void print(const Measure* const m, const int partNr, const int firstStaffOfPart, const staff_idx_t nrStavesInPart,
const MeasurePrintContext& mpc);
void measureLayout(const double distance);
void findAndExportClef(const Measure* const m, const int staves, const track_idx_t strack, const track_idx_t etrack);
Expand Down Expand Up @@ -7168,7 +7168,7 @@ static bool hasPageBreak(const System* const system)
*/

void ExportMusicXml::print(const Measure* const m, const int partNr, const int firstStaffOfPart,
const int nrStavesInPart, const MeasurePrintContext& mpc)
const staff_idx_t nrStavesInPart, const MeasurePrintContext& mpc)
{
const MeasureBase* const prevSysMB = lastMeasureBase(mpc.prevSystem);

Expand Down Expand Up @@ -7250,15 +7250,21 @@ void ExportMusicXml::print(const Measure* const m, const int partNr, const int f
}

// Staff layout elements.
for (int staffIdx = (firstStaffOfPart == 0) ? 1 : 0; staffIdx < nrStavesInPart; staffIdx++) {
for (staff_idx_t staffIdx = (firstStaffOfPart == 0) ? 1 : 0; staffIdx < nrStavesInPart; staffIdx++) {
// calculate distance between this and previous staff using the bounding boxes
const int staffNr = firstStaffOfPart + staffIdx;
const RectF& prevBbox = system->staff(staffNr - 1)->bbox();
const staff_idx_t staffNr = firstStaffOfPart + staffIdx;
const staff_idx_t prevStaffNr = system->prevVisibleStaff(staffNr);
if (prevStaffNr == muse::nidx) {
continue;
}
const RectF& prevBbox = system->staff(prevStaffNr)->bbox();
const double staffDist = system->staff(staffNr)->bbox().y() - prevBbox.y() - prevBbox.height();

m_xml.startElement("staff-layout", { { "number", staffIdx + 1 } });
m_xml.tag("staff-distance", String::number(getTenthsFromDots(staffDist), 2));
m_xml.endElement();
if (staffDist > 0) {
m_xml.startElement("staff-layout", { { "number", staffIdx + 1 } });
m_xml.tag("staff-distance", String::number(getTenthsFromDots(staffDist), 2));
m_xml.endElement();
}
}

// Measure layout elements.
Expand Down Expand Up @@ -8239,7 +8245,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m,

m_xml.startElementRaw(measureTag);

print(m, partIndex, staffCount, static_cast<int>(staves), mpc);
print(m, partIndex, staffCount, staves, mpc);

m_attr.start();

Expand Down