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