Skip to content

Commit

Permalink
Merge pull request #5899 from KartikShrivastava/good-first-issue-gsoc
Browse files Browse the repository at this point in the history
fix #57791: Importing chord symbol in capx
  • Loading branch information
anatoly-os committed Apr 10, 2020
2 parents c1bc992 + b3fa39e commit f91dc43
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
29 changes: 28 additions & 1 deletion mscore/capella.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "libmscore/hairpin.h"
#include "libmscore/sym.h"
#include "libmscore/articulation.h"
#include "libmscore/harmony.h"

extern QString rtf2html(const QString &);

Expand Down Expand Up @@ -337,7 +338,6 @@ static void processBasicDrawObj(QList<BasicDrawObj*> objects, Segment* s, int tr
QPointF p(st->pos());
p = p / 32.0 * score->spatium();
// text->setUserOff(st->pos());
text->setAutoplace(false);
text->setOffset(p);
// qDebug("setText %s (%f %f)(%f %f) <%s>",
// qPrintable(st->font().family()),
Expand All @@ -361,6 +361,33 @@ static void processBasicDrawObj(QList<BasicDrawObj*> objects, Segment* s, int tr
s->add(text);
}
break;
case CapellaType::TRANSPOSABLE:
{
TransposableObj* to = static_cast<TransposableObj*>(oo);
QString str = "";
for (BasicDrawObj* bdo : to->variants) {
SimpleTextObj* st = static_cast<SimpleTextObj*>(bdo);
if (st->font().family() == "capella3") {
for (const QChar& ch : st->text()) {
if (ch == 'Q')
str += "b";
else if (ch == 'S')
str += "#";
else if (ch == 'R')
str += "natural";
else
str += ch;
}
}
else
str += st->text();
}
Harmony* harmony = new Harmony(score);
harmony->setHarmony(str);
harmony->setTrack(track);
s->add(harmony);
break;
}
case CapellaType::TEXT:
qDebug("======================Text:");
break;
Expand Down
1 change: 1 addition & 0 deletions mscore/capella.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class TransposableObj : public BasicDrawObj {
public:
TransposableObj(Capella* c) : BasicDrawObj(CapellaType::TRANSPOSABLE, c) {}
void read();
void readCapx(XmlReader& e);

QPointF relPos;
char b { 0 };
Expand Down
31 changes: 29 additions & 2 deletions mscore/capxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,31 @@ void SimpleTextObj::readCapx(XmlReader& e)
}
}

//---------------------------------------------------------
// TransposableObj::readCapx -- capx equivalent of TransposableObj::read
//---------------------------------------------------------

void TransposableObj::readCapx(XmlReader& e)
{
QString enharmonicNote = e.attribute("base");
while (e.readNextStartElement()) {
const QStringRef& tag1(e.name());
if (tag1 == "drawObj") {
if (e.attribute("base") == enharmonicNote) {
while (e.readNextStartElement()) {
const QStringRef& tag2(e.name());
if (tag2 == "group") {
variants.append(cap->readCapxDrawObjectArray(e));
}
}
}
else {
e.skipCurrentElement();
}
}
}
}

//---------------------------------------------------------
// SlurObj::readCapx -- capx equivalent of SlurObj::read
//---------------------------------------------------------
Expand Down Expand Up @@ -663,8 +688,10 @@ QList<BasicDrawObj*> Capella::readCapxDrawObjectArray(XmlReader& e)
ol.append(o);
}
else if (tag == "transposable") {
qDebug("readCapxDrawObjectArray: found transposable (skipping)");
e.skipCurrentElement();
TransposableObj* o = new TransposableObj(this);
bdo = o; // save o to handle the "basic" tag (which sometimes follows)
o->readCapx(e);
ol.append(o);
}
else if (tag == "group") {
qDebug("readCapxDrawObjectArray: found group (skipping)");
Expand Down
3 changes: 0 additions & 3 deletions mtest/capella/io/testText1.capx-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@
<sigD>4</sigD>
</TimeSig>
<StaffText>
<autoplace>0</autoplace>
<text>Test text 1</text>
</StaffText>
<StaffText>
<autoplace>0</autoplace>
<text>This is the subtitle</text>
</StaffText>
<Chord>
Expand Down Expand Up @@ -178,7 +176,6 @@
</Note>
</Chord>
<StaffText>
<autoplace>0</autoplace>
<text>MuseScore testfile
Leon Vinken</text>
</StaffText>
Expand Down
3 changes: 0 additions & 3 deletions mtest/capella/io/testVolta1.capx-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
<sigD>4</sigD>
</TimeSig>
<StaffText>
<autoplace>0</autoplace>
<text>Volta 1</text>
</StaffText>
<StaffText>
<autoplace>0</autoplace>
<text>MuseScore testfile</text>
</StaffText>
<Chord>
Expand Down Expand Up @@ -134,7 +132,6 @@
</LayoutBreak>
<voice>
<StaffText>
<autoplace>0</autoplace>
<text>Leon Vinken</text>
</StaffText>
<Spanner type="Volta">
Expand Down

0 comments on commit f91dc43

Please sign in to comment.