1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2004-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __ACCIDENTAL_H__
#define __ACCIDENTAL_H__
/**
\file
Definition of class Accidental
*/
#include "config.h"
#include "element.h"
namespace Ms {
class Note;
enum class SymId;
enum class AccidentalVal : signed char;
//---------------------------------------------------------
// AccidentalRole
//---------------------------------------------------------
enum class AccidentalRole : char {
AUTO, // layout created accidental
USER // user created accidental
};
//---------------------------------------------------------
// AccidentalBracket
//---------------------------------------------------------
enum class AccidentalBracket : char {
NONE,
PARENTHESIS,
BRACKET
};
//---------------------------------------------------------
// SymElement
//---------------------------------------------------------
struct SymElement {
SymId sym;
qreal x;
SymElement(SymId _sym, qreal _x) : sym(_sym), x(_x) {}
};
//---------------------------------------------------------
// @@ Accidental
// @P role enum (Accidental.AUTO, .USER) (read only)
// @P small bool
//---------------------------------------------------------
class Accidental final : public Element {
QList<SymElement> el;
AccidentalType _accidentalType { AccidentalType::NONE };
bool _small { false };
AccidentalBracket _bracket { AccidentalBracket::NONE };
AccidentalRole _role { AccidentalRole::AUTO };
public:
Accidental(Score* s = 0);
virtual Accidental* clone() const override { return new Accidental(*this); }
virtual ElementType type() const override { return ElementType::ACCIDENTAL; }
QString subtypeUserName() const;
void setSubtype(const QString& s);
void setAccidentalType(AccidentalType t) { _accidentalType = t; }
AccidentalType accidentalType() const { return _accidentalType; }
AccidentalRole role() const { return _role; }
virtual int subtype() const override { return (int)_accidentalType; }
virtual QString subtypeName() const override { return QString(subtype2name(_accidentalType)); }
virtual bool acceptDrop(EditData&) const override;
virtual Element* drop(EditData&) override;
virtual void layout() override;
virtual void draw(QPainter*) const override;
virtual bool isEditable() const override { return true; }
virtual void startEdit(EditData&) override { setGenerated(false); }
SymId symbol() const;
Note* note() const { return (parent() && parent()->isNote()) ? toNote(parent()) : 0; }
AccidentalBracket bracket() const { return _bracket; }
void setBracket(AccidentalBracket val) { _bracket = val; }
void setRole(AccidentalRole r) { _role = r; }
bool small() const { return _small; }
void setSmall(bool val) { _small = val; }
void undoSetSmall(bool val);
virtual void read(XmlReader&) override;
virtual void write(XmlWriter& xml) const override;
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid propertyId) const override;
virtual Pid propertyId(const QStringRef& xmlName) const override;
virtual QString propertyUserValue(Pid) const override;
static AccidentalVal subtype2value(AccidentalType); // return effective pitch offset
static const char* subtype2name(AccidentalType);
static AccidentalType value2subtype(AccidentalVal);
static AccidentalType name2subtype(const QString&);
static bool isMicrotonal(AccidentalType t) { return t > AccidentalType::FLAT2; }
QString accessibleInfo() const override;
};
extern AccidentalVal sym2accidentalVal(SymId id);
} // namespace Ms
Q_DECLARE_METATYPE(Ms::AccidentalRole);
Q_DECLARE_METATYPE(Ms::AccidentalType);
#endif
|