Fix #268968: MusicXML import export lyric color

This commit is contained in:
Giuseppe de Beer 2018-01-30 22:06:50 +01:00
parent 9c17edd9c2
commit 8448417ed2
4 changed files with 200 additions and 0 deletions

View file

@ -3766,6 +3766,7 @@ void ExportMusicXml::lyrics(const std::vector<Lyrics*>* ll, const int trk)
if (l && !l->xmlText().isEmpty()) {
if ((l)->track() == trk) {
QString lyricXml = QString("lyric number=\"%1\"").arg((l)->no() + 1);
lyricXml += color2xml(l);
lyricXml += addPositioningAttributes(l);
xml.stag(lyricXml);
Lyrics::Syllabic syl = (l)->syllabic();

View file

@ -5487,6 +5487,8 @@ void MusicXMLParserPass2::lyric(QMap<int, Lyrics*>& numbrdLyrics,
bool hasExtend = false;
QString strLyricNo = _e.attributes().value("number").toString();
QColor lyricColor = QColor::Invalid;
lyricColor.setNamedColor(_e.attributes().value("color").toString());
QString strDefaultY = _e.attributes().value("default-y").toString();
QString extendType;
QString formattedText;
@ -5564,6 +5566,8 @@ void MusicXMLParserPass2::lyric(QMap<int, Lyrics*>& numbrdLyrics,
//qDebug("formatted lyric '%s'", qPrintable(formattedText));
l->setXmlText(formattedText);
if (lyricColor != QColor::Invalid)
l->setColor(lyricColor);
}

View file

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<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>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</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>1</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>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<lyric number="1">
<syllabic>begin</syllabic>
<text>Ro</text>
</lyric>
</note>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<lyric number="1">
<syllabic>end</syllabic>
<text>ses</text>
</lyric>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<lyric number="1">
<syllabic>single</syllabic>
<text>are</text>
</lyric>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>3</duration>
<voice>1</voice>
<type>half</type>
<dot/>
<stem>up</stem>
<lyric number="1" color="#FF0000">
<syllabic>single</syllabic>
<text>red,</text>
</lyric>
</note>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<lyric number="1">
<syllabic>single</syllabic>
<text>and</text>
</lyric>
</note>
</measure>
<measure number="3">
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
<lyric number="1">
<syllabic>begin</syllabic>
<text>vio</text>
</lyric>
</note>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<lyric number="1">
<syllabic>single</syllabic>
<text>lets</text>
</lyric>
</note>
<note>
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<lyric number="1">
<syllabic>single</syllabic>
<text>are</text>
</lyric>
</note>
</measure>
<measure number="4">
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<lyric number="1" color="#0000FF">
<syllabic>single</syllabic>
<text>blue.</text>
</lyric>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>

View file

@ -105,6 +105,7 @@ private slots:
void keysig2() { mxmlIoTest("testKeysig2"); }
void lines1() { mxmlIoTest("testLines1"); }
void lines2() { mxmlIoTest("testLines2"); }
void lyricColor() { mxmlIoTest("testLyricColor"); }
void lyrics1() { mxmlIoTestRef("testLyrics1"); }
void lyricsVoice2a() { mxmlIoTest("testLyricsVoice2a"); }
void lyricsVoice2b() { mxmlIoTestRef("testLyricsVoice2b"); }