MuseScore/libmscore/keysig.h

104 lines
3.4 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;
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
/// 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-07-27 18:01:15 +02:00
//---------------------------------------------------------------------------------------
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)
2014-05-30 13:35:44 +02:00
bool _showCourtesy;
2014-06-26 23:17:25 +02:00
bool _hideNaturals; // used in layout to override score style (needed for the Continuous panel)
2012-05-26 14:26:10 +02:00
QList<KeySym*> keySymbols;
2014-06-03 15:28:10 +02:00
KeySigEvent _sig;
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); }
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
virtual Element::Type type() const { return Element::Type::KEYSIG; }
2014-08-13 21:01:21 +02:00
virtual bool acceptDrop(const DropData&) const override;
2012-05-26 14:26:10 +02:00
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
2014-06-20 17:07:22 +02:00
Q_INVOKABLE void setKey(Key);
2012-05-26 14:26:10 +02:00
Segment* segment() const { return (Segment*)parent(); }
2014-06-03 15:28:10 +02:00
Measure* measure() const { return parent() ? (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&);
2014-06-04 11:24:44 +02:00
//@ -7 (flats) -- +7 (sharps)
Q_INVOKABLE Key key() const { return _sig.key(); }
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;
bool showCourtesy() const { return _showCourtesy; }
void setShowCourtesy(bool v) { _showCourtesy = v; }
2012-07-27 18:01:15 +02:00
void undoSetShowCourtesy(bool v);
2014-06-26 23:17:25 +02:00
void setHideNaturals(bool hide) { _hideNaturals = hide; }
2012-07-27 18:01:15 +02:00
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant&);
QVariant propertyDefault(P_ID id) const;
virtual Element* nextElement() override;
virtual Element* prevElement() override;
virtual QString accessibleInfo() override;
};
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