@@ -468,6 +468,7 @@ class ExportMusicXml : public muse::Injectable
468
468
int m_tenths = 0 ;
469
469
bool m_tboxesAboveWritten = false ;
470
470
bool m_tboxesBelowWritten = false ;
471
+ std::vector<size_t > m_hiddenStaves;
471
472
TrillHash m_trillStart;
472
473
TrillHash m_trillStop;
473
474
MusicXmlInstrumentMap m_instrMap;
@@ -7444,13 +7445,19 @@ void ExportMusicXml::print(const Measure* const m, const int partNr, const int f
7444
7445
if (prevStaffNr == muse::nidx) {
7445
7446
continue ;
7446
7447
}
7448
+ if (!system->staff (staffNr)->show ()) {
7449
+ m_hiddenStaves.push_back (staffIdx);
7450
+ continue ;
7451
+ }
7447
7452
const RectF& prevBbox = system->staff (prevStaffNr)->bbox ();
7448
7453
const double staffDist = system->staff (staffNr)->bbox ().y () - prevBbox.y () - prevBbox.height ();
7449
7454
7450
7455
if (staffDist > 0 ) {
7451
7456
m_xml.startElement (" staff-layout" , { { " number" , staffIdx + 1 } });
7452
7457
m_xml.tag (" staff-distance" , String::number (getTenthsFromDots (staffDist), 2 ));
7453
7458
m_xml.endElement ();
7459
+ } else {
7460
+ m_hiddenStaves.push_back (staffIdx);
7454
7461
}
7455
7462
}
7456
7463
@@ -7909,29 +7916,41 @@ static void clampMusicXmlOctave(int& octave)
7909
7916
Write the staff details for \a part to \a xml.
7910
7917
*/
7911
7918
7912
- static void writeStaffDetails (XmlWriter& xml, const Part* part)
7919
+ static void writeStaffDetails (XmlWriter& xml, const Part* part, const std::vector< size_t > hiddenStaves )
7913
7920
{
7914
7921
const Instrument* instrument = part->instrument ();
7915
- size_t staves = part->nstaves ();
7922
+ const size_t staves = part->nstaves ();
7916
7923
7917
7924
// staff details
7918
- // TODO: decide how to handle linked regular / TAB staff
7919
- // currently exported as a two staff part ...
7920
7925
for (size_t i = 0 ; i < staves; i++) {
7921
7926
Staff* st = part->staff (i);
7922
7927
const double mag = st->staffMag (Fraction (0 , 1 ));
7928
+ bool hidden = false ;
7929
+ if (!st->show ()) {
7930
+ hidden = true ;
7931
+ } else {
7932
+ for (size_t staffIdx : hiddenStaves) {
7933
+ if (i == staffIdx) {
7934
+ hidden = true ;
7935
+ }
7936
+ }
7937
+ }
7923
7938
const Color lineColor = st->color (Fraction (0 , 1 ));
7924
7939
const bool invis = st->isLinesInvisible (Fraction (0 , 1 ));
7925
7940
const bool needsLineDetails = invis || lineColor != engravingConfiguration ()->defaultColor ();
7926
7941
if (st->lines (Fraction (0 , 1 )) != 5 || st->isTabStaff (Fraction (0 , 1 )) || !muse::RealIsEqual (mag, 1.0 )
7927
- || !st-> show () || needsLineDetails) {
7942
+ || hidden || needsLineDetails) {
7928
7943
XmlWriter::Attributes attributes;
7929
7944
if (staves > 1 ) {
7930
- attributes.push_back ({ " number" , i + 1 } );
7945
+ attributes.emplace_back ( std::make_pair ( " number" , i + 1 ) );
7931
7946
}
7932
- if (!st->show ()) {
7933
- attributes.push_back ({ " print-object" , " no" });
7947
+ if (hidden) {
7948
+ attributes.emplace_back (std::make_pair (" print-object" , " no" ));
7949
+ if (st->cutaway ()) {
7950
+ attributes.emplace_back (std::make_pair (" print-spacing" , " yes" ));
7951
+ }
7934
7952
}
7953
+
7935
7954
xml.startElement (" staff-details" , attributes);
7936
7955
7937
7956
if (i > 0 && st->links () && st->links ()->contains (part->staff (i - 1 ))) {
@@ -8494,9 +8513,24 @@ void ExportMusicXml::writeMeasure(const Measure* const m,
8494
8513
8495
8514
// output attributes with the first actual measure (pickup or regular) only
8496
8515
if (isFirstActualMeasure) {
8497
- writeStaffDetails (m_xml, part);
8516
+ writeStaffDetails (m_xml, part, m_hiddenStaves );
8498
8517
writeInstrumentDetails (part->instrument (), m_score->style ().styleB (Sid::concertPitch));
8518
+ } else {
8519
+ for (size_t staffIdx : m_hiddenStaves) {
8520
+ m_attr.doAttr (m_xml, true );
8521
+ XmlWriter::Attributes attributes;
8522
+ if (staves > 1 ) {
8523
+ attributes.emplace_back (std::make_pair (" number" , staffIdx + 1 ));
8524
+ }
8525
+ attributes.emplace_back (std::make_pair (" print-object" , " no" ));
8526
+ if (part->staff (staffIdx)->cutaway ()) {
8527
+ attributes.emplace_back (std::make_pair (" print-spacing" , " yes" ));
8528
+ }
8529
+ m_xml.tag (" staff-details" , attributes);
8530
+ m_attr.doAttr (m_xml, false );
8531
+ }
8499
8532
}
8533
+ m_hiddenStaves.clear ();
8500
8534
8501
8535
// output attribute at start of measure: measure-style
8502
8536
measureStyle (m_xml, m_attr, m, partIndex);
0 commit comments