MuseScore Plugins 3.3
Plugins API for MuseScore
Loading...
Searching...
No Matches
mscore.h
1//=============================================================================
2// MuseScore
3// Music Composition & Notation
4//
5// Copyright (C) 2011-2013 Werner Schweer and others
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 LICENSE.GPL
11//=============================================================================
12
13#ifndef __MSCORE_H__
14#define __MSCORE_H__
15
16#include "config.h"
17#include "style.h"
18
19namespace Ms {
20
21#define MSC_VERSION "3.02"
22static constexpr int MSCVERSION = 302;
23
24// History:
25// 1.3 added staff->_barLineSpan
26// 1.4 (Version 0.9)
27// 1.5 save xoff/yoff in mm instead of pixel
28// 1.6 save harmony base/root as tpc value
29// 1.7 invert semantic of page fill limit
30// 1.8 slur id, slur anchor in in Note
31// 1.9 image size stored in mm instead of pixel (Versions 0.9.2 -0.9.3)
32// 1.10 TextLine properties changed (Version 0.9.4)
33// 1.11 Instrument name in part saved as TextC (Version 0.9.5)
34// 1.12 use durationType, remove tickLen
35// 1.13 Clefs: userOffset is not (mis)used for vertical layout position
36// 1.14 save user modified beam position as spatium value (Versions 0.9.6 - 1.3)
37
38// 1.15 save timesig inline; Lyrics "endTick" replaced by "ticks"
39// 1.16 spanners (hairpin, trill etc.) are now inline and have no ticks anymore
40// 1.17 new <Score> toplevel structure to support linked parts (excerpts)
41// 1.18 save lyrics as subtype to chord/rest to allow them associated with
42// grace notes
43// 1.19 replace text style numbers by text style names; box margins are now
44// used
45// 1.20 instrument names are saved as html again
46// 1.21 no cleflist anymore
47// 1.22 timesig changed
48// 1.23 measure property for actual length
49// 1.24 default image size is spatium dependent
50// - symbol numbers in TextLine() replaced by symbol names
51// TextStyle: frameWidth, paddingWidth are now in Spatium units (instead of mm)
52
53// 2.00 (Version 2.0)
54// 2.01 save SlurSegment position relative to staff
55// 2.02 save instrumentId, note slashes
56// 2.03 save Box topGap, bottomGap in spatium units
57// 2.04 added hideSystemBarLine flag to Staff
58// 2.05 breath segment changed to use tick of following chord rather than preceding chord
59// 2.06 Glissando moved from final chord to start note (Version 2.0.x)
60//
61// 2.07 irregular, breakMMrest, more style options, system divider, bass string for tab (3.0)
62
63// 3.00 (Version 3.0 alpha)
64// 3.01 -
65// 3.02 Engraving improvements for 3.6
66
67
68class MStyle;
69class Sequencer;
70
71enum class HairpinType : signed char;
72
73#ifndef VOICES
74#define VOICES 4
75#endif
76
77inline int staff2track(int staffIdx) { return staffIdx << 2; }
78inline int track2staff(int voice) { return voice >> 2; }
79inline int track2voice(int track) { return track & 3; }
80inline int trackZeroVoice(int track) { return track & ~3; }
81
82static const int MAX_TAGS = 32;
83
84static const int MAX_HEADERS = 3;
85static const int MAX_FOOTERS = 3;
86
87static constexpr qreal INCH = 25.4;
88static constexpr qreal PPI = 72.0; // printer points per inch
89static constexpr qreal DPI_F = 5;
90static constexpr qreal DPI = 72.0 * DPI_F;
91static constexpr qreal SPATIUM20 = 5.0 * (DPI / 72.0);
92static constexpr qreal DPMM = DPI / INCH;
93
94static constexpr int MAX_STAVES = 4;
95
96static const int SHADOW_NOTE_LIGHT = 135;
97
98static const char mimeSymbolFormat[] = "application/musescore/symbol";
99static const char mimeSymbolListFormat[] = "application/musescore/symbollist";
100static const char mimeStaffListFormat[] = "application/musescore/stafflist";
101
102static const int VISUAL_STRING_NONE = -100; // no ordinal for the visual repres. of string (topmost in TAB
103 // varies according to visual order and presence of bass strings)
104static const int STRING_NONE = -1; // no ordinal for a physical string (0 = topmost in instrument)
105static const int FRET_NONE = -1; // no ordinal for a fret
106
107//---------------------------------------------------------
108// BracketType
109// System Brackets
110//---------------------------------------------------------
111
112enum class BracketType : signed char {
113 NORMAL, BRACE, SQUARE, LINE, NO_BRACKET = -1
114 };
115
116//---------------------------------------------------------
117// PlaceText
118//---------------------------------------------------------
119
120enum class PlaceText : char {
122 };
123
124//---------------------------------------------------------
125// TransposeDirection
126//---------------------------------------------------------
127
128enum class TransposeDirection : char {
129 UP, DOWN, CLOSEST
130 };
131
132//---------------------------------------------------------
133// TransposeMode
134//---------------------------------------------------------
135
136enum class TransposeMode : char {
137 TO_KEY, BY_INTERVAL, DIATONICALLY
138 };
139
140//---------------------------------------------------------
141// SelectType
142//---------------------------------------------------------
143
144enum class SelectType : char {
145 SINGLE, RANGE, ADD
146 };
147
148//---------------------------------------------------------
149// AccidentalVal
150//---------------------------------------------------------
151
152enum class AccidentalVal : signed char {
153 SHARP3 = 3,
154 SHARP2 = 2,
155 SHARP = 1,
156 NATURAL = 0,
157 FLAT = -1,
158 FLAT2 = -2,
159 FLAT3 = -3,
160 MIN = FLAT3,
161 MAX = SHARP3
162 };
163
164//---------------------------------------------------------
165// KeySigNaturals (positions of naturals in key sig. changes)
166//---------------------------------------------------------
167
168enum class KeySigNatural : char {
169 NONE = 0, // no naturals, except for change to CMaj/Amin
170 BEFORE = 1, // naturals before accidentals
171 AFTER = 2 // naturals after accidentals (but always before if going sharps <=> flats)
172 };
173
174//---------------------------------------------------------
175// UpDownMode
176//---------------------------------------------------------
177
178enum class UpDownMode : char {
179 CHROMATIC, OCTAVE, DIATONIC
180 };
181
182//---------------------------------------------------------
183// StaffGroup
184//---------------------------------------------------------
185
186enum class StaffGroup : char {
187 STANDARD, PERCUSSION, TAB
188 };
189const int STAFF_GROUP_MAX = int(StaffGroup::TAB) + 1; // out of enum to avoid compiler complains about not handled switch cases
190
191//---------------------------------------------------------
192// BarLineType
193//---------------------------------------------------------
194
195enum class BarLineType {
196 NORMAL = 1,
197 SINGLE = BarLineType::NORMAL,
198 DOUBLE = 2,
199 START_REPEAT = 4,
200 LEFT_REPEAT = BarLineType::START_REPEAT,
201 END_REPEAT = 8,
202 RIGHT_REPEAT = BarLineType::END_REPEAT,
203 BROKEN = 0x10,
204 DASHED = BarLineType::BROKEN,
205 END = 0x20,
206 FINAL = BarLineType::END,
207 END_START_REPEAT = 0x40,
208 LEFT_RIGHT_REPEAT= BarLineType::END_START_REPEAT,
209 DOTTED = 0x80,
210 REVERSE_END = 0x100,
211 REVERSE_FINALE = BarLineType::REVERSE_END,
212 HEAVY = 0x200,
213 DOUBLE_HEAVY = 0x400,
214 };
215
216constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
217 return static_cast<BarLineType>(static_cast<int>(t1) | static_cast<int>(t2));
218 }
219constexpr bool operator& (BarLineType t1, BarLineType t2) {
220 return static_cast<int>(t1) & static_cast<int>(t2);
221 }
222
223
224// Icon() subtypes
225enum class IconType : signed char {
226 NONE = -1,
229 SBEAM, MBEAM, NBEAM, BEAM32, BEAM64, AUTOBEAM,
230 FBEAM1, FBEAM2,
231 VFRAME, HFRAME, TFRAME, FFRAME, MEASURE,
232 BRACKETS, PARENTHESES, BRACES,
233 };
234
235//---------------------------------------------------------
236// MScoreError
237//---------------------------------------------------------
238
239enum MsError {
240 MS_NO_ERROR,
241 NO_NOTE_SELECTED,
242 NO_CHORD_REST_SELECTED,
243 NO_LYRICS_SELECTED,
244 NO_NOTE_REST_SELECTED,
245 NO_FLIPPABLE_SELECTED,
246 NO_STAFF_SELECTED,
247 NO_NOTE_FIGUREDBASS_SELECTED,
248 CANNOT_INSERT_TUPLET,
249 CANNOT_SPLIT_TUPLET,
250 CANNOT_SPLIT_MEASURE_FIRST_BEAT,
251 CANNOT_SPLIT_MEASURE_TUPLET,
252 NO_DEST,
253 DEST_TUPLET,
254 TUPLET_CROSSES_BAR,
255 DEST_LOCAL_TIME_SIGNATURE,
256 DEST_TREMOLO,
257 NO_MIME,
258 DEST_NO_CR,
259 CANNOT_CHANGE_LOCAL_TIMESIG,
260 CORRUPTED_MEASURE,
261 };
262
264struct MScoreError {
265 MsError no;
266 const char* group;
267 const char* txt;
268 };
269
270//---------------------------------------------------------
271// MPaintDevice
273//---------------------------------------------------------
274
275class MPaintDevice : public QPaintDevice {
276
277 protected:
278 virtual int metric(PaintDeviceMetric m) const;
279
280 public:
281 MPaintDevice() : QPaintDevice() {}
282 virtual QPaintEngine* paintEngine() const;
283 virtual ~MPaintDevice() {}
284 };
285
286//---------------------------------------------------------
287// MScore
288// MuseScore application object
289//---------------------------------------------------------
290
291class MScore {
292 Q_GADGET
293 static MStyle _baseStyle; // buildin initial style
294 static MStyle _defaultStyle; // buildin modified by preferences
295 static MStyle* _defaultStyleForParts;
296
297 static QString _globalShare;
298 static int _hRaster, _vRaster;
299 static bool _verticalOrientation;
300
301 static MPaintDevice* _paintDevice;
302
303 public:
304 enum class DirectionH : char { AUTO, LEFT, RIGHT };
305 enum class OrnamentStyle : char { DEFAULT, BAROQUE };
306 Q_ENUM(DirectionH);
307 Q_ENUM(OrnamentStyle);
308
309 static MsError _error;
310 static std::vector<MScoreError> errorList;
311
312 static void init();
313
314 static MStyle& baseStyle() { return _baseStyle; }
315 static void setBaseStyle(const MStyle& style) { _baseStyle = style; }
316 static MStyle& defaultStyle() { return _defaultStyle; }
317 static const MStyle* defaultStyleForParts() { return _defaultStyleForParts; }
318
319 static bool readDefaultStyle(QString file);
320 static void setDefaultStyle(const MStyle& s) { _defaultStyle = s; }
321 static void defaultStyleForPartsHasChanged();
322
323 static const QString& globalShare() { return _globalShare; }
324 static qreal hRaster() { return _hRaster; }
325 static qreal vRaster() { return _vRaster; }
326 static void setHRaster(int val) { _hRaster = val; }
327 static void setVRaster(int val) { _vRaster = val; }
328 static void setNudgeStep(qreal val) { nudgeStep = val; }
329 static void setNudgeStep10(qreal val) { nudgeStep10 = val; }
330 static void setNudgeStep50(qreal val) { nudgeStep50 = val; }
331
332 static bool verticalOrientation() { return _verticalOrientation; }
333 static void setVerticalOrientation(bool val) { _verticalOrientation = val; }
334
335 static QColor selectColor[VOICES];
336 static QColor defaultColor;
337 static QColor dropColor;
338 static QColor layoutBreakColor;
339 static QColor frameMarginColor;
340 static QColor bgColor;
341 static bool warnPitchRange;
342 static int pedalEventsMinTicks;
343
344 static bool harmonyPlayDisableCompatibility;
345 static bool harmonyPlayDisableNew;
346 static bool playRepeats;
347 static bool panPlayback;
348 static int playbackSpeedIncrement;
349 static qreal nudgeStep;
350 static qreal nudgeStep10;
351 static qreal nudgeStep50;
352 static int defaultPlayDuration;
353 static QString lastError;
354
355// #ifndef NDEBUG
356 static bool noHorizontalStretch;
357 static bool noVerticalStretch;
358 static bool showSegmentShapes;
359 static bool showSkylines;
360 static bool showMeasureShapes;
361 static bool showBoundingRect;
362 static bool showSystemBoundingRect;
363 static bool showCorruptedMeasures;
364 static bool useFallbackFont;
365// #endif
366 static bool debugMode;
367 static bool testMode;
368
369 static int division;
370 static int sampleRate;
371 static int mtcType;
372 static Sequencer* seq;
373
374 static bool saveTemplateMode;
375 static bool noGui;
376
377 static bool noExcerpts;
378 static bool noImages;
379
380 static bool pdfPrinting;
381 static bool svgPrinting;
382 static double pixelRatio;
383
384 static qreal verticalPageGap;
385 static qreal horizontalPageGapEven;
386 static qreal horizontalPageGapOdd;
387
388 static MPaintDevice* paintDevice();
389
390 static void setError(MsError e) { _error = e; }
391 static const char* errorMessage();
392 static const char* errorGroup();
393 };
394
395//---------------------------------------------------------
396// center
397//---------------------------------------------------------
398
399inline static qreal center(qreal x1, qreal x2)
400 {
401 return (x1 + (x2 - x1) * .5);
402 }
403
404//---------------------------------------------------------
405// limit
406//---------------------------------------------------------
407
408inline static int limit(int val, int min, int max)
409 {
410 if (val > max)
411 return max;
412 if (val < min)
413 return min;
414 return val;
415 }
416} // namespace Ms
417
418Q_DECLARE_METATYPE(Ms::BarLineType);
419
420#endif
Definition mscore.h:291
DirectionH
Definition mscore.h:304
OrnamentStyle
Definition mscore.h:305
Definition cursor.cpp:30