MuseScore  3.4
Music composition and notation
style.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __STYLE_H__
14 #define __STYLE_H__
15 
16 #include "chordlist.h"
17 #include "types.h"
18 
19 namespace Ms {
20 
21 enum class Pid : int;
22 class XmlWriter;
23 struct ChordDescription;
24 class Element;
25 class Score;
26 
27 //---------------------------------------------------------
28 // Sid
29 //
30 // Keep in sync with styleTypes[] in style.cpp
31 //---------------------------------------------------------
32 
33 enum class Sid {
34  NOSTYLE = -1,
35 
36  pageWidth,
37  pageHeight,
46 
51 
54 
73 
86 
99 
101 // figuredBassFontSize,
109 
110  barWidth,
112  endBarWidth,
119 
120  bracketWidth,
124  dividerLeft,
126  dividerLeftX,
127  dividerLeftY,
128  dividerRight,
132 
137  timesigScale,
138 
147 
150 
151  stemWidth,
152  shortenStem,
154  shortestStem,
161 
168  beamWidth,
169  beamDistance,
170  beamMinLen,
171  beamNoSlope,
172 
173  dotMag,
186 
199  hairpinColor,
207  hairpinText,
214 
226  pedalColor,
234 
238 
242 
249 
252 
255 
258 
261 
274 
287 
300 
313 
314  capoPosition,
315  fretNumMag,
316  fretNumPos,
317  fretY,
319  fretMag,
321  fretStrings,
322  fretFrets,
323  fretNut,
324  fretDotSize,
327 
335 
337  smallNoteMag,
338  graceNoteMag,
340  smallClefMag,
341  genClef,
342  genKeysig,
346 
347  swingRatio,
348  swingUnit,
349 
359  chordStyle,
366  concertPitch,
373  gateTime,
376  slurGateTime,
377 
382 
383  SlurEndWidth,
384  SlurMidWidth,
386  MinTieLength,
388 
389  SectionPause,
392 
393  showHeader,
396  evenHeaderL,
397  evenHeaderC,
398  evenHeaderR,
399  oddHeaderL,
400  oddHeaderC,
401  oddHeaderR,
402 
403  showFooter,
406  evenFooterL,
407  evenFooterC,
408  evenFooterR,
409  oddFooterL,
410  oddFooterC,
411  oddFooterR,
412 
414  voltaHook,
421  voltaColor,
422  voltaAlign,
423  voltaOffset,
430 
437 
450 
463 
475  ottavaColor,
483 
484  tabClef,
485 
486  tremoloWidth,
491  // TODO tremoloBeamLengthMultiplier,
492  // TODO tremoloMaxBeamLength,
493 
497 
514  tupletColor,
515  tupletAlign,
517  tupletOffset,
524 
528 
531  spatium,
532 
534 
538 
541 
551 
553  jumpPosAbove,
555 
560  defaultColor,
561  defaultAlign,
571  defaultText,
572 
577  titleColor,
578  titleAlign,
579  titleOffset,
587 
602 
617 
632 
646 
660 
674 
688 
702 
716 
730 
743 
758 
763  tempoColor,
764  tempoAlign,
776 
791 
806 
820 
838 
856 
873 
887 
901 
906  frameColor,
907  frameAlign,
908  frameOffset,
915 
922 
938 
939  bendFontFace,
940  bendFontSize,
943  bendColor,
944  bendAlign,
945  bendOffset,
954 
959  headerColor,
960  headerAlign,
961  headerOffset,
968 
973  footerColor,
974  footerAlign,
975  footerOffset,
982 
1000 
1005  stickingColor,
1006  stickingAlign,
1018 
1024 
1025  user1Name,
1026  user1FontFace,
1027  user1FontSize,
1030  user1Color,
1031  user1Align,
1032  user1Offset,
1040 
1041  user2Name,
1042  user2FontFace,
1043  user2FontSize,
1046  user2Color,
1047  user2Align,
1048  user2Offset,
1056 
1057  user3Name,
1058  user3FontFace,
1059  user3FontSize,
1062  user3Color,
1063  user3Align,
1064  user3Offset,
1072 
1073  user4Name,
1074  user4FontFace,
1075  user4FontSize,
1078  user4Color,
1079  user4Align,
1080  user4Offset,
1088 
1089  user5Name,
1090  user5FontFace,
1091  user5FontSize,
1094  user5Color,
1095  user5Align,
1096  user5Offset,
1104 
1105  user6Name,
1106  user6FontFace,
1107  user6FontSize,
1110  user6Color,
1111  user6Align,
1112  user6Offset,
1120 
1121  user7Name,
1122  user7FontFace,
1123  user7FontSize,
1126  user7Color,
1127  user7Align,
1128  user7Offset,
1136 
1137  user8Name,
1138  user8FontFace,
1139  user8FontSize,
1142  user8Color,
1143  user8Align,
1144  user8Offset,
1152 
1153  user9Name,
1154  user9FontFace,
1155  user9FontSize,
1158  user9Color,
1159  user9Align,
1160  user9Offset,
1168 
1169  user10Name,
1174  user10Color,
1175  user10Align,
1176  user10Offset,
1184 
1185  user11Name,
1190  user11Color,
1191  user11Align,
1192  user11Offset,
1200 
1201  user12Name,
1206  user12Color,
1207  user12Align,
1208  user12Offset,
1216 
1221  letRingColor,
1230  letRingText,
1238 
1243  palmMuteColor,
1252  palmMuteText,
1260 
1264 
1266 
1281 
1283 
1284  STYLES
1285  };
1286 
1287 //---------------------------------------------------------
1288 // MStyle
1289 // the name "Style" gives problems with some microsoft
1290 // header files...
1291 //---------------------------------------------------------
1292 
1293 class MStyle {
1294  std::array<QVariant, int(Sid::STYLES)> _values;
1295  std::array<qreal, int(Sid::STYLES)> _precomputedValues;
1296 
1298  bool _customChordList; // if true, chordlist will be saved as part of score
1299 
1300  public:
1301  MStyle();
1302 
1303  void precomputeValues();
1304  QVariant value(Sid idx) const;
1305  qreal pvalue(Sid idx) const { return _precomputedValues[int(idx)]; }
1306  void set(Sid idx, const QVariant& v);
1307 
1308  bool isDefault(Sid idx) const;
1309 
1310  const ChordDescription* chordDescription(int id) const;
1311  ChordList* chordList() { return &_chordList; }
1312  void setChordList(ChordList*, bool custom = true); // Style gets ownership of ChordList
1313  void setCustomChordList(bool t) { _customChordList = t; }
1314  void checkChordList();
1315 
1316  bool load(QFile* qf, bool ign = false);
1317  void load(XmlReader& e);
1318  void save(XmlWriter& xml, bool optimize);
1319  bool readProperties(XmlReader&);
1320  bool readStyleValCompat(XmlReader&);
1321  bool readTextStyleValCompat(XmlReader&);
1322 
1323  void reset(Score*);
1324 
1325  static const char* valueType(const Sid);
1326  static const char* valueName(const Sid);
1327  static Sid styleIdx(const QString& name);
1328  };
1329 
1330 //---------------------------------------------------------
1331 // StyledProperty
1332 //---------------------------------------------------------
1333 
1337  };
1338 
1339 typedef std::vector<StyledProperty> ElementStyle;
1340 
1341 #define TEXT_STYLE_SIZE 13
1342 
1343 typedef std::array<StyledProperty, TEXT_STYLE_SIZE> TextStyle;
1344 
1345 
1346 const TextStyle* textStyle(Tid);
1347 const TextStyle* textStyle(const char*);
1348 
1349 const char* textStyleName(Tid);
1350 QString textStyleUserName(Tid);
1351 Tid textStyleFromName(const QString&);
1352 
1353 const std::vector<Tid>& allTextStyles();
1354 const std::vector<Tid>& primaryTextStyles();
1355 
1356 #ifndef NDEBUG
1357 extern void checkStyles();
1358 #endif
1359 
1360 } // namespace Ms
1361 
1362 
1363 #endif
Definition: chordlist.h:174
Pid pid
Definition: style.h:1336
Pid
Definition: property.h:62
Definition: xml.h:67
Tid textStyleFromName(const QString &name)
Definition: style.cpp:2317
Definition: chordlist.h:230
std::vector< StyledProperty > ElementStyle
Definition: style.h:1339
ChordList * chordList()
Definition: style.h:1311
const std::vector< Tid > & allTextStyles()
Definition: style.cpp:2398
Definition: style.h:1334
Definition: score.h:391
std::array< StyledProperty, TEXT_STYLE_SIZE > TextStyle
Definition: style.h:1343
const TextStyle * textStyle(const char *name)
Definition: style.cpp:2297
void setCustomChordList(bool t)
Definition: style.h:1313
QString textStyleUserName(Tid idx)
Definition: style.cpp:2344
Tid
Enumerates the list of built-in text substyles.
Definition: types.h:371
Definition: aeolus.cpp:26
void checkStyles()
Definition: style.cpp:2866
Sid
Definition: style.h:33
const std::vector< Tid > & primaryTextStyles()
Definition: style.cpp:2415
Definition: xml.h:218
const char * textStyleName(Tid idx)
Definition: style.cpp:2334
Sid sid
Definition: style.h:1335
Definition: xmlwriter.h:26
qreal pvalue(Sid idx) const
Definition: style.h:1305
std::array< qreal, int(Sid::STYLES)> _precomputedValues
Definition: style.h:1295
bool _customChordList
Definition: style.h:1298
ChordList _chordList
Definition: style.h:1297
Definition: style.h:1293
std::array< QVariant, int(Sid::STYLES)> _values
Definition: style.h:1294