move Ottava::Type into OttavaType

This commit is contained in:
Werner Schweer 2017-03-08 14:18:34 +01:00
parent 867f2582f6
commit 129d508144
21 changed files with 81 additions and 72 deletions

View file

@ -23,6 +23,7 @@
#include "xml.h"
#include "marker.h"
#include "stafflines.h"
#include "spanner.h"
namespace Ms {

View file

@ -31,6 +31,7 @@
#include "stemslash.h"
#include "groups.h"
#include "xml.h"
#include "spanner.h"
namespace Ms {

View file

@ -3201,8 +3201,8 @@ void Score::cmd(const QAction* a)
{ "add-trill", [this]{ addArticulation(SymId::ornamentTrill); }},
{ "add-up-bow", [this]{ addArticulation(SymId::stringsUpBow); }},
{ "add-down-bow", [this]{ addArticulation(SymId::stringsDownBow); }},
{ "add-8va", [this]{ cmdAddOttava(Ottava::Type::OTTAVA_8VA); }},
{ "add-8vb", [this]{ cmdAddOttava(Ottava::Type::OTTAVA_8VB); }},
{ "add-8va", [this]{ cmdAddOttava(OttavaType::OTTAVA_8VA); }},
{ "add-8vb", [this]{ cmdAddOttava(OttavaType::OTTAVA_8VB); }},
{ "note-longa", [this]{ padToggle(Pad::NOTE00); }},
{ "note-longa-TAB", [this]{ padToggle(Pad::NOTE00); }},
{ "note-breve", [this]{ padToggle(Pad::NOTE0); }},

View file

@ -48,6 +48,7 @@
#include "repeat.h"
#include "textframe.h"
#include "accidental.h"
#include "ottava.h"
namespace Ms {
@ -1151,7 +1152,7 @@ void Score::cmdAddTie()
// cmdAddOttava
//---------------------------------------------------------
void Score::cmdAddOttava(Ottava::Type type)
void Score::cmdAddOttava(OttavaType type)
{
Selection sel = selection();
ChordRest* cr1;

View file

@ -14,6 +14,7 @@
#include "measure.h"
#include "undo.h"
#include "range.h"
#include "spanner.h"
namespace Ms {

View file

@ -228,7 +228,7 @@ void MScore::init()
qRegisterMetaType<FiguredBassItem::Parenthesis>("Parenthesis");
qRegisterMetaType<FiguredBassItem::ContLine>("ContLine");
qRegisterMetaType<Volta::Type>("VoltaType");
qRegisterMetaType<Ottava::Type>("OttavaType");
qRegisterMetaType<OttavaType>("OttavaType");
qRegisterMetaType<Trill::Type>("TrillType");
qRegisterMetaType<Dynamic::Range>("DynamicRange");
qRegisterMetaType<Jump::Type>("JumpType");

View file

@ -39,7 +39,7 @@ struct OttavaDefault {
const char* numbersOnlyName;
};
// order is important, should be the same as Ottava::Type
// order is important, should be the same as OttavaType
static const OttavaDefault ottavaDefault[] = {
{ SymId::ottavaAlta, SymId::ottava, QPointF(0.0, .7), 1.0, Element::Placement::ABOVE, 12, "8va", "8" },
{ SymId::ottavaBassaBa, SymId::ottava, QPointF(0.0, -1.0), -1.0, Element::Placement::BELOW, -12, "8vb", "8" },
@ -238,7 +238,7 @@ Ottava::Ottava(Score* s)
setFlag(ElementFlag::ON_STAFF, true);
_numbersOnly = score()->styleB(StyleIdx::ottavaNumbersOnly);
setOttavaType(Type::OTTAVA_8VA);
setOttavaType(OttavaType::OTTAVA_8VA);
resetProperty(P_ID::LINE_WIDTH);
resetProperty(P_ID::LINE_STYLE);
@ -264,7 +264,7 @@ Ottava::Ottava(const Ottava& o)
// setOttavaType
//---------------------------------------------------------
void Ottava::setOttavaType(Type val)
void Ottava::setOttavaType(OttavaType val)
{
_ottavaType = val;
@ -343,7 +343,7 @@ bool Ottava::readProperties(XmlReader& e)
bool ok;
int idx = s.toInt(&ok);
if (!ok) {
idx = int(Type::OTTAVA_8VA);
idx = int(OttavaType::OTTAVA_8VA);
for (unsigned i = 0; i < sizeof(ottavaDefault)/sizeof(*ottavaDefault); ++i) {
if (s == ottavaDefault[i].name) {
idx = i;
@ -358,7 +358,7 @@ bool Ottava::readProperties(XmlReader& e)
else if (idx == 2)
idx = 1;
}
setOttavaType(Type(idx));
setOttavaType(OttavaType(idx));
}
else if (tag == "numbersOnly") {
_numbersOnly = e.readInt();
@ -375,7 +375,7 @@ bool Ottava::readProperties(XmlReader& e)
// undoSetOttavaType
//---------------------------------------------------------
void Ottava::undoSetOttavaType(Type val)
void Ottava::undoSetOttavaType(OttavaType val)
{
undoChangeProperty(P_ID::OTTAVA_TYPE, int(val));
}
@ -415,7 +415,7 @@ bool Ottava::setProperty(P_ID propertyId, const QVariant& val)
{
switch (propertyId) {
case P_ID::OTTAVA_TYPE:
setOttavaType(Type(val.toInt()));
setOttavaType(OttavaType(val.toInt()));
break;
case P_ID::PLACEMENT:

View file

@ -28,6 +28,19 @@ struct OttavaE {
unsigned end;
};
//---------------------------------------------------------
// OttavaType
//---------------------------------------------------------
enum class OttavaType : char {
OTTAVA_8VA,
OTTAVA_8VB,
OTTAVA_15MA,
OTTAVA_15MB,
OTTAVA_22MA,
OTTAVA_22MB
};
class Ottava;
//---------------------------------------------------------
@ -61,21 +74,8 @@ class OttavaSegment : public TextLineBaseSegment {
class Ottava : public TextLineBase {
Q_GADGET
Q_PROPERTY(Ms::Ottava::Type ottavaType READ ottavaType WRITE undoSetOttavaType)
Q_ENUMS(Type)
public:
enum Type : char {
OTTAVA_8VA,
OTTAVA_8VB,
OTTAVA_15MA,
OTTAVA_15MB,
OTTAVA_22MA,
OTTAVA_22MB
};
private:
Type _ottavaType;
OttavaType _ottavaType;
bool _numbersOnly;
PropertyFlags numbersOnlyStyle { PropertyFlags::STYLED };
@ -87,18 +87,18 @@ class Ottava : public TextLineBase {
public:
Ottava(Score* s);
Ottava(const Ottava&);
virtual Ottava* clone() const override { return new Ottava(*this); }
virtual Ottava* clone() const override { return new Ottava(*this); }
virtual ElementType type() const override { return ElementType::OTTAVA; }
void setOttavaType(Type val);
Type ottavaType() const { return _ottavaType; }
void undoSetOttavaType(Type val);
void setOttavaType(OttavaType val);
OttavaType ottavaType() const { return _ottavaType; }
void undoSetOttavaType(OttavaType val);
bool numbersOnly() const { return _numbersOnly; }
void setNumbersOnly(bool val) { _numbersOnly = val; }
bool numbersOnly() const { return _numbersOnly; }
void setNumbersOnly(bool val) { _numbersOnly = val; }
virtual LineSegment* createLineSegment() override;
int pitchShift() const { return _pitchShift; }
int pitchShift() const { return _pitchShift; }
virtual void endEdit() override;
virtual void write(XmlWriter& xml) const override;
@ -120,7 +120,5 @@ class Ottava : public TextLineBase {
} // namespace Ms
Q_DECLARE_METATYPE(Ms::Ottava::Type);
#endif

View file

@ -44,6 +44,7 @@
#include "volta.h"
#include "pedal.h"
#include "hairpin.h"
#include "ottava.h"
#ifdef OMR
#include "omr/omr.h"
@ -1051,7 +1052,7 @@ static void readOttava(XmlReader& e, Ottava* ottava)
bool ok;
int idx = s.toInt(&ok);
if (!ok) {
idx = 0; // Ottava::Type::OTTAVA_8VA;
idx = 0; // OttavaType::OTTAVA_8VA;
int i = 0;
for (auto p : { "8va","8vb","15ma","15mb","22ma","22mb" } ) {
if (p == s) {
@ -1061,7 +1062,7 @@ static void readOttava(XmlReader& e, Ottava* ottava)
++i;
}
}
ottava->setOttavaType(Ottava::Type(idx));
ottava->setOttavaType(OttavaType(idx));
}
else if (tag == "numbersOnly") {
ottava->setNumbersOnly(e.readBool());

View file

@ -22,6 +22,7 @@
#include "sig.h"
#include "barline.h"
#include "excerpt.h"
#include "spanner.h"
#ifdef OMR
#include "omr/omr.h"

View file

@ -23,11 +23,9 @@
#include "select.h"
#include "synthesizerstate.h"
#include "mscoreview.h"
#include "ottava.h"
#include "spannermap.h"
#include "rehearsalmark.h"
#include "tremolo.h"
#include "layoutbreak.h"
#include "property.h"
namespace Ms {
@ -97,6 +95,7 @@ enum class SymId;
enum class Key;
enum class HairpinType : char;
enum class SegmentType;
enum class OttavaType : char;
extern bool showRubberBand;
@ -569,7 +568,7 @@ class Score : public QObject, ScoreElement {
void cmdRemovePart(Part*);
void cmdAddTie();
void cmdAddOttava(Ottava::Type);
void cmdAddOttava(OttavaType);
void cmdAddStretch(qreal);
void cmdResetNoteAndRestGroupings();

View file

@ -3391,24 +3391,24 @@ void ExportMusicXml::ottava(Ottava const* const ot, int staff, int tick)
directionTag(xml, attr, ot);
xml.stag("direction-type");
Ottava::Type st = ot->ottavaType();
OttavaType st = ot->ottavaType();
if (ot->tick() == tick) {
const char* sz = 0;
const char* tp = 0;
switch (st) {
case Ottava::Type::OTTAVA_8VA:
case OttavaType::OTTAVA_8VA:
sz = "8";
tp = "down";
break;
case Ottava::Type::OTTAVA_15MA:
case OttavaType::OTTAVA_15MA:
sz = "15";
tp = "down";
break;
case Ottava::Type::OTTAVA_8VB:
case OttavaType::OTTAVA_8VB:
sz = "8";
tp = "up";
break;
case Ottava::Type::OTTAVA_15MB:
case OttavaType::OTTAVA_15MB:
sz = "15";
tp = "up";
break;
@ -3419,9 +3419,9 @@ void ExportMusicXml::ottava(Ottava const* const ot, int staff, int tick)
xml.tagE(QString("octave-shift type=\"%1\" size=\"%2\" number=\"%3\"").arg(tp).arg(sz).arg(n + 1));
}
else {
if (st == Ottava::Type::OTTAVA_8VA || st == Ottava::Type::OTTAVA_8VB)
if (st == OttavaType::OTTAVA_8VA || st == OttavaType::OTTAVA_8VB)
xml.tagE(QString("octave-shift type=\"stop\" size=\"8\" number=\"%1\"").arg(n + 1));
else if (st == Ottava::Type::OTTAVA_15MA || st == Ottava::Type::OTTAVA_15MB)
else if (st == OttavaType::OTTAVA_15MA || st == OttavaType::OTTAVA_15MB)
xml.tagE(QString("octave-shift type=\"stop\" size=\"15\" number=\"%1\"").arg(n + 1));
else
qDebug("ottava subtype %hhd not understood", st);

View file

@ -1211,14 +1211,14 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
if (ottavaFound.at(track)) {
createOttava(true, track, cr, ottavaValue.at(track));
int pitch = note->pitch();
Ottava::Type type = ottava.at(track)->ottavaType();
if (type == Ottava::Type::OTTAVA_8VA)
OttavaType type = ottava.at(track)->ottavaType();
if (type == OttavaType::OTTAVA_8VA)
note->setPitch(pitch-12);
else if (type == Ottava::Type::OTTAVA_8VB)
else if (type == OttavaType::OTTAVA_8VB)
note->setPitch(pitch+12);
else if (type == Ottava::Type::OTTAVA_15MA)
else if (type == OttavaType::OTTAVA_15MA)
note->setPitch(pitch-24);
else if (type == Ottava::Type::OTTAVA_15MB)
else if (type == OttavaType::OTTAVA_15MB)
note->setPitch(pitch+24);
}

View file

@ -1131,13 +1131,13 @@ void GuitarPro::createOttava(bool hasOttava, int track, ChordRest* cr, QString v
Ottava* newOttava = new Ottava(score);
newOttava->setTrack(track);
if (!value.compare("8va"))
newOttava->setOttavaType(Ottava::Type::OTTAVA_8VA);
newOttava->setOttavaType(OttavaType::OTTAVA_8VA);
else if (!value.compare("8vb"))
newOttava->setOttavaType(Ottava::Type::OTTAVA_8VB);
newOttava->setOttavaType(OttavaType::OTTAVA_8VB);
else if (!value.compare("15ma"))
newOttava->setOttavaType(Ottava::Type::OTTAVA_15MA);
newOttava->setOttavaType(OttavaType::OTTAVA_15MA);
else if (!value.compare("15mb"))
newOttava->setOttavaType(Ottava::Type::OTTAVA_15MB);
newOttava->setOttavaType(OttavaType::OTTAVA_15MB);
newOttava->setTick(cr->tick());
/* we set the second tick when we encounter the next note
without an ottava. We also allow the ottava to continue

View file

@ -28,6 +28,7 @@
#include "libmscore/symbol.h"
#include "libmscore/timesig.h"
#include "libmscore/style.h"
#include "libmscore/spanner.h"
#include "importmxmlpass1.h"
#include "importmxmlpass2.h"

View file

@ -58,6 +58,8 @@
#include "libmscore/textline.h"
#include "libmscore/barline.h"
#include "libmscore/articulation.h"
#include "libmscore/ottava.h"
#include "libmscore/rehearsalmark.h"
#include "importmxmlpass2.h"
#include "musicxmlfonthandler.h"
@ -2825,10 +2827,10 @@ void MusicXMLParserDirection::octaveShift(const QString& type, const int number,
// if (placement == "") placement = "above"; // TODO ? set default
if (type == "down" && ottavasize == 8) o->setOttavaType(Ottava::Type::OTTAVA_8VA);
if (type == "down" && ottavasize == 15) o->setOttavaType(Ottava::Type::OTTAVA_15MA);
if (type == "up" && ottavasize == 8) o->setOttavaType(Ottava::Type::OTTAVA_8VB);
if (type == "up" && ottavasize == 15) o->setOttavaType(Ottava::Type::OTTAVA_15MB);
if (type == "down" && ottavasize == 8) o->setOttavaType(OttavaType::OTTAVA_8VA);
if (type == "down" && ottavasize == 15) o->setOttavaType(OttavaType::OTTAVA_15MA);
if (type == "up" && ottavasize == 8) o->setOttavaType(OttavaType::OTTAVA_8VB);
if (type == "up" && ottavasize == 15) o->setOttavaType(OttavaType::OTTAVA_15MB);
starts.append(MusicXmlSpannerDesc(o, ElementType::OTTAVA, number));
}

View file

@ -629,23 +629,23 @@ void OveToMScore::convertTrackHeader(OVE::Track* track, Part* part){
}
}
static Ottava::Type OctaveShiftTypeToInt(OVE::OctaveShiftType type) {
Ottava::Type subtype = Ottava::Type::OTTAVA_8VA;
static OttavaType OctaveShiftTypeToInt(OVE::OctaveShiftType type) {
OttavaType subtype = OttavaType::OTTAVA_8VA;
switch (type) {
case OVE::OctaveShiftType::OS_8: {
subtype = Ottava::Type::OTTAVA_8VA;
subtype = OttavaType::OTTAVA_8VA;
break;
}
case OVE::OctaveShiftType::OS_15: {
subtype = Ottava::Type::OTTAVA_15MA;
subtype = OttavaType::OTTAVA_15MA;
break;
}
case OVE::OctaveShiftType::OS_Minus_8: {
subtype = Ottava::Type::OTTAVA_8VB;
subtype = OttavaType::OTTAVA_8VB;
break;
}
case OVE::OctaveShiftType::OS_Minus_15: {
subtype = Ottava::Type::OTTAVA_15MB;
subtype = OttavaType::OTTAVA_15MB;
break;
}
default:

View file

@ -1156,35 +1156,35 @@ Palette* MuseScore::newLinesPalette(PaletteType t)
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta 2"));
Ottava* ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_8VA);
ottava->setOttavaType(OttavaType::OTTAVA_8VA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8va"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_8VB);
ottava->setOttavaType(OttavaType::OTTAVA_8VB);
ottava->setLen(w);
ottava->setPlacement(Element::Placement::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8vb"));
if (t != PaletteType::BASIC) {
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_15MA);
ottava->setOttavaType(OttavaType::OTTAVA_15MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_15MB);
ottava->setOttavaType(OttavaType::OTTAVA_15MB);
ottava->setLen(w);
ottava->setPlacement(Element::Placement::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15mb"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_22MA);
ottava->setOttavaType(OttavaType::OTTAVA_22MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_22MB);
ottava->setOttavaType(OttavaType::OTTAVA_22MB);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22mb"));
}

View file

@ -28,6 +28,7 @@
#include "libmscore/fraction.h"
#include "libmscore/mscore.h"
#include "libmscore/pitchspelling.h"
#include "libmscore/line.h"
#include "importxmlfirstpass.h"
#include "musicxmlsupport.h"

View file

@ -18,6 +18,7 @@
#include "libmscore/part.h"
#include "libmscore/key.h"
#include "libmscore/icon.h"
#include "libmscore/staff.h"
#include "musescore.h"
namespace Ms {

View file

@ -6,6 +6,7 @@
#include "libmscore/timesig.h"
#include "libmscore/score.h"
#include "libmscore/measure.h"
#include "libmscore/spanner.h"
#include "inspector/inspector.h"
#include "selectionwindow.h"
#include "playpanel.h"