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

Add import/export of invisible clefs to MusicXML #19605

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -6750,7 +6750,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 @@ -6980,13 +6984,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 @@ -3947,8 +3947,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 @@ -4059,6 +4060,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