MuseScore/libmscore/style.h

395 lines
9.1 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2011 Werner Schweer
//
// 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 LICENCE.GPL
//=============================================================================
#ifndef __STYLE_H__
#define __STYLE_H__
#include "mscore.h"
#include "spatium.h"
#include "articulation.h"
2016-03-02 13:20:19 +01:00
#include "page.h"
#include "chordlist.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2016-11-19 11:51:21 +01:00
class XmlWriter;
2012-05-26 14:26:10 +02:00
struct ChordDescription;
class PageFormat;
class ChordList;
class Element;
//---------------------------------------------------------
// StyleIdx
//
// Keep in sync with styleTypes[] in style.cpp
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
enum class StyleIdx : int {
NOSTYLE = -1,
2014-05-26 15:31:36 +02:00
staffUpperBorder,
staffLowerBorder,
staffDistance,
akkoladeDistance,
minSystemDistance,
maxSystemDistance,
2016-08-26 12:43:43 +02:00
lyricsPlacement,
lyricsPosAbove,
lyricsPosBelow,
lyricsMinTopDistance,
2014-05-26 15:31:36 +02:00
lyricsMinBottomDistance,
lyricsLineHeight,
2016-08-26 12:43:43 +02:00
lyricsDashMinLength,
lyricsDashMaxLength,
lyricsDashMaxDistance,
lyricsDashForce,
lyricsAlignVerseNumber,
lyricsLineThickness,
2014-05-26 15:31:36 +02:00
figuredBassFontFamily,
figuredBassFontSize,
figuredBassYOffset,
figuredBassLineHeight,
figuredBassAlignment,
figuredBassStyle,
systemFrameDistance,
frameSystemDistance,
minMeasureWidth,
barWidth,
doubleBarWidth,
endBarWidth,
doubleBarDistance,
endBarDistance,
repeatBarlineDotSeparation,
2014-05-26 15:31:36 +02:00
repeatBarTips,
startBarlineSingle,
startBarlineMultiple,
bracketWidth,
bracketDistance,
akkoladeWidth,
akkoladeBarDistance,
2015-07-25 08:43:02 +02:00
dividerLeft,
dividerLeftSym,
dividerLeftX,
dividerLeftY,
dividerRight,
dividerRightSym,
dividerRightX,
dividerRightY,
2014-05-26 15:31:36 +02:00
clefLeftMargin,
keysigLeftMargin,
ambitusMargin,
2014-05-26 15:31:36 +02:00
timesigLeftMargin,
clefKeyRightMargin,
2016-10-06 12:21:28 +02:00
clefKeyDistance,
clefTimesigDistance,
keyTimesigDistance,
keyBarlineDistance,
systemHeaderDistance,
systemHeaderTimeSigDistance,
2016-03-02 13:20:19 +01:00
2014-05-26 15:31:36 +02:00
clefBarlineDistance,
timesigBarlineDistance,
2014-05-26 15:31:36 +02:00
stemWidth,
shortenStem,
shortStemProgression,
shortestStem,
beginRepeatLeftMargin,
minNoteDistance,
barNoteDistance,
barAccidentalDistance,
multiMeasureRestMargin,
noteBarDistance,
measureSpacing,
staffLineWidth,
ledgerLineWidth,
ledgerLineLength,
accidentalDistance,
accidentalNoteDistance,
beamWidth,
beamDistance,
beamMinLen,
beamNoSlope,
dotMag,
dotNoteDistance,
dotRestDistance,
dotDotDistance,
propertyDistanceHead,
propertyDistanceStem,
propertyDistance,
articulationMag,
lastSystemFillLimit,
2016-11-18 14:28:53 +01:00
hairpinPlacement,
hairpinPosAbove,
hairpinPosBelow,
2014-05-26 15:31:36 +02:00
hairpinHeight,
hairpinContHeight,
hairpinLineWidth,
2016-11-18 14:28:53 +01:00
pedalPlacement,
pedalPosAbove,
pedalPosBelow,
2014-05-26 15:31:36 +02:00
pedalLineWidth,
pedalLineStyle,
2016-11-18 14:28:53 +01:00
trillPlacement,
trillPosAbove,
trillPosBelow,
2014-05-26 15:31:36 +02:00
harmonyY,
harmonyFretDist,
minHarmonyDistance,
maxHarmonyBarDistance,
capoPosition,
fretNumMag,
fretNumPos,
fretY,
showPageNumber,
showPageNumberOne,
pageNumberOddEven,
showMeasureNumber,
showMeasureNumberOne,
measureNumberInterval,
measureNumberSystem,
measureNumberAllStaffs,
smallNoteMag,
graceNoteMag,
smallStaffMag,
smallClefMag,
genClef,
genKeysig,
genCourtesyTimesig,
genCourtesyKeysig,
genCourtesyClef,
swingRatio,
swingUnit,
2014-05-26 15:31:36 +02:00
useStandardNoteNames,
useGermanNoteNames,
useFullGermanNoteNames,
2014-05-26 15:31:36 +02:00
useSolfeggioNoteNames,
useFrenchNoteNames,
automaticCapitalization,
2014-05-26 15:31:36 +02:00
lowerCaseMinorChords,
lowerCaseBassNotes,
allCapsNoteNames,
2014-05-26 15:31:36 +02:00
chordStyle,
chordsXmlFile,
chordDescriptionFile,
concertPitch,
createMultiMeasureRests,
minEmptyMeasures,
minMMRestWidth,
hideEmptyStaves,
dontHideStavesInFirstSystem,
hideInstrumentNameIfOneInstrument,
gateTime,
tenutoGateTime,
staccatoGateTime,
slurGateTime,
ArpeggioNoteDistance,
ArpeggioLineWidth,
ArpeggioHookLen,
SlurEndWidth,
SlurMidWidth,
SlurDottedWidth,
MinTieLength,
SectionPause,
MusicalSymbolFont,
2014-07-26 11:03:22 +02:00
MusicalTextFont,
2014-05-26 15:31:36 +02:00
showHeader,
headerFirstPage,
headerOddEven,
evenHeaderL,
evenHeaderC,
evenHeaderR,
oddHeaderL,
oddHeaderC,
oddHeaderR,
showFooter,
footerFirstPage,
footerOddEven,
evenFooterL,
evenFooterC,
evenFooterR,
oddFooterL,
oddFooterC,
oddFooterR,
voltaY,
voltaHook,
voltaLineWidth,
voltaLineStyle,
2016-11-18 14:28:53 +01:00
ottavaPlacement,
ottavaPosAbove,
ottavaPosBelow,
2014-05-26 15:31:36 +02:00
ottavaHook,
ottavaLineWidth,
ottavaLineStyle,
ottavaNumbersOnly,
tabClef,
tremoloWidth,
tremoloBoxHeight,
tremoloStrokeWidth,
tremoloDistance,
// TODO tremoloBeamLengthMultiplier,
// TODO tremoloMaxBeamLength,
2014-05-26 15:31:36 +02:00
linearStretch,
crossMeasureValues,
keySigNaturals,
tupletMaxSlope,
tupletOufOfStaff,
tupletVHeadDistance,
tupletVStemDistance,
tupletStemLeftDistance,
tupletStemRightDistance,
tupletNoteLeftDistance,
tupletNoteRightDistance,
tupletBracketWidth,
tupletDirection,
tupletNumberType,
tupletBracketType,
2014-05-26 15:31:36 +02:00
barreLineWidth,
fretMag,
scaleBarlines,
barGraceDistance,
2016-01-04 14:48:58 +01:00
minVerticalDistance,
2016-03-02 13:20:19 +01:00
ornamentStyle,
spatium,
2016-01-04 14:48:58 +01:00
2016-07-25 12:29:24 +02:00
autoplaceHairpinDynamicsDistance,
2016-11-18 14:28:53 +01:00
dynamicsPlacement,
dynamicsPosAbove,
dynamicsPosBelow,
2016-08-02 17:00:49 +02:00
dynamicsMinDistance,
autoplaceVerticalAlignRange,
2016-07-25 12:29:24 +02:00
textLinePlacement,
textLinePosAbove,
textLinePosBelow,
2016-09-20 17:13:54 +02:00
tremoloBarLineWidth,
2014-05-26 15:31:36 +02:00
STYLES
2012-05-26 14:26:10 +02:00
};
2016-09-19 22:57:36 +02:00
//---------------------------------------------------------
// StyleType
//---------------------------------------------------------
struct StyleType {
StyleIdx _idx;
const char* _name; // xml name for read()/write()
QVariant _defaultValue;
public:
StyleIdx styleIdx() const { return _idx; }
int idx() const { return int(_idx); }
const char* valueType() const { return _defaultValue.typeName(); }
const char* name() const { return _name; }
const QVariant& defaultValue() const { return _defaultValue; }
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// MStyle
//---------------------------------------------------------
class MStyle {
2016-03-02 13:20:19 +01:00
QVector<QVariant> _values;
QVector<qreal> _precomputedValues;
ChordList _chordList;
QList<TextStyle> _textStyles;
PageFormat _pageFormat;
bool _customChordList; // if true, chordlist will be saved as part of score
void precomputeValues();
2012-05-26 14:26:10 +02:00
public:
MStyle();
MStyle(const MStyle&);
MStyle& operator=(const MStyle&);
2016-03-03 17:10:50 +01:00
// ~MStyle() {}
2012-05-26 14:26:10 +02:00
bool isDefault(StyleIdx idx) const;
const ChordDescription* chordDescription(int id) const;
2016-03-02 13:20:19 +01:00
ChordList* chordList() { return &_chordList; }
2014-03-15 12:15:49 +01:00
void setChordList(ChordList*, bool custom = true); // Style gets ownership of ChordList
2016-09-19 22:57:36 +02:00
void setCustomChordList(bool t) { _customChordList = t; }
2012-05-26 14:26:10 +02:00
const TextStyle& textStyle(TextStyleType) const;
2016-09-19 22:57:36 +02:00
TextStyle& textStyle(TextStyleType);
2012-05-26 14:26:10 +02:00
const TextStyle& textStyle(const QString& name) const;
TextStyleType textStyleType(const QString& name) const;
2012-05-26 14:26:10 +02:00
void setTextStyle(const TextStyle& ts);
void addTextStyle(const TextStyle& ts);
void removeTextStyle(const TextStyle& ts);
const QList<TextStyle>& textStyles() const;
2013-08-09 11:42:24 +02:00
2016-03-02 13:20:19 +01:00
void set(StyleIdx idx, const QVariant& v);
QVariant value(StyleIdx idx) const { return _values[int(idx)]; }
qreal pvalue(StyleIdx idx) const { return _precomputedValues[int(idx)]; }
2012-05-26 14:26:10 +02:00
bool load(QFile* qf);
2013-01-11 18:10:18 +01:00
void load(XmlReader& e);
2016-11-19 11:51:21 +01:00
void save(XmlWriter& xml, bool optimize);
2016-09-20 17:13:54 +02:00
2016-09-19 22:57:36 +02:00
void convertToUnit(const QString& tag, const QString& val);
2016-03-02 13:20:19 +01:00
PageFormat* pageFormat() { return &_pageFormat; }
const PageFormat* pageFormat() const { return &_pageFormat; }
2012-05-26 14:26:10 +02:00
void setPageFormat(const PageFormat& pf);
2016-03-02 13:20:19 +01:00
static const char* valueType(const StyleIdx);
static const char* valueName(const StyleIdx);
2016-09-19 22:57:36 +02:00
static StyleIdx styleIdx(const QString& name);
2012-05-26 14:26:10 +02:00
};
extern void initStyle(MStyle*);
2013-05-13 18:49:17 +02:00
} // namespace Ms
2014-03-10 10:50:12 +01:00
2012-05-26 14:26:10 +02:00
#endif