Skip to content

Commit 3ea0a16

Browse files
committed
<print-object> tags indicate hide empty staves
1 parent 04ad3a0 commit 3ea0a16

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ void MusicXMLParserPass2::attributes(const QString& partId, Measure* measure, co
23502350
} else if (_e.name() == "measure-style") {
23512351
measureStyle(measure);
23522352
} else if (_e.name() == "staff-details") {
2353-
staffDetails(partId);
2353+
staffDetails(partId, measure);
23542354
} else if (_e.name() == "time") {
23552355
time(partId, measure, tick);
23562356
} else if (_e.name() == "transpose") {
@@ -2383,7 +2383,7 @@ static void setStaffLines(Score* score, staff_idx_t staffIdx, int stafflines)
23832383
Parse the /score-partwise/part/measure/attributes/staff-details node.
23842384
*/
23852385

2386-
void MusicXMLParserPass2::staffDetails(const QString& partId)
2386+
void MusicXMLParserPass2::staffDetails(const QString& partId, Measure* measure)
23872387
{
23882388
//logDebugTrace("MusicXMLParserPass2::staffDetails");
23892389

@@ -2409,7 +2409,20 @@ void MusicXMLParserPass2::staffDetails(const QString& partId)
24092409
StringData* t = new StringData;
24102410
QString visible = _e.attributes().value("print-object").toString();
24112411
if (visible == "no") {
2412-
_score->staff(staffIdx)->setVisible(false);
2412+
if (measure && !measure->hasVoices(staffIdx) && measure->isOnlyRests(0)) {
2413+
// measures with print-object="no" are generally exported by exporters such as dolet when empty staves are hidden.
2414+
// for this reason, if we see an empty measure with print-object="no", we can assume that this indicates we should set
2415+
// the hide empty staves style.
2416+
_score->setStyleValue(Sid::hideEmptyStaves, true);
2417+
_score->setStyleValue(Sid::dontHideStavesInFirstSystem, false);
2418+
} else if (measure) {
2419+
// this is a measure with things in it, but is also print-object="no". I assume that means that the measure itself needs
2420+
// to be hidden, not the entire staff.
2421+
measure->setStaffVisible(staffIdx, false);
2422+
} else {
2423+
// this doesn't apply to a measure, so we'll assume the entire staff has to be hidden.
2424+
_score->staff(staffIdx)->setVisible(false);
2425+
}
24132426
} else if (!visible.isEmpty() && visible != "yes") {
24142427
_logger->logError(QString("print-object should be \"yes\" or \"no\""));
24152428
}

src/importexport/musicxml/internal/musicxml/importmxmlpass2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class MusicXMLParserPass2
305305
void stem(DirectionV& sd, bool& nost);
306306
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QString& text,
307307
const bool print);
308-
void staffDetails(const QString& partId);
308+
void staffDetails(const QString& partId, Measure* measure = nullptr);
309309
void staffTuning(StringData* t);
310310
void skipLogCurrElem();
311311

0 commit comments

Comments
 (0)