Skip to content

Commit

Permalink
Extend MusicXML color support
Browse files Browse the repository at this point in the history
Backport of musescore#19132 (plus another small change for articulations placement above/below)

* add color to breath marks and caesuras (+, export only)
* impove/extend breath marks and caesuras ex- and import (+)
* add color to chord symbols(+)
* add color to arpeggios (+)
* add color to pedal lines (+)
* add color to voltas (+)
* add color to textlines (+)
* add color to dynamics (+)
* import accidental brackets (+)

add color, placement(?) and visibility to figured bass
add color to ornaments
add color to slurs and ties
add color to fermata
add color to hairpins
add color to clef
add color to time signature
add color to accidentals
add color to articulations
export accidental brackets
fix color for glissando
unify tie and slur handling
add tuplet placement
add import of key color
add tuplet placement
also export WideDashed
accidental-mark on ornament
add color to ending
add placement to accidental-mark
color on trill-mark
add color to octave
import ending color
add textline color
export appearance
pedal color import
add support for curlew
bracket color only at start
import/export barline color
export fingering color
add another barlines test
add missing spannerStop for tempo change
export metronome and rehearsal color
tuplet color
hairpintext color
don't export invisible line
add color export test
improve figured bass import (not yet export)

Also fixes musescore#17841 (for 3.x)
  • Loading branch information
Jojo-Schmitz committed Nov 15, 2023
1 parent cc59cc3 commit 7561558
Show file tree
Hide file tree
Showing 25 changed files with 2,054 additions and 244 deletions.
226 changes: 165 additions & 61 deletions importexport/musicxml/exportxml.cpp

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions importexport/musicxml/importmxmlnotepitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ namespace Ms {

static Accidental* accidental(QXmlStreamReader& e, Score* score)
{
bool cautionary = e.attributes().value("cautionary") == "yes";
bool editorial = e.attributes().value("editorial") == "yes";
bool parentheses = e.attributes().value("parentheses") == "yes";
const bool cautionary = e.attributes().value("cautionary") == "yes";
const bool editorial = e.attributes().value("editorial") == "yes";
const bool parentheses = e.attributes().value("parentheses") == "yes";
const bool bracket = e.attributes().value("bracket") == "yes";
const QColor accColor = e.attributes().value("color").toString();
QString smufl = e.attributes().value("smufl").toString();

const auto s = e.readElementText();
Expand All @@ -40,10 +42,16 @@ static Accidental* accidental(QXmlStreamReader& e, Score* score)
if (type != AccidentalType::NONE) {
auto a = new Accidental(score);
a->setAccidentalType(type);
if (editorial || cautionary || parentheses) {
a->setBracket(AccidentalBracket(cautionary || parentheses));
if (cautionary || parentheses) {
a->setBracket(AccidentalBracket(AccidentalBracket::PARENTHESIS));
a->setRole(AccidentalRole::USER);
}
else if (editorial || bracket) {
a->setBracket(AccidentalBracket(AccidentalBracket::BRACKET));
a->setRole(AccidentalRole::USER);
}
if (accColor.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
a->setColor(accColor);
return a;
}

Expand Down
331 changes: 221 additions & 110 deletions importexport/musicxml/importmxmlpass2.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions importexport/musicxml/importmxmlpass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum class MusicXmlSlash : char {
struct MusicXmlTupletDesc {
MusicXmlTupletDesc();
MxmlStartStop type;
Placement placement;
Direction direction;
TupletBracketType bracket;
TupletNumberType shownumber;
};
Expand Down Expand Up @@ -307,7 +307,7 @@ class MusicXMLParserPass2 {
void backup(Fraction& dura);
void timeModification(Fraction& timeMod, TDuration& normalType);
void stem(Direction& sd, bool& nost);
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QString& text, const bool print);
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QColor color, const QString& text, const bool print);
void staffDetails(const QString& partId, Measure* measure = nullptr);
void staffTuning(StringData* t);
void addCopyrightVBox();
Expand Down
6 changes: 6 additions & 0 deletions libmscore/figuredbass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,12 @@ void FiguredBass::writeMusicXML(XmlWriter& xml, bool isOriginalFigure, int crEnd
QString stag = "figured-bass";
if (hasParentheses())
stag += " parentheses=\"yes\"";
if (placeAbove())
stag += " placement=\"above\"";
if (color() != MScore::defaultColor)
stag += QString(" color=\"%1\"").arg(color().name().toUpper());
if (!visible())
stag += " print-object=\"no\"";
xml.stag(stag);
for(FiguredBassItem* item : items)
item->writeMusicXML(xml, isOriginalFigure, crEndTick, fbEndTick);
Expand Down
4 changes: 2 additions & 2 deletions mtest/musicxml/io/testArpGliss3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<type>half</type>
<stem>down</stem>
<notations>
<glissando line-type="wavy" number="1" type="stop" color="#005500"/>
<glissando line-type="wavy" number="1" type="stop"/>
</notations>
</note>
</measure>
Expand Down Expand Up @@ -155,7 +155,7 @@
<type>half</type>
<stem>down</stem>
<notations>
<slide line-type="solid" number="1" type="stop" color="#AA0000"/>
<slide line-type="solid" number="1" type="stop"/>
</notations>
</note>
<barline location="right">
Expand Down
167 changes: 167 additions & 0 deletions mtest/musicxml/io/testBarStyles4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?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>All bar styles with color</work-title>
</work>
<identification>
<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>Flöte</part-name>
<part-abbreviation>Fl.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Flöte</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>
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#FF0000">dashed</bar-style>
</barline>
</measure>
<measure number="2">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#0FF000">dotted</bar-style>
</barline>
</measure>
<measure number="3">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#00FF00">heavy</bar-style>
</barline>
</measure>
<measure number="4">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#000FF0">heavy-heavy</bar-style>
</barline>
</measure>
<measure number="5">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#0000FF">heavy-light</bar-style>
</barline>
</measure>
<measure number="6">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#F0000F">light-heavy</bar-style>
</barline>
</measure>
<measure number="7">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#0F00F0">light-light</bar-style>
</barline>
</measure>
<measure number="8">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#F0F0F0">none</bar-style>
</barline>
</measure>
<measure number="9">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#0F0F0F">regular</bar-style>
</barline>
</measure>
<measure number="10">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#FFF000">short</bar-style>
</barline>
</measure>
<measure number="11">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style color="#000FFF">tick</bar-style>
</barline>
</measure>
<measure number="12">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
</measure>
</part>
</score-partwise>
Loading

0 comments on commit 7561558

Please sign in to comment.