Skip to content

Commit

Permalink
Read 'print-object' for directions and write for tempo
Browse files Browse the repository at this point in the history
Backport of musescore#22577
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Apr 26, 2024
1 parent ff7f31e commit 4f11ad6
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
2 changes: 2 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4450,6 +4450,8 @@ static void wordsMetronome(XmlWriter& xml, Score* s, TextBase const* const text,
QString tagName = QString("metronome parentheses=\"%1\"").arg(hasParen ? "yes" : "no");
tagName += color2xml(text);
tagName += positioningAttributes(text);
if (!text->visible())
tagName += " print-object=\"no\"";
xml.stag(tagName);
int len1 = 0;
TDuration dur;
Expand Down
10 changes: 9 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3257,6 +3257,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
if (tt->plainText().contains('='))
tt->setFollowText(true);
}
tt->setVisible(_visible);

addElemOffset(tt, track, placement(), measure, tick + _offset);
}
Expand Down Expand Up @@ -3325,6 +3326,8 @@ void MusicXMLParserDirection::direction(const QString& partId,
t->setPropertyFlags(Pid::COLOR, PropertyFlags::UNSTYLED);
}

t->setVisible(_visible);

QString wordsPlacement = placement();
// Case-based defaults
if (wordsPlacement.isEmpty()) {
Expand Down Expand Up @@ -3382,9 +3385,11 @@ void MusicXMLParserDirection::direction(const QString& partId,
dynaValue = 127;
else if (dynaValue < 0)
dynaValue = 0;
dyn->setVelocity( dynaValue );
dyn->setVelocity(dynaValue);
}

dyn->setVisible(_visible);

QString dynamicsPlacement = placement();
// Case-based defaults
if (dynamicsPlacement.isEmpty())
Expand Down Expand Up @@ -3473,6 +3478,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
else
spannerPlacement = totalY() < 0 ? "above" : "below";
}
desc._sp->setVisible(_visible);
if (spdesc._isStopped) {
_pass2.addSpanner(desc);
// handleSpannerStart and handleSpannerStop must be called in order
Expand Down Expand Up @@ -3514,6 +3520,7 @@ void MusicXMLParserDirection::directionType(QList<MusicXmlSpannerDesc>& starts,
_hasDefaultY |= hasDefaultYCandidate;
_hasRelativeY |= hasRelativeYCandidate;
_isBold &= _e.attributes().value("font-weight").toString() == "bold";
_visible = _e.attributes().value("print-object") != "no";
QString number = _e.attributes().value("number").toString();
int n = 0;
if (!number.isEmpty()) {
Expand Down Expand Up @@ -4202,6 +4209,7 @@ void MusicXMLParserDirection::handleRepeats(Measure* measure, const int track, c
measure = measure->prevMeasure();
else if (tb->tid() == Tid::REPEAT_LEFT && !closerToLeft && measure->nextMeasure())
measure = measure->nextMeasure();
tb->setVisible(_visible);
measure->add(tb);
}
}
Expand Down
1 change: 1 addition & 0 deletions importexport/musicxml/importmxmlpass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ class MusicXMLParserDirection {
bool _isBold;
double _tpoMetro; // tempo according to metronome
double _tpoSound; // tempo according to sound
bool _visible = true;
QList<Element*> _elems;
Fraction _offset;

Expand Down
84 changes: 84 additions & 0 deletions mtest/musicxml/io/testInvisibleDirection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>Untitled score</work-title>
</work>
<identification>
<creator type="composer">Composer / arranger</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Flute</part-name>
<part-abbreviation>Fl.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Flute</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>74</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction-type>
<metronome parentheses="no"print-object="no">
<beat-unit>quarter</beat-unit>
<per-minute>64</per-minute>
</metronome>
</direction-type>
<sound tempo="64"/>
</direction>
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
</measure>
<measure number="2">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
</measure>
<measure number="3">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
1 change: 1 addition & 0 deletions mtest/musicxml/io/tst_mxml_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private slots:
void instrumentSound() { mxmlIoTestRef("testInstrumentSound"); }
void invalidLayout() { mxmlMscxExportTestRef("testInvalidLayout"); }
void invalidTimesig() { mxmlIoTestRef("testInvalidTimesig"); }
void invisibleDirection() { mxmlIoTest("testInvisibleDirection"); }
void invisibleElements() { mxmlIoTest("testInvisibleElements"); }
void keysig1() { mxmlIoTest("testKeysig1"); }
void keysig2() { mxmlIoTest("testKeysig2"); }
Expand Down

0 comments on commit 4f11ad6

Please sign in to comment.