MuseScore/libmscore/clef.h

197 lines
6.1 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 __CLEF_H__
#define __CLEF_H__
/**
\file
2014-05-08 17:59:24 +02:00
Definition of classes Clef
2012-05-26 14:26:10 +02:00
*/
#include "element.h"
#include "mscore.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2016-11-19 11:51:21 +01:00
class XmlWriter;
2012-05-26 14:26:10 +02:00
class MuseScoreView;
class Segment;
static const int NO_CLEF = -1000;
2013-09-05 16:37:49 +02:00
//---------------------------------------------------------
// ClefType
//---------------------------------------------------------
enum class ClefType : signed char {
INVALID = -1,
G = 0,
G15_MB,
G8_VB,
G8_VA,
G15_MA,
G8_VB_O,
G8_VB_P,
G_1,
2013-09-05 16:37:49 +02:00
C1,
C2,
C3,
C4,
C5,
C_19C,
C1_F18C,
C3_F18C,
C4_F18C,
C3_F20C,
C1_F20C,
C4_F20C,
F,
F15_MB,
F8_VB,
2013-09-05 16:37:49 +02:00
F_8VA,
F_15MA,
F_B,
F_C,
F_F18C,
F_19C,
PERC,
PERC2,
TAB,
TAB4,
TAB_SERIF,
TAB4_SERIF,
2013-09-05 16:37:49 +02:00
MAX
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ClefTypeList
//---------------------------------------------------------
struct ClefTypeList {
2014-05-08 17:59:24 +02:00
ClefType _concertClef = ClefType::G;
ClefType _transposingClef = ClefType::G;
2012-05-26 14:26:10 +02:00
ClefTypeList() {}
ClefTypeList(ClefType a, ClefType b) : _concertClef(a), _transposingClef(b) {}
2014-08-15 11:58:19 +02:00
ClefTypeList(ClefType a) : _concertClef(a), _transposingClef(a) {}
2012-05-26 14:26:10 +02:00
bool operator==(const ClefTypeList& t) const;
bool operator!=(const ClefTypeList& t) const;
};
//---------------------------------------------------------
// ClefInfo
/// Info about a clef.
//---------------------------------------------------------
2013-09-05 16:37:49 +02:00
class ClefInfo {
public:
static const ClefInfo clefTable[];
const char* _tag; ///< comprehensive name for instruments.xml
const char* _sign; ///< Name for musicXml.
int _line; ///< Line for musicXml and for positioning on the staff
2013-09-05 16:37:49 +02:00
int _octChng; ///< Octave change for musicXml.
int _pitchOffset; ///< Pitch offset for line 0.
signed char _lines[14];
SymId _symId;
2013-09-05 16:37:49 +02:00
const char* _name;
StaffGroup _staffGroup;
public:
static const char* tag(ClefType t) { return clefTable[int(t)]._tag; }
static const char* sign(ClefType t) { return clefTable[int(t)]._sign; }
static int line(ClefType t) { return clefTable[int(t)]._line; }
static int octChng(ClefType t) { return clefTable[int(t)]._octChng; }
static int pitchOffset(ClefType t) { return clefTable[int(t)]._pitchOffset; }
static SymId symId(ClefType t) { return clefTable[int(t)]._symId; }
static const signed char* lines(ClefType t) { return clefTable[int(t)]._lines; }
2013-09-05 16:37:49 +02:00
static const char* name(ClefType t) { return clefTable[int(t)]._name; }
static StaffGroup staffGroup(ClefType t) { return clefTable[int(t)]._staffGroup; }
static ClefType tag2type(const QString&);
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Clef
/// Graphic representation of a clef.
2012-07-27 18:01:15 +02:00
//
// @P showCourtesy bool show/hide courtesy clef when applicable
// @P small bool small, mid-staff clef (read only, set by layout)
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Clef final : public Element {
2016-09-21 12:46:05 +02:00
SymId symId;
bool _showCourtesy = true;
bool _small = false;
bool _forInstrumentChange = false;
2012-05-26 14:26:10 +02:00
ClefTypeList _clefTypes { ClefType::INVALID };
2012-07-27 18:01:15 +02:00
2012-05-26 14:26:10 +02:00
public:
Clef(Score*);
2020-03-21 15:03:04 +01:00
Clef* clone() const override { return new Clef(*this); }
ElementType type() const override { return ElementType::CLEF; }
qreal mag() const override;
2012-05-26 14:26:10 +02:00
Segment* segment() const { return (Segment*)parent(); }
Measure* measure() const { return (Measure*)parent()->parent(); }
2012-05-26 14:26:10 +02:00
2020-03-21 15:03:04 +01:00
bool acceptDrop(EditData&) const override;
Element* drop(EditData&) override;
void layout() override;
void draw(QPainter*) const override;
void read(XmlReader&) override;
void write(XmlWriter&) const override;
2014-05-08 17:59:24 +02:00
2020-03-21 15:03:04 +01:00
bool isEditable() const override { return false; }
2012-05-26 14:26:10 +02:00
bool small() const { return _small; }
void setSmall(bool val);
2012-07-27 18:01:15 +02:00
bool showCourtesy() const { return _showCourtesy; }
2012-07-27 18:35:37 +02:00
void setShowCourtesy(bool v) { _showCourtesy = v; }
void undoSetShowCourtesy(bool v);
Clef* otherClef();
2012-05-26 14:26:10 +02:00
static ClefType clefType(const QString& s);
2014-05-08 17:59:24 +02:00
const char* clefTypeName();
2012-05-26 14:26:10 +02:00
ClefType clefType() const;
void setClefType(ClefType i);
void setClefType(const QString& s);
void setForInstrumentChange(bool forInstrumentChange) { _forInstrumentChange = forInstrumentChange; }
bool forInstrumentChange() const { return _forInstrumentChange; }
2012-05-26 14:26:10 +02:00
ClefTypeList clefTypeList() const { return _clefTypes; }
ClefType concertClef() const { return _clefTypes._concertClef; }
ClefType transposingClef() const { return _clefTypes._transposingClef; }
void setConcertClef(ClefType val);
void setTransposingClef(ClefType val);
void setClefType(const ClefTypeList& ctl) { _clefTypes = ctl; }
2020-03-21 15:03:04 +01:00
void spatiumChanged(qreal oldValue, qreal newValue) override;
2012-07-27 18:01:15 +02:00
2020-03-21 15:03:04 +01:00
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid id) const override;
2020-03-21 15:03:04 +01:00
Element* nextSegmentElement() override;
Element* prevSegmentElement() override;
2016-02-04 17:06:32 +01:00
QString accessibleInfo() const override;
2016-04-21 12:20:29 +02:00
void clear();
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