Skip to content

Commit

Permalink
fix #108616 add more breath mark /caesura symbols to palette
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 19, 2016
1 parent afecf19 commit b5516f8
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 79 deletions.
72 changes: 51 additions & 21 deletions libmscore/breath.cpp
Expand Up @@ -20,11 +20,15 @@

namespace Ms {

SymId Breath::symList[Breath::breathSymbols] = {
SymId::breathMarkComma,
SymId::breathMarkComma, // TODO-smufl SymId(lcommaSym),
SymId::caesuraCurved,
SymId::caesura
const std::vector<BreathType> Breath::breathList {
{ SymId::breathMarkComma, false, 0.0 },
{ SymId::breathMarkTick, false, 0.0 },
{ SymId::breathMarkSalzedo, false, 0.0 },
{ SymId::breathMarkUpbow, false, 0.0 },
{ SymId::caesuraCurved, true, 0.0 },
{ SymId::caesura, true, 0.0 },
{ SymId::caesuraShort, true, 0.0 },
{ SymId::caesuraThick, true, 0.0 },
};

//---------------------------------------------------------
Expand All @@ -34,22 +38,35 @@ SymId Breath::symList[Breath::breathSymbols] = {
Breath::Breath(Score* s)
: Element(s)
{
_breathType = 0;
_symId = SymId::breathMarkComma;
_pause = 0.0;
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE);
}

//---------------------------------------------------------
// isCaesura
//---------------------------------------------------------

bool Breath::isCaesura() const
{
for (const BreathType& bt : breathList) {
if (bt.id == _symId)
return bt.isCaesura;
}
return false;
}

//---------------------------------------------------------
// layout
//---------------------------------------------------------

void Breath::layout()
{
if (_breathType >= 2)
if (isCaesura())
setPos(x(), spatium());
else
setPos(x(), -0.5 * spatium());
setbbox(symBbox(symList[breathType()]));
setbbox(symBbox(_symId));
}

//---------------------------------------------------------
Expand All @@ -61,7 +78,7 @@ void Breath::write(Xml& xml) const
if (!xml.canWrite(this))
return;
xml.stag("Breath");
xml.tag("subtype", _breathType);
xml.tag("symbol", Sym::id2name(_symId));
writeProperty(xml, P_ID::PAUSE);
Element::writeProperties(xml);
xml.etag();
Expand All @@ -75,8 +92,22 @@ void Breath::read(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "subtype")
_breathType = e.readInt();
if (tag == "subtype") { // obsolete
switch (e.readInt()) {
case 0:
case 1:
_symId = SymId::breathMarkComma;
break;
case 2:
_symId = SymId::caesuraCurved;
break;
case 3:
_symId = SymId::caesura;
break;
}
}
else if (tag == "symbol")
_symId = Sym::name2id(e.readElementText());
else if (tag == "pause")
_pause = e.readDouble();
else if (!Element::readProperties(e))
Expand All @@ -91,7 +122,7 @@ void Breath::read(XmlReader& e)
void Breath::draw(QPainter* p) const
{
p->setPen(curColor());
drawSymbol(symList[_breathType], p);
drawSymbol(_symId, p);
}

//---------------------------------------------------------
Expand All @@ -115,7 +146,9 @@ QPointF Breath::pagePos() const

QVariant Breath::getProperty(P_ID propertyId) const
{
switch(propertyId) {
switch (propertyId) {
case P_ID::SYMBOL:
return int(_symId);
case P_ID::PAUSE:
return _pause;
default:
Expand All @@ -129,7 +162,10 @@ QVariant Breath::getProperty(P_ID propertyId) const

bool Breath::setProperty(P_ID propertyId, const QVariant& v)
{
switch(propertyId) {
switch (propertyId) {
case P_ID::SYMBOL:
setSymId(SymId(v.toInt()));

case P_ID::PAUSE:
setPause(v.toDouble());
break;
Expand Down Expand Up @@ -181,13 +217,7 @@ Element* Breath::prevElement()

QString Breath::accessibleInfo() const
{
switch (breathType()) {
case 2:
case 3:
return tr("Caesura");
default:
return tr("Breath");
}
return Sym::id2userName(_symId);
}
}

22 changes: 17 additions & 5 deletions libmscore/breath.h
Expand Up @@ -21,6 +21,16 @@ namespace Ms {

enum class SymId;

//---------------------------------------------------------
// BreathType
//---------------------------------------------------------

struct BreathType {
SymId id;
bool isCaesura;
qreal pause;
};

//---------------------------------------------------------
// @@ Breath
//! breathType() is index in symList
Expand All @@ -29,18 +39,16 @@ enum class SymId;
class Breath : public Element {
Q_OBJECT

int _breathType;
qreal _pause;
static const int breathSymbols = 4;
static SymId symList[breathSymbols];
SymId _symId;

public:
Breath(Score* s);
virtual Element::Type type() const override { return Element::Type::BREATH; }
virtual Breath* clone() const override { return new Breath(*this); }

int breathType() const { return _breathType; }
void setBreathType(int v) { _breathType = v; }
void setSymId(SymId id) { _symId = id; }
SymId symId() const { return _symId; }
qreal pause() const { return _pause; }
void setPause(qreal v) { _pause = v; }

Expand All @@ -59,6 +67,10 @@ class Breath : public Element {
virtual Element* nextElement() override;
virtual Element* prevElement() override;
virtual QString accessibleInfo() const override;

bool isCaesura() const;

static const std::vector<BreathType> breathList;
};


Expand Down
1 change: 1 addition & 0 deletions libmscore/property.cpp
Expand Up @@ -249,6 +249,7 @@ static const PropertyData propertyList[] = {
{ P_ID::PLAYBACK_VOICE2, false, "playbackVoice2", P_TYPE::BOOL },
{ P_ID::PLAYBACK_VOICE3, false, "playbackVoice3", P_TYPE::BOOL },
{ P_ID::PLAYBACK_VOICE4, false, "playbackVoice4", P_TYPE::BOOL },
{ P_ID::SYMBOL, true, "symbol", P_TYPE::INT },

{ P_ID::END, false, "", P_TYPE::INT }
};
Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Expand Up @@ -241,6 +241,7 @@ enum class P_ID : int {
PLAYBACK_VOICE2,
PLAYBACK_VOICE3,
PLAYBACK_VOICE4,
SYMBOL,

END
};
Expand Down
3 changes: 1 addition & 2 deletions libmscore/sym.h
Expand Up @@ -2717,7 +2717,7 @@ class Sym {
static SymId oldName2id(const QString s) { return lonhash.value(s, SymId::noSym);}
static const char* id2name(SymId id);

static QString id2userName(SymId id) { return symUserNames[int(id)]; }
static QString id2userName(SymId id) { return symUserNames[int(id)]; }
static SymId userName2id(const QString& s);

static QVector<const char*> symNames;
Expand All @@ -2744,7 +2744,6 @@ struct GlyphKey {
bool operator==(const GlyphKey&) const;
};


struct GlyphPixmap {
QPixmap pm;
QPointF offset;
Expand Down
3 changes: 2 additions & 1 deletion mscore/capella.cpp
Expand Up @@ -52,6 +52,7 @@
#include "libmscore/arpeggio.h"
#include "libmscore/breath.h"
#include "libmscore/hairpin.h"
#include "libmscore/sym.h"

extern QString rtf2html(const QString &);

Expand Down Expand Up @@ -220,7 +221,7 @@ static void processBasicDrawObj(QList<BasicDrawObj*> objects, Segment* s, int tr
{
Breath* b = new Breath(score);
b->setTrack(track);
b->setBreathType(3);
b->setSymId(SymId::caesura);
Segment* seg = s->measure()->getSegment(Segment::Type::Breath, s->tick() + (cr ? cr->actualTicks() : 0));
seg->add(b);
}
Expand Down
6 changes: 1 addition & 5 deletions mscore/exportxml.cpp
Expand Up @@ -1950,11 +1950,7 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
if (Breath* b = hasBreathMark(chord)) {
notations.tag(xml);
articulations.tag(xml);
int st = b->breathType();
if (st == 0 || st == 1)
xml.tagE("breath-mark");
else
xml.tagE("caesura");
xml.tagE(b->isCaesura() ? "caesura" : "breath-mark");
}

for (Element* e : chord->el()) {
Expand Down
10 changes: 5 additions & 5 deletions mscore/importmxmlpass2.cpp
Expand Up @@ -5373,7 +5373,7 @@ void MusicXMLParserPass2::notations(Note* note, ChordRest* cr, const int tick,
int wavyLineNo = 0;
QString arpeggioType;
// QString glissandoType;
int breath = -1;
SymId breath = SymId::noSym;
int tremolo = 0;
QString tremoloType;
QString placement;
Expand Down Expand Up @@ -5531,12 +5531,12 @@ void MusicXMLParserPass2::notations(Note* note, ChordRest* cr, const int tick,
continue;
}
else if (_e.name() == "breath-mark") {
breath = 0;
breath = SymId::breathMarkComma;
_e.readElementText();
// TODO: handle value read (note: encoding unknown, only "comma" found)
}
else if (_e.name() == "caesura") {
breath = 3;
breath = SymId::caesura;
_e.readNext();
}
else if (_e.name() == "doit"
Expand Down Expand Up @@ -5773,11 +5773,11 @@ void MusicXMLParserPass2::notations(Note* note, ChordRest* cr, const int tick,
logError(QString("unknown wavy-line type %1").arg(wavyLineType));
}

if (breath >= 0) {
if (breath != SymId::noSym) {
Breath* b = new Breath(_score);
// b->setTrack(trk + voice); TODO check next line
b->setTrack(track);
b->setBreathType(breath);
b->setSymId(breath);
Segment* seg = measure->getSegment(Segment::Type::Breath, tick + ticks);
seg->add(b);
}
Expand Down
15 changes: 4 additions & 11 deletions mscore/menus.cpp
Expand Up @@ -634,18 +634,11 @@ Palette* MuseScore::newBreathPalette()
sp->setDrawGrid(true);
sp->setDrawGrid(true);

for (int i = 0; i < 4; ++i) {
if (i == 1) // do not add two similar breaths. //TODO add support for other break mark
continue;
for (BreathType bt : Breath::breathList) {
Breath* a = new Breath(gscore);
a->setBreathType(i);
if (i < 2) {
sp->append(a, tr("Breath"));
}
else {
sp->append(a, tr("Caesura"));
a->setPause(2.0);
}
a->setSymId(bt.id);
a->setPause(bt.pause);
sp->append(a, Sym::id2userName(bt.id));
}
return sp;
}
Expand Down
16 changes: 8 additions & 8 deletions mtest/libmscore/breath/breath01-ref.mscx
Expand Up @@ -161,7 +161,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<Chord>
<durationType>quarter</durationType>
Expand All @@ -171,7 +171,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
</Measure>
<Measure number="2">
Expand All @@ -183,7 +183,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<Chord>
<durationType>half</durationType>
Expand All @@ -193,7 +193,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<BarLine>
<subtype>end</subtype>
Expand All @@ -216,7 +216,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<Chord>
<durationType>half</durationType>
Expand All @@ -226,7 +226,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
</Measure>
<Measure number="2">
Expand All @@ -239,7 +239,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<Chord>
<durationType>quarter</durationType>
Expand All @@ -249,7 +249,7 @@
</Note>
</Chord>
<Breath>
<subtype>0</subtype>
<symbol>breathMarkComma</symbol>
</Breath>
<BarLine>
<subtype>end</subtype>
Expand Down

0 comments on commit b5516f8

Please sign in to comment.