MuseScore/libmscore/style.h
2017-01-18 20:25:37 +01:00

771 lines
18 KiB
C++

//=============================================================================
// 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 "pageformat.h"
#include "chordlist.h"
namespace Ms {
enum class P_ID : int;
class XmlWriter;
struct ChordDescription;
class PageFormat;
class Element;
//---------------------------------------------------------
// StyleIdx
//
// Keep in sync with styleTypes[] in style.cpp
//---------------------------------------------------------
enum class StyleIdx {
NOSTYLE = -1,
staffUpperBorder,
staffLowerBorder,
staffDistance,
akkoladeDistance,
minSystemDistance,
maxSystemDistance,
lyricsPlacement,
lyricsPosAbove,
lyricsPosBelow,
lyricsMinTopDistance,
lyricsMinBottomDistance,
lyricsLineHeight,
lyricsDashMinLength,
lyricsDashMaxLength,
lyricsDashMaxDistance,
lyricsDashForce,
lyricsAlignVerseNumber,
lyricsLineThickness,
figuredBassFontFamily,
// figuredBassFontSize,
figuredBassYOffset,
figuredBassLineHeight,
figuredBassAlignment,
figuredBassStyle,
systemFrameDistance,
frameSystemDistance,
minMeasureWidth,
barWidth,
doubleBarWidth,
endBarWidth,
doubleBarDistance,
endBarDistance,
repeatBarlineDotSeparation,
repeatBarTips,
startBarlineSingle,
startBarlineMultiple,
bracketWidth,
bracketDistance,
akkoladeWidth,
akkoladeBarDistance,
dividerLeft,
dividerLeftSym,
dividerLeftX,
dividerLeftY,
dividerRight,
dividerRightSym,
dividerRightX,
dividerRightY,
clefLeftMargin,
keysigLeftMargin,
ambitusMargin,
timesigLeftMargin,
clefKeyRightMargin,
clefKeyDistance,
clefTimesigDistance,
keyTimesigDistance,
keyBarlineDistance,
systemHeaderDistance,
systemHeaderTimeSigDistance,
clefBarlineDistance,
timesigBarlineDistance,
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,
hairpinPlacement,
hairpinPosAbove,
hairpinPosBelow,
hairpinHeight,
hairpinContHeight,
hairpinLineWidth,
pedalPlacement,
pedalPosAbove,
pedalPosBelow,
pedalLineWidth,
pedalLineStyle,
trillPlacement,
trillPosAbove,
trillPosBelow,
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,
useStandardNoteNames,
useGermanNoteNames,
useFullGermanNoteNames,
useSolfeggioNoteNames,
useFrenchNoteNames,
automaticCapitalization,
lowerCaseMinorChords,
lowerCaseBassNotes,
allCapsNoteNames,
chordStyle,
chordsXmlFile,
chordDescriptionFile,
concertPitch,
createMultiMeasureRests,
minEmptyMeasures,
minMMRestWidth,
hideEmptyStaves,
dontHideStavesInFirstSystem,
hideInstrumentNameIfOneInstrument,
gateTime,
tenutoGateTime,
staccatoGateTime,
slurGateTime,
ArpeggioNoteDistance,
ArpeggioLineWidth,
ArpeggioHookLen,
SlurEndWidth,
SlurMidWidth,
SlurDottedWidth,
MinTieLength,
SectionPause,
MusicalSymbolFont,
MusicalTextFont,
showHeader,
headerFirstPage,
headerOddEven,
evenHeaderL,
evenHeaderC,
evenHeaderR,
oddHeaderL,
oddHeaderC,
oddHeaderR,
showFooter,
footerFirstPage,
footerOddEven,
evenFooterL,
evenFooterC,
evenFooterR,
oddFooterL,
oddFooterC,
oddFooterR,
voltaY,
voltaHook,
voltaLineWidth,
voltaLineStyle,
ottavaPlacement,
ottavaPosAbove,
ottavaPosBelow,
ottavaHook,
ottavaLineWidth,
ottavaLineStyle,
ottavaNumbersOnly,
tabClef,
tremoloWidth,
tremoloBoxHeight,
tremoloStrokeWidth,
tremoloDistance,
// TODO tremoloBeamLengthMultiplier,
// TODO tremoloMaxBeamLength,
linearStretch,
crossMeasureValues,
keySigNaturals,
tupletMaxSlope,
tupletOufOfStaff,
tupletVHeadDistance,
tupletVStemDistance,
tupletStemLeftDistance,
tupletStemRightDistance,
tupletNoteLeftDistance,
tupletNoteRightDistance,
tupletBracketWidth,
tupletDirection,
tupletNumberType,
tupletBracketType,
barreLineWidth,
fretMag,
scaleBarlines,
barGraceDistance,
minVerticalDistance,
ornamentStyle,
spatium,
autoplaceHairpinDynamicsDistance,
dynamicsPlacement,
dynamicsPosAbove,
dynamicsPosBelow,
dynamicsMinDistance,
autoplaceVerticalAlignRange,
textLinePlacement,
textLinePosAbove,
textLinePosBelow,
tremoloBarLineWidth,
defaultFontFace,
defaultFontSize,
defaultFontSpatiumDependent,
defaultFontBold,
defaultFontItalic,
defaultFontUnderline,
defaultAlign,
defaultFrame,
defaultFrameSquare,
defaultFrameCircle,
defaultFramePadding,
defaultFrameWidth,
defaultFrameRound,
defaultFrameFgColor,
defaultFrameBgColor,
defaultOffset,
defaultOffsetType,
defaultSystemFlag,
titleFontFace,
titleFontSize,
titleFontSpatiumDependent,
titleFontBold,
titleFontItalic,
titleFontUnderline,
titleAlign,
titleOffset,
titleOffsetType,
subTitleFontFace,
subTitleFontSize,
subTitleFontSpatiumDependent,
subTitleFontBold,
subTitleFontItalic,
subTitleFontUnderline,
subTitleAlign,
subTitleOffset,
subTitleOffsetType,
composerFontFace,
composerFontSize,
composerFontSpatiumDependent,
composerFontBold,
composerFontItalic,
composerFontUnderline,
composerAlign,
composerOffset,
composerOffsetType,
lyricistFontFace,
lyricistFontSize,
lyricistFontSpatiumDependent,
lyricistFontBold,
lyricistFontItalic,
lyricistFontUnderline,
lyricistAlign,
lyricistOffset,
lyricistOffsetType,
lyricsOddFontFace,
lyricsOddFontSize,
lyricsOddFontBold,
lyricsOddFontItalic,
lyricsOddFontUnderline,
lyricsOddAlign,
lyricsOddOffset,
lyricsEvenFontFace,
lyricsEvenFontSize,
lyricsEvenFontBold,
lyricsEvenFontItalic,
lyricsEvenFontUnderline,
lyricsEvenAlign,
lyricsEvenOffset,
fingeringFontFace,
fingeringFontSize,
fingeringFontBold,
fingeringFontItalic,
fingeringFontUnderline,
fingeringAlign,
fingeringFrame,
fingeringFrameSquare,
fingeringFrameCircle,
fingeringFramePadding,
fingeringFrameWidth,
fingeringFrameRound,
fingeringFrameFgColor,
fingeringFrameBgColor,
fingeringOffset,
lhGuitarFingeringFontFace,
lhGuitarFingeringFontSize,
lhGuitarFingeringFontBold,
lhGuitarFingeringFontItalic,
lhGuitarFingeringFontUnderline,
lhGuitarFingeringAlign,
lhGuitarFingeringFrame,
lhGuitarFingeringFrameSquare,
lhGuitarFingeringFrameCircle,
lhGuitarFingeringFramePadding,
lhGuitarFingeringFrameWidth,
lhGuitarFingeringFrameRound,
lhGuitarFingeringFrameFgColor,
lhGuitarFingeringFrameBgColor,
lhGuitarFingeringOffset,
rhGuitarFingeringFontFace,
rhGuitarFingeringFontSize,
rhGuitarFingeringFontBold,
rhGuitarFingeringFontItalic,
rhGuitarFingeringFontUnderline,
rhGuitarFingeringAlign,
rhGuitarFingeringFrame,
rhGuitarFingeringFrameSquare,
rhGuitarFingeringFrameCircle,
rhGuitarFingeringFramePadding,
rhGuitarFingeringFrameWidth,
rhGuitarFingeringFrameRound,
rhGuitarFingeringFrameFgColor,
rhGuitarFingeringFrameBgColor,
rhGuitarFingeringOffset,
stringNumberFontFace,
stringNumberFontSize,
stringNumberFontBold,
stringNumberFontItalic,
stringNumberFontUnderline,
stringNumberAlign,
stringNumberFrame,
stringNumberFrameSquare,
stringNumberFrameCircle,
stringNumberFramePadding,
stringNumberFrameWidth,
stringNumberFrameRound,
stringNumberFrameFgColor,
stringNumberFrameBgColor,
stringNumberOffset,
longInstrumentFontFace,
longInstrumentFontSize,
longInstrumentFontBold,
longInstrumentFontItalic,
longInstrumentFontUnderline,
shortInstrumentFontFace,
shortInstrumentFontSize,
shortInstrumentFontBold,
shortInstrumentFontItalic,
shortInstrumentFontUnderline,
partInstrumentFontFace,
partInstrumentFontSize,
partInstrumentFontBold,
partInstrumentFontItalic,
partInstrumentFontUnderline,
dynamicsFontFace,
dynamicsFontSize,
dynamicsFontBold,
dynamicsFontItalic,
dynamicsFontUnderline,
dynamicsAlign,
expressionFontFace,
expressionFontSize,
expressionFontBold,
expressionFontItalic,
expressionFontUnderline,
expressionAlign,
tempoFontFace,
tempoFontSize,
tempoFontBold,
tempoFontItalic,
tempoFontUnderline,
tempoAlign,
tempoOffset,
tempoSystemFlag,
metronomeFontFace,
metronomeFontSize,
metronomeFontBold,
metronomeFontItalic,
metronomeFontUnderline,
measureNumberFontFace,
measureNumberFontSize,
measureNumberFontBold,
measureNumberFontItalic,
measureNumberFontUnderline,
measureNumberOffset,
measureNumberOffsetType,
translatorFontFace,
translatorFontSize,
translatorFontBold,
translatorFontItalic,
translatorFontUnderline,
tupletFontFace,
tupletFontSize,
tupletFontBold,
tupletFontItalic,
tupletFontUnderline,
systemFontFace,
systemFontSize,
systemFontBold,
systemFontItalic,
systemFontUnderline,
systemOffset,
systemSystemFlag,
staffFontFace,
staffFontSize,
staffFontBold,
staffFontItalic,
staffFontUnderline,
staffOffset,
staffSystemFlag,
chordSymbolFontFace,
chordSymbolFontSize,
chordSymbolFontBold,
chordSymbolFontItalic,
chordSymbolFontUnderline,
rehearsalMarkFontFace,
rehearsalMarkFontSize,
rehearsalMarkFontBold,
rehearsalMarkFontItalic,
rehearsalMarkFontUnderline,
rehearsalMarkFrame,
rehearsalMarkFrameSquare,
rehearsalMarkFrameCircle,
rehearsalMarkFramePadding,
rehearsalMarkFrameWidth,
rehearsalMarkFrameRound,
rehearsalMarkFrameFgColor,
rehearsalMarkFrameBgColor,
rehearsalMarkSystemFlag,
repeatLeftFontFace,
repeatLeftFontSize,
repeatLeftFontBold,
repeatLeftFontItalic,
repeatLeftFontUnderline,
repeatLeftSystemFlag,
repeatRightFontFace,
repeatRightFontSize,
repeatRightFontBold,
repeatRightFontItalic,
repeatRightFontUnderline,
repeatRightSystemFlag,
voltaSubStyle,
voltaFontFace,
voltaFontSize,
voltaFontBold,
voltaFontItalic,
voltaFontUnderline,
voltaAlign,
voltaOffset,
frameFontFace,
frameFontSize,
frameFontBold,
frameFontItalic,
frameFontUnderline,
textLineFontFace,
textLineFontSize,
textLineFontBold,
textLineFontItalic,
textLineFontUnderline,
glissandoFontFace,
glissandoFontSize,
glissandoFontBold,
glissandoFontItalic,
glissandoFontUnderline,
ottavaFontFace,
ottavaFontSize,
ottavaFontBold,
ottavaFontItalic,
ottavaFontUnderline,
pedalFontFace,
pedalFontSize,
pedalFontBold,
pedalFontItalic,
pedalFontUnderline,
hairpinFontFace,
hairpinFontSize,
hairpinFontBold,
hairpinFontItalic,
hairpinFontUnderline,
bendFontFace,
bendFontSize,
bendFontBold,
bendFontItalic,
bendFontUnderline,
headerFontFace,
headerFontSize,
headerFontBold,
headerFontItalic,
headerFontUnderline,
footerFontFace,
footerFontSize,
footerFontBold,
footerFontItalic,
footerFontUnderline,
instrumentChangeFontFace,
instrumentChangeFontSize,
instrumentChangeFontBold,
instrumentChangeFontItalic,
instrumentChangeFontUnderline,
instrumentChangeOffset,
figuredBassFontFace,
figuredBassFontSize,
figuredBassFontBold,
figuredBassFontItalic,
figuredBassFontUnderline,
user1FontFace,
user1FontSize,
user1FontBold,
user1FontItalic,
user1FontUnderline,
user2FontFace,
user2FontSize,
user2FontBold,
user2FontItalic,
user2FontUnderline,
STYLES
};
//---------------------------------------------------------
// StyledProperty
//---------------------------------------------------------
struct StyledProperty {
StyleIdx styleIdx;
P_ID propertyIdx;
};
extern const std::vector<StyledProperty> fingeringStyle;
extern const std::vector<StyledProperty> titleStyle;
//-------------------------------------------------------------------
// SubStyle
// Enumerate the list of built-in substyles
// must be in sync with namedStyles array
//-------------------------------------------------------------------
enum class SubStyle {
DEFAULT,
TITLE,
SUBTITLE,
COMPOSER,
POET,
LYRIC1,
LYRIC2,
FINGERING,
LH_GUITAR_FINGERING,
RH_GUITAR_FINGERING,
STRING_NUMBER,
INSTRUMENT_LONG,
INSTRUMENT_SHORT,
INSTRUMENT_EXCERPT,
DYNAMICS,
EXPRESSION,
TEMPO,
METRONOME,
MEASURE_NUMBER,
TRANSLATOR,
TUPLET,
SYSTEM,
STAFF,
HARMONY,
REHEARSAL_MARK,
REPEAT_LEFT, // align to start of measure
REPEAT_RIGHT, // align to end of measure
VOLTA,
FRAME,
TEXTLINE,
GLISSANDO,
OTTAVA,
PEDAL,
HAIRPIN,
BEND,
HEADER,
FOOTER,
INSTRUMENT_CHANGE,
FIGURED_BASS,
USER1,
USER2,
SUBSTYLES
};
//---------------------------------------------------------
// MStyle
//---------------------------------------------------------
class MStyle {
std::array<QVariant, int(StyleIdx::STYLES)> _values;
std::array<qreal, int(StyleIdx::STYLES)> _precomputedValues;
ChordList _chordList;
PageFormat _pageFormat;
bool _customChordList; // if true, chordlist will be saved as part of score
public:
MStyle();
void precomputeValues();
QVariant value(StyleIdx idx) const { return _values[int(idx)]; }
qreal pvalue(StyleIdx idx) const { return _precomputedValues[int(idx)]; }
void set(StyleIdx idx, const QVariant& v);
bool isDefault(StyleIdx idx) const;
const ChordDescription* chordDescription(int id) const;
ChordList* chordList() { return &_chordList; }
void setChordList(ChordList*, bool custom = true); // Style gets ownership of ChordList
void setCustomChordList(bool t) { _customChordList = t; }
bool load(QFile* qf);
void load(XmlReader& e);
void save(XmlWriter& xml, bool optimize);
bool readProperties(XmlReader&);
PageFormat* pageFormat() { return &_pageFormat; }
const PageFormat* pageFormat() const { return &_pageFormat; }
void setPageFormat(const PageFormat& pf);
static const char* valueType(const StyleIdx);
static const char* valueName(const StyleIdx);
static StyleIdx styleIdx(const QString& name);
};
const std::vector<StyledProperty>& subStyle(const char*);
const std::vector<StyledProperty>& subStyle(SubStyle);
const char* subStyleName(SubStyle);
QString subStyleUserName(SubStyle);
SubStyle subStyleFromName(const QString&);
#ifndef NDEBUG
extern void checkStyles();
#endif
} // namespace Ms
#endif