MuseScore Plugins 3.2.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.01"
22static constexpr int MSCVERSION = 301;
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
65
66class MStyle;
67class Sequencer;
68
69enum class HairpinType : signed char;
70
71#ifndef VOICES
72#define VOICES 4
73#endif
74
75inline int staff2track(int staffIdx) { return staffIdx << 2; }
76inline int track2staff(int voice) { return voice >> 2; }
77inline int track2voice(int track) { return track & 3; }
78inline int trackZeroVoice(int track) { return track & ~3; }
79
80static const int MAX_TAGS = 32;
81
82static constexpr qreal INCH = 25.4;
83static constexpr qreal PPI = 72.0; // printer points per inch
84static constexpr qreal DPI_F = 5;
85static constexpr qreal DPI = 72.0 * DPI_F;
86static constexpr qreal SPATIUM20 = 5.0 * (DPI / 72.0);
87static constexpr qreal DPMM = DPI / INCH;
88
89static constexpr int MAX_STAVES = 4;
90
91static const int SHADOW_NOTE_LIGHT = 135;
92
93static const char mimeSymbolFormat[] = "application/musescore/symbol";
94static const char mimeSymbolListFormat[] = "application/musescore/symbollist";
95static const char mimeStaffListFormat[] = "application/musescore/stafflist";
96
97static const int VISUAL_STRING_NONE = -100; // no ordinal for the visual repres. of string (topmost in TAB
98 // varies according to visual order and presence of bass strings)
99static const int STRING_NONE = -1; // no ordinal for a physical string (0 = topmost in instrument)
100static const int FRET_NONE = -1; // no ordinal for a fret
101
102//---------------------------------------------------------
103// BracketType
104// System Brackets
105//---------------------------------------------------------
106
107enum class BracketType : signed char {
108 NORMAL, BRACE, SQUARE, LINE, NO_BRACKET = -1
109 };
110
111//---------------------------------------------------------
112// PlaceText
113//---------------------------------------------------------
114
115enum class PlaceText : char {
116 AUTO, ABOVE, BELOW, LEFT
117 };
118
119//---------------------------------------------------------
120// TransposeDirection
121//---------------------------------------------------------
122
123enum class TransposeDirection : char {
124 UP, DOWN, CLOSEST
125 };
126
127//---------------------------------------------------------
128// TransposeMode
129//---------------------------------------------------------
130
131enum class TransposeMode : char {
132 BY_KEY, BY_INTERVAL, DIATONICALLY
133 };
134
135//---------------------------------------------------------
136// SelectType
137//---------------------------------------------------------
138
139enum class SelectType : char {
140 SINGLE, RANGE, ADD
141 };
142
143//---------------------------------------------------------
144// AccidentalVal
145//---------------------------------------------------------
146
147enum class AccidentalVal : signed char {
148 SHARP2 = 2,
149 SHARP = 1,
150 NATURAL = 0,
151 FLAT = -1,
152 FLAT2 = -2
153 };
154
155//---------------------------------------------------------
156// KeySigNaturals (positions of naturals in key sig. changes)
157//---------------------------------------------------------
158
159enum class KeySigNatural : char {
160 NONE = 0, // no naturals, except for change to CMaj/Amin
161 BEFORE = 1, // naturals before accidentals
162 AFTER = 2 // naturals after accidentals (but always before if going sharps <=> flats)
163 };
164
165//---------------------------------------------------------
166// UpDownMode
167//---------------------------------------------------------
168
169enum class UpDownMode : char {
170 CHROMATIC, OCTAVE, DIATONIC
171 };
172
173//---------------------------------------------------------
174// StaffGroup
175//---------------------------------------------------------
176
177enum class StaffGroup : char {
178 STANDARD, PERCUSSION, TAB
179 };
180const int STAFF_GROUP_MAX = int(StaffGroup::TAB) + 1; // out of enum to avoid compiler complains about not handled switch cases
181
182enum class NoteHeadScheme : char {
183 HEAD_NORMAL = 0,
184 HEAD_PITCHNAME,
185 HEAD_PITCHNAME_GERMAN,
186 HEAD_SOLFEGE,
187 HEAD_SOLFEGE_FIXED,
188 HEAD_SHAPE_NOTE_4,
189 HEAD_SHAPE_NOTE_7_AIKIN,
190 HEAD_SHAPE_NOTE_7_FUNK,
191 HEAD_SHAPE_NOTE_7_WALKER,
192 HEAD_SCHEMES
193 };
194
195//---------------------------------------------------------
196// BarLineType
197//---------------------------------------------------------
198
199enum class BarLineType {
200 NORMAL = 1,
201 DOUBLE = 2,
202 START_REPEAT = 4,
203 END_REPEAT = 8,
204 BROKEN = 0x10,
205 END = 0x20,
206 END_START_REPEAT = 0x40,
207 DOTTED = 0x80
208 };
209
210constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
211 return static_cast<BarLineType>(static_cast<int>(t1) | static_cast<int>(t2));
212 }
213constexpr bool operator& (BarLineType t1, BarLineType t2) {
214 return static_cast<int>(t1) & static_cast<int>(t2);
215 }
216
217
218// Icon() subtypes
219enum class IconType : signed char {
220 NONE = -1,
223 SBEAM, MBEAM, NBEAM, BEAM32, BEAM64, AUTOBEAM,
224 FBEAM1, FBEAM2,
225 VFRAME, HFRAME, TFRAME, FFRAME, MEASURE,
226 BRACKETS, PARENTHESES
227 };
228
229//---------------------------------------------------------
230// MScoreError
231//---------------------------------------------------------
232
233enum MsError {
234 MS_NO_ERROR,
235 NO_NOTE_SELECTED,
236 NO_CHORD_REST_SELECTED,
237 NO_LYRICS_SELECTED,
238 NO_NOTE_REST_SELECTED,
239 NO_NOTE_SLUR_SELECTED,
240 NO_STAFF_SELECTED,
241 NO_NOTE_FIGUREDBASS_SELECTED,
242 CANNOT_INSERT_TUPLET,
243 CANNOT_SPLIT_TUPLET,
244 CANNOT_SPLIT_MEASURE_FIRST_BEAT,
245 CANNOT_SPLIT_MEASURE_TUPLET,
246 NO_DEST,
247 DEST_TUPLET,
248 TUPLET_CROSSES_BAR,
249 DEST_LOCAL_TIME_SIGNATURE,
250 DEST_TREMOLO,
251 NO_MIME,
252 DEST_NO_CR,
253 CANNOT_CHANGE_LOCAL_TIMESIG,
254 };
255
257struct MScoreError {
258 MsError no;
259 const char* group;
260 const char* txt;
261 };
262
263//---------------------------------------------------------
264// MPaintDevice
266//---------------------------------------------------------
267
268class MPaintDevice : public QPaintDevice {
269
270 protected:
271 virtual int metric(PaintDeviceMetric m) const;
272
273 public:
274 MPaintDevice() : QPaintDevice() {}
275 virtual QPaintEngine* paintEngine() const;
276 virtual ~MPaintDevice() {}
277 };
278
279//---------------------------------------------------------
280// MScore
281// MuseScore application object
282//---------------------------------------------------------
283
284class MScore {
285 Q_GADGET
286 static MStyle _baseStyle; // buildin initial style
287 static MStyle _defaultStyle; // buildin modified by preferences
288 static MStyle* _defaultStyleForParts;
289
290 static QString _globalShare;
291 static int _hRaster, _vRaster;
292 static bool _verticalOrientation;
293
294 static MPaintDevice* _paintDevice;
295
296 public:
297 enum class DirectionH : char { AUTO, LEFT, RIGHT };
298 enum class OrnamentStyle : char { DEFAULT, BAROQUE };
299 Q_ENUM(DirectionH)
300 Q_ENUM(OrnamentStyle)
301
302 static MsError _error;
303 static std::vector<MScoreError> errorList;
304
305 static void init();
306
307 static const MStyle& baseStyle() { return _baseStyle; }
308 static MStyle& defaultStyle() { return _defaultStyle; }
309 static const MStyle* defaultStyleForParts() { return _defaultStyleForParts; }
310
311 static bool readDefaultStyle(QString file);
312 static void setDefaultStyle(const MStyle& s) { _defaultStyle = s; }
313 static void defaultStyleForPartsHasChanged();
314
315 static const QString& globalShare() { return _globalShare; }
316 static qreal hRaster() { return _hRaster; }
317 static qreal vRaster() { return _vRaster; }
318 static void setHRaster(int val) { _hRaster = val; }
319 static void setVRaster(int val) { _vRaster = val; }
320 static void setNudgeStep(qreal val) { nudgeStep = val; }
321 static void setNudgeStep10(qreal val) { nudgeStep10 = val; }
322 static void setNudgeStep50(qreal val) { nudgeStep50 = val; }
323
324 static bool verticalOrientation() { return _verticalOrientation; }
325 static void setVerticalOrientation(bool val) { _verticalOrientation = val; }
326
327 static QColor selectColor[4];
328 static QColor defaultColor;
329 static QColor dropColor;
330 static QColor layoutBreakColor;
331 static QColor frameMarginColor;
332 static QColor bgColor;
333 static bool warnPitchRange;
334
335 static bool playRepeats;
336 static bool panPlayback;
337 static qreal nudgeStep;
338 static qreal nudgeStep10;
339 static qreal nudgeStep50;
340 static int defaultPlayDuration;
341 static QString lastError;
342
343// #ifndef NDEBUG
344 static bool noHorizontalStretch;
345 static bool noVerticalStretch;
346 static bool showSegmentShapes;
347 static bool showSkylines;
348 static bool showMeasureShapes;
349 static bool showBoundingRect;
350 static bool showSystemBoundingRect;
351 static bool showCorruptedMeasures;
352 static bool useFallbackFont;
353// #endif
354 static bool debugMode;
355 static bool testMode;
356
357 static int division;
358 static int sampleRate;
359 static int mtcType;
360 static Sequencer* seq;
361
362 static bool saveTemplateMode;
363 static bool noGui;
364
365 static bool noExcerpts;
366 static bool noImages;
367
368 static bool pdfPrinting;
369 static bool svgPrinting;
370 static double pixelRatio;
371
372 static qreal verticalPageGap;
373 static qreal horizontalPageGapEven;
374 static qreal horizontalPageGapOdd;
375
376 static MPaintDevice* paintDevice();
377
378 static void setError(MsError e) { _error = e; }
379 static const char* errorMessage();
380 static const char* errorGroup();
381 };
382
383//---------------------------------------------------------
384// center
385//---------------------------------------------------------
386
387inline static qreal center(qreal x1, qreal x2)
388 {
389 return (x1 + (x2 - x1) * .5);
390 }
391
392//---------------------------------------------------------
393// limit
394//---------------------------------------------------------
395
396inline static int limit(int val, int min, int max)
397 {
398 if (val > max)
399 return max;
400 if (val < min)
401 return min;
402 return val;
403 }
404} // namespace Ms
405
406Q_DECLARE_METATYPE(Ms::BarLineType);
407
408#endif
Definition mscore.h:284
DirectionH
Definition mscore.h:297
OrnamentStyle
Definition mscore.h:298
Definition cursor.cpp:29