Skip to content

Commit

Permalink
Merge pull request #822 from Isensee/25112-slur-on-grace-export
Browse files Browse the repository at this point in the history
fix #25112 export slur on grace notes
  • Loading branch information
lasconic committed Apr 19, 2014
2 parents ba34ec4 + 1300e50 commit 807e1da
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
32 changes: 27 additions & 5 deletions mscore/exportxml.cpp
Expand Up @@ -233,7 +233,7 @@ class SlurHandler {

public:
SlurHandler();
void doSlurStart(Chord* chord, Notations& notations, Xml& xml);
void doSlurStart(Chord* chord, Notations& notations, Xml& xml, bool grace = false);
void doSlurStop(Chord* chord, Notations& notations, Xml& xml);
};

Expand Down Expand Up @@ -445,8 +445,28 @@ int SlurHandler::findSlur(const Slur* s) const
// doSlurStart
//---------------------------------------------------------

void SlurHandler::doSlurStart(Chord* chord, Notations& notations, Xml& xml)
void SlurHandler::doSlurStart(Chord* chord, Notations& notations, Xml& xml, bool grace)
{
// slurs on grace notes are not in spanner list, therefore:
if (grace){
foreach(Element* el, chord->el()){
if (el->type() == Element::SLUR){
const Slur* s = static_cast<const Slur*>(el);
//define line type
QString rest = slurTieLineStyle(s);
int i = findSlur(0);
if (i >= 0) {
slur[i] = s;
started[i] = true;
notations.tag(xml);
xml.tagE(QString("slur%1 type=\"start\" number=\"%2\"").arg(rest).arg(i + 1));
}
else
qDebug("no free slur slot");
}
}
return;
}
// search for slur(s) starting at this chord
int tick = chord->tick();
auto sl = chord->score()->spanner();
Expand Down Expand Up @@ -2309,9 +2329,11 @@ void ExportMusicXml::chord(Chord* chord, int staff, const QList<Lyrics*>* ll, bo
}

if (note == nl.front()) {
tupletStartStop(chord, notations, xml);
if (!grace) {
// handle slurs between normal (non-grace) notes
if (grace){
sh.doSlurStart(chord, notations, xml, true);
}
else {
tupletStartStop(chord, notations, xml);
sh.doSlurStop(chord, notations, xml);
sh.doSlurStart(chord, notations, xml);
}
Expand Down
4 changes: 4 additions & 0 deletions mscore/importxml.cpp
Expand Up @@ -4153,6 +4153,10 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int ticks, QDomE
bool endSlur = false;
if (slur[slurNo] == 0) {
slur[slurNo] = new Slur(score);
if(cr->isGrace()){
slur[slurNo]->setAnchor(Spanner::ANCHOR_CHORD);
slur[slurNo]->setParent(cr);
}
if (lineType == "dotted")
slur[slurNo]->setLineType(1);
else if (lineType == "dashed")
Expand Down
2 changes: 2 additions & 0 deletions mscore/scoreview.cpp
Expand Up @@ -4105,6 +4105,8 @@ void ScoreView::cmdAddSlur(Note* firstNote, Note* lastNote)

slur->setStartChord(static_cast<Chord*>(cr1));
slur->setEndChord(static_cast<Chord*>(cr2));
slur->setTick(cr1->tick());
slur->setTick2(cr2->tick());
slur->setTrack(cr1->track());
slur->setTrack2(cr2->track());
slur->setParent(cr1);
Expand Down

0 comments on commit 807e1da

Please sign in to comment.