MuseScore/libmscore/keysig.h

96 lines
3.5 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
namespace Ms {
2012-05-26 14:26:10 +02:00
class Sym;
class Segment;
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 final : public Element {
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)
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&);
2020-03-25 15:06:32 +01:00
KeySig* clone() const override { return new KeySig(*this); }
void draw(QPainter*) const override;
ElementType type() const override { return ElementType::KEYSIG; }
bool acceptDrop(EditData&) const override;
Element* drop(EditData&) override;
void layout() override;
Shape shape() const override;
qreal mag() const override;
2012-05-26 14:26:10 +02:00
//@ sets the key of the key signature
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; }
2020-03-25 15:06:32 +01:00
void write(XmlWriter&) const override;
void read(XmlReader&) override;
//@ returns the key of the key signature (from -7 (flats) to +7 (sharps) )
2014-06-04 11:24:44 +02:00
Q_INVOKABLE Key key() const { return _sig.key(); }
2012-05-26 14:26:10 +02:00
bool isCustom() const { return _sig.custom(); }
bool isAtonal() const { return _sig.isAtonal(); }
bool isChange() const;
2012-05-26 14:26:10 +02:00
KeySigEvent keySigEvent() const { return _sig; }
bool operator==(const KeySig&) const;
void changeKeySigEvent(const KeySigEvent&);
void setKeySigEvent(const KeySigEvent& e) { _sig = e; }
bool showCourtesy() const { return _showCourtesy; }
void setShowCourtesy(bool v) { _showCourtesy = v; }
2012-07-27 18:01:15 +02:00
void undoSetShowCourtesy(bool v);
KeyMode mode() const { return _sig.mode(); }
void setMode(KeyMode v) { _sig.setMode(v); }
void undoSetMode(KeyMode v);
2014-06-26 23:17:25 +02:00
void setHideNaturals(bool hide) { _hideNaturals = hide; }
void setForInstrumentChange(bool forInstrumentChange) { _sig.setForInstrumentChange(forInstrumentChange); }
bool forInstrumentChange() const { return _sig.forInstrumentChange(); }
2020-03-25 15:06:32 +01:00
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid id) const override;
2020-03-25 15:06:32 +01:00
Element* nextSegmentElement() override;
Element* prevSegmentElement() override;
QString accessibleInfo() const override;
SymId convertFromOldId(int val) 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