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
|
2014-05-16 13:44:32 +02:00
|
|
|
/// The KeySig class represents a Key Signature on a staff
|
2012-07-27 18:01:15 +02:00
|
|
|
//
|
2014-05-16 13:44:32 +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
|
|
|
|
2017-12-21 14:03:45 +01: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:
|
2012-07-16 20:21:31 +02:00
|
|
|
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
|
|
|
|
2015-04-24 00:55:46 +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;
|
2015-04-24 00:55:46 +02:00
|
|
|
//@ 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(); }
|
2015-06-05 01:53:47 +02:00
|
|
|
bool isAtonal() const { return _sig.isAtonal(); }
|
2019-02-13 01:05:42 +01:00
|
|
|
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; }
|
|
|
|
|
2013-05-08 11:21:59 +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);
|
|
|
|
|
2019-08-28 18:56:13 +02:00
|
|
|
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; }
|
|
|
|
|
2019-08-01 18:06:52 +02:00
|
|
|
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;
|
2014-06-20 22:48:34 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
Element* nextSegmentElement() override;
|
|
|
|
Element* prevSegmentElement() override;
|
|
|
|
QString accessibleInfo() const override;
|
2014-12-09 13:43:31 +01:00
|
|
|
|
|
|
|
SymId convertFromOldId(int val) const;
|
2013-05-08 11:21:59 +02:00
|
|
|
};
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-02-10 14:30:35 +01: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
|
|
|
|
|