Skip to content

Commit

Permalink
Merge pull request #19605 from rettinghaus/xml/visible
Browse files Browse the repository at this point in the history
Add import/export of invisible clefs to MusicXML
  • Loading branch information
RomanPudashkin committed Nov 15, 2023
2 parents 08c79f1 + 2543006 commit 71ebe8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6806,7 +6806,11 @@ void ExportMusicXml::findAndExportClef(const Measure* const m, const int staves,
if ((tick.isZero() || !cle->generated())
&& ((seg->measure() != m) || ((seg->segmentType() == SegmentType::HeaderClef) && !cle->otherClef()))) {
clefDebug("exportxml: clef exported");
clef(sstaff, cle->clefType(), color2xml(cle));
QString clefAttr = color2xml(cle);
if (!cle->visible()) {
clefAttr += " print-object=\"no\"";
}
clef(sstaff, cle->clefType(), clefAttr);
} else {
clefDebug("exportxml: clef not exported");
}
Expand Down Expand Up @@ -7036,13 +7040,14 @@ void ExportMusicXml::writeElement(EngravingItem* el, const Measure* m, staff_idx
// these will be output at the start of the next measure
const auto cle = toClef(el);
const auto ti = cle->segment()->tick();
const QString visible = (!cle->visible()) ? " print-object=\"no\"" : "";
clefDebug("exportxml: clef in measure ti=%d ct=%d gen=%d", ti, int(cle->clefType()), el->generated());
if (el->generated()) {
clefDebug("exportxml: generated clef not exported");
} else if (!el->generated() && tickIsInMiddleOfMeasure(ti, m)) {
clef(sstaff, cle->clefType(), color2xml(cle));
clef(sstaff, cle->clefType(), color2xml(cle) + visible);
} else if (!el->generated() && (ti == m->tick()) && (cle->segment()->segmentType() != SegmentType::HeaderClef)) {
clef(sstaff, cle->clefType(), color2xml(cle) + QString(" after-barline=\"yes\""));
clef(sstaff, cle->clefType(), color2xml(cle) + visible + QString(" after-barline=\"yes\""));
} else {
clefDebug("exportxml: clef not exported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3949,8 +3949,9 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr
int i = 0;
int line = -1;

QString strClefno = _e.attributes().value("number").toString();
const QString strClefno = _e.attributes().value("number").toString();
const bool afterBarline = _e.attributes().value("after-barline") == "yes";
const bool printObject = _e.attributes().value("print-object") != "no";

while (_e.readNextStartElement()) {
if (_e.name() == "sign") {
Expand Down Expand Up @@ -4065,6 +4066,7 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr

Clef* clefs = Factory::createClef(s);
clefs->setClefType(clef);
clefs->setVisible(printObject);
track_idx_t track = _pass1.trackForPart(partId) + clefno * VOICES;
clefs->setTrack(track);
s->add(clefs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<clef print-object="no">
<sign>G</sign>
<line>2</line>
</clef>
Expand Down

0 comments on commit 71ebe8f

Please sign in to comment.