MuseScore/libmscore/keysig.h

101 lines
3.3 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-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 __KEYSIG_H__
#define __KEYSIG_H__
#include "key.h"
#include "element.h"
2013-05-13 18:49:17 +02:00
class QPainter;
namespace Ms {
2012-05-26 14:26:10 +02:00
class Sym;
class Segment;
2013-11-06 15:58:05 +01:00
enum class SymId;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// KeySym
// position of one symbol in KeySig
//---------------------------------------------------------
struct KeySym {
2013-11-06 15:58:05 +01:00
SymId sym;
2012-05-26 14:26:10 +02:00
QPointF spos;
QPointF pos;
};
2012-07-27 18:01:15 +02:00
//---------------------------------------------------------------------------------------
2012-07-16 19:59:32 +02:00
// @@ KeySig
2012-05-26 14:26:10 +02:00
/// The KeySig class represents a Key Signature on a staff
2012-07-27 18:01:15 +02:00
//
// @P showCourtesy bool show courtesy key signature for this sig if appropriate
//---------------------------------------------------------------------------------------
2012-05-26 14:26:10 +02:00
class KeySig : public Element {
Q_OBJECT
2012-07-27 18:01:15 +02:00
Q_PROPERTY(bool showCourtesy READ showCourtesy WRITE undoSetShowCourtesy)
bool _showCourtesy;
2012-05-26 14:26:10 +02:00
QList<KeySym*> keySymbols;
2014-04-10 13:13:37 +02:00
KeySigEvent _sig; // concertKeySig, transposingKeySig
2013-11-06 15:58:05 +01:00
void addLayout(SymId sym, qreal x, int y);
2012-05-26 14:26:10 +02:00
public:
KeySig(Score* = 0);
2012-05-26 14:26:10 +02:00
KeySig(const KeySig&);
virtual KeySig* clone() const { return new KeySig(*this); }
virtual void draw(QPainter*) const;
virtual ElementType type() const { return KEYSIG; }
virtual bool acceptDrop(MuseScoreView*, const QPointF&, Element*) const;
virtual Element* drop(const DropData&);
virtual void layout();
2013-05-28 15:42:02 +02:00
virtual qreal mag() const;
2012-05-26 14:26:10 +02:00
Q_INVOKABLE void setSig(int oldSig, int newSig);
2012-05-26 14:26:10 +02:00
void setOldSig(int oldSig);
Segment* segment() const { return (Segment*)parent(); }
Measure* measure() const { return parent() != nullptr ? (Measure*)parent()->parent() : nullptr; }
2012-05-26 14:26:10 +02:00
Space space() const;
void setCustom(const QList<KeySym*>& symbols);
virtual void write(Xml&) const;
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&);
2012-07-16 19:59:32 +02:00
//@ -7 (flats) -- +7 (sharps)
2012-07-27 18:01:15 +02:00
Q_INVOKABLE int keySignature() const { return _sig.accidentalType(); } // -7 - +7
2012-05-26 14:26:10 +02:00
int customType() const { return _sig.customType(); }
bool isCustom() const { return _sig.custom(); }
KeySigEvent keySigEvent() const { return _sig; }
bool operator==(const KeySig&) const;
void changeKeySigEvent(const KeySigEvent&);
void setKeySigEvent(const KeySigEvent& e) { _sig = e; }
int tick() const;
void insertIntoKeySigChain();
void removeFromKeySigChain();
2012-05-26 14:26:10 +02:00
bool showCourtesy() const { return _showCourtesy; }
void setShowCourtesy(bool v) { _showCourtesy = v; }
2012-07-27 18:01:15 +02:00
void undoSetShowCourtesy(bool v);
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant&);
QVariant propertyDefault(P_ID id) const;
};
2012-05-26 14:26:10 +02:00
extern const char* keyNames[];
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif