1 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 3 4 /* 5 Rosegarden 6 A MIDI and audio sequencer and musical notation editor. 7 Copyright 2000-2021 the Rosegarden development team. 8 9 Other copyrights also apply to some parts of this work. Please 10 see the AUTHORS file and individual file headers for details. 11 12 This program is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 2 of the 15 License, or (at your option) any later version. See the file 16 COPYING included with this distribution for more information. 17 */ 18 19 #ifndef RG_NOTESTYLE_H 20 #define RG_NOTESTYLE_H 21 22 #include "base/NotationTypes.h" 23 #include <map> 24 #include "NoteCharacterNames.h" 25 26 #include <QSharedPointer> 27 #include <QString> 28 29 #include <utility> 30 31 32 class Mark; 33 class Accidental; 34 35 36 namespace Rosegarden 37 { 38 39 class Clef; 40 41 typedef QString NoteStyleName; 42 43 44 class NoteStyle 45 { 46 public: 47 virtual ~NoteStyle(); 48 49 typedef QString NoteHeadShape; 50 51 static const NoteHeadShape AngledOval; 52 static const NoteHeadShape LevelOval; 53 static const NoteHeadShape Breve; 54 static const NoteHeadShape Cross; 55 static const NoteHeadShape TriangleUp; 56 static const NoteHeadShape TriangleDown; 57 static const NoteHeadShape Diamond; 58 static const NoteHeadShape Rectangle; 59 static const NoteHeadShape CustomCharName; 60 static const NoteHeadShape Number; 61 62 enum HFixPoint { Normal, Central, Reversed }; 63 enum VFixPoint { Near, Middle, Far }; 64 getName()65 NoteStyleName getName() const { return m_name; } 66 67 NoteHeadShape getShape (Note::Type); 68 bool isFilled (Note::Type); 69 bool hasStem (Note::Type); 70 int getFlagCount (Note::Type); 71 int getSlashCount(Note::Type); 72 73 typedef std::pair<CharName, bool> CharNameRec; // bool is "inverted" 74 CharNameRec getNoteHeadCharName(Note::Type); 75 76 CharName getRestCharName(Note::Type, bool restOutsideStave); 77 CharName getPartialFlagCharName(bool final); 78 CharName getFlagCharName(int flagCount); 79 CharName getAccidentalCharName(const Accidental &); 80 CharName getMarkCharName(const Mark &); 81 CharName getClefCharName(const Clef &); 82 CharName getSymbolCharName(const Symbol &); 83 CharName getTimeSignatureDigitName(int digit); 84 CharName getSomeCharName(QString thing); 85 86 void setBaseStyle (NoteStyleName name); 87 void setShape (Note::Type, NoteHeadShape); 88 void setCharName (Note::Type, CharName); 89 void setFilled (Note::Type, bool); 90 void setStem (Note::Type, bool); 91 void setFlagCount (Note::Type, int); 92 void setSlashCount(Note::Type, int); 93 94 void getStemFixPoints(Note::Type, HFixPoint &, VFixPoint &); 95 void setStemFixPoints(Note::Type, HFixPoint, VFixPoint); 96 97 protected: 98 struct NoteDescription { 99 NoteHeadShape shape; // if CustomCharName, use charName 100 CharName charName; // only used if shape == CustomCharName 101 bool filled; 102 bool stem; 103 int flags; 104 int slashes; 105 HFixPoint hfix; 106 VFixPoint vfix; 107 NoteDescriptionNoteDescription108 NoteDescription() : 109 shape(AngledOval), charName(NoteCharacterNames::UNKNOWN), 110 filled(true), stem(true), flags(0), slashes(0), 111 hfix(Normal), vfix(Middle) { } 112 NoteDescriptionNoteDescription113 NoteDescription(NoteHeadShape i_shape, CharName i_charName, 114 bool i_filled, bool i_stem, int i_flags, int i_slashes, 115 HFixPoint i_hfix, VFixPoint i_vfix) : 116 shape(i_shape), charName(i_charName), 117 filled(i_filled), stem(i_stem), flags(i_flags), slashes(i_slashes), 118 hfix(i_hfix), vfix(i_vfix) { } 119 }; 120 121 typedef std::map<Note::Type, NoteDescription> NoteDescriptionMap; 122 123 NoteDescriptionMap m_notes; 124 QSharedPointer<NoteStyle> m_baseStyle; 125 NoteStyleName m_name; 126 127 void checkDescription(Note::Type type); 128 129 protected: // for use by NoteStyleFileReader NoteStyle(NoteStyleName name)130 NoteStyle(NoteStyleName name) : m_name(name) { } 131 friend class NoteStyleFileReader; 132 }; 133 134 135 136 137 } 138 139 #endif 140