1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2010-2015 Werner Schweer & 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 LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __STAFFTYPE_H__
14 #define __STAFFTYPE_H__
15 
16 #include "element.h"
17 #include "spatium.h"
18 #include "mscore.h"
19 #include "durationtype.h"
20 #include "note.h"
21 
22 namespace Ms {
23 
24 class Chord;
25 class ChordRest;
26 class Staff;
27 class XmlWriter;
28 
29 // all in spatium units
30 #define STAFFTYPE_TAB_DEFAULTSTEMLEN_UP   3.0
31 #define STAFFTYPE_TAB_DEFAULTSTEMDIST_UP  1.0
32 #define STAFFTYPE_TAB_DEFAULTSTEMPOSY_UP  -STAFFTYPE_TAB_DEFAULTSTEMDIST_UP
33 #define STAFFTYPE_TAB_DEFAULTSTEMLEN_DN   3.0
34 #define STAFFTYPE_TAB_DEFAULTSTEMDIST_DN  1.0
35 #define STAFFTYPE_TAB_DEFAULTSTEMPOSY_DN  STAFFTYPE_TAB_DEFAULTSTEMDIST_DN
36 #define STAFFTYPE_TAB_DEFAULTSTEMLEN_THRU 3.5
37 #define STAFFTYPE_TAB_DEFAULTSTEMPOSX     0.75
38 #define STAFFTYPE_TAB_DEFAULTDOTDIST_X    0.75
39 
40 // TAB STEM NOTATION
41 // the ratio between the length of a full stem and the length of a short stem
42 // (used for half note stems, in some TAB styles)
43 #define STAFFTYPE_TAB_SHORTSTEMRATIO      0.5
44 // metrics of slashes through half note stems
45 #define STAFFTYPE_TAB_SLASH_WIDTH         1.2   /* X width of half note slash */
46 #define STAFFTYPE_TAB_SLASH_SLANTY        0.8   /* the Y coord of the slash slant */
47 #define STAFFTYPE_TAB_SLASH_THICK         0.4   /* slash thickness */
48 #define STAFFTYPE_TAB_SLASH_DISPL         0.8   /* the total displacement between one slash and the next:
49                                                       includes slash thickness and empty space between slashes*/
50 // the total height of a double slash
51 #define STAFFTYPE_TAB_SLASH_2TOTHEIGHT     (STAFFTYPE_TAB_SLASH_THICK+STAFFTYPE_TAB_SLASH_DISPL+STAFFTYPE_TAB_SLASH_SLANTY)
52 // the initial Y coord for a double shash on an UP stem = topmost corner of topmost slash
53 #define STAFFTYPE_TAB_SLASH_2STARTY_UP     ((STAFFTYPE_TAB_DEFAULTSTEMLEN_UP-STAFFTYPE_TAB_SLASH_2TOTHEIGHT)*0.5)
54 // the initial Y coord for a double shash on an DN stem = topmost corner of topmost slash
55 #define STAFFTYPE_TAB_SLASH_2STARTY_DN     ((STAFFTYPE_TAB_DEFAULTSTEMLEN_UP+STAFFTYPE_TAB_SLASH_2TOTHEIGHT)*0.5)
56 // same for a 4-ple slash
57 #define STAFFTYPE_TAB_SLASH_4TOTHEIGHT     (STAFFTYPE_TAB_SLASH_THICK+STAFFTYPE_TAB_SLASH_DISPL*3+STAFFTYPE_TAB_SLASH_SLANTY)
58 // the initial Y coord for a double shash on an UP stem = topmost corner of topmost slash
59 #define STAFFTYPE_TAB_SLASH_4STARTY_UP     ((STAFFTYPE_TAB_DEFAULTSTEMLEN_UP-STAFFTYPE_TAB_SLASH_4TOTHEIGHT)*0.5)
60 // the initial Y coord for a double shash on an DN stem = topmost corner of topmost slash
61 #define STAFFTYPE_TAB_SLASH_4STARTY_DN     ((STAFFTYPE_TAB_DEFAULTSTEMLEN_UP+STAFFTYPE_TAB_SLASH_4TOTHEIGHT)*0.5)
62 
63 // HISTORIC TAB BASS STRING NOTATION
64 // The following constants refer to the specifics of bass string notation in historic
65 //    (Renaiss./Baroque French and Italian) tablatures.
66 
67 // how much to lower a bass string note with slashes with respect to line distance (in fraction of line distance)
68 #define STAFFTYPE_TAB_BASSSLASH_YOFFSET   0.33
69 // The following constants could ideially be customizeable values;
70 //    they are currently constants to simplify implementation;
71 // Note that these constants do not constrain which strings of an instrument are
72 //    physically frettable (which is defined in the instrument itself) but fix the
73 //    number of bass strings for which the notation is able to express a fret number
74 //    rather than simply a string ordinal.
75 #define NUM_OF_BASSSTRINGS_WITH_LETTER    4     // the max number of bass strings frettable with letter notation (French)
76 #define NUM_OF_BASSSTRINGS_WITH_NUMBER    2     // the max number of bass strings frettable with number notation (Italian)
77 
78 //---------------------------------------------------------
79 //   TablatureFont
80 //---------------------------------------------------------
81 
82 #define NUM_OF_DIGITFRETS                 100   // the max fret number which can be rendered with numbers
83 #define NUM_OF_LETTERFRETS                17    // the max fret number which can be rendered with letters
84 #define NUM_OF_BASSSTRING_SLASHES         5     // the max number of slashes supported for French bass strings notation
85                                                 // (currently, only 3 slashes are used at most; another two are
86                                                 // foreseen for future customizability)
87 
88 // default values for 'grid'-like beaming to use with value symbols in stemless TAB
89 static const qreal GRID_BEAM_DEF_WIDTH  = 0.25; // all values in sp
90 static const qreal GRID_STEM_DEF_HEIGHT = 1.75;
91 static const qreal GRID_STEM_DEF_WIDTH  = 0.125;
92 
93 struct TablatureFretFont {
94       QString family;                           // the family of the physical font to use
95       QString displayName;                      // the name to display to the user
96       qreal   defPitch;                         // the default size of the font
97       qreal   defYOffset;                       // the default Y displacement
98       QChar   xChar;                            // the char to use for 'x'
99       QChar   ghostChar;                        // the char to use for ghost notes
100       QString slashChar[NUM_OF_BASSSTRING_SLASHES];// the char used to draw one or more '/' symbols
101       QString displayDigit[NUM_OF_DIGITFRETS];  // the string to draw for digit frets
102       QChar   displayLetter[NUM_OF_LETTERFRETS];// the char to use for letter frets
103 
104       bool read(XmlReader&);
105       };
106 
107 enum class TabVal : char {
108       VAL_LONGA = 0,
109       VAL_BREVIS,
110       VAL_SEMIBREVIS,
111       VAL_MINIMA,
112       VAL_SEMIMINIMA,
113       VAL_FUSA,
114       VAL_SEMIFUSA,
115       VAL_32,
116       VAL_64,
117       VAL_128,
118       VAL_256,
119       VAL_512,
120       VAL_1024,
121       NUM_OF
122       };
123 
124 enum class TablatureMinimStyle : char {
125       NONE = 0,                       // do not draw half notes at all
126       SHORTER,                        // draw half notes with a shorter stem
127       SLASHED                         // draw half notes with stem with two slashes
128       };
129 
130 enum class TablatureSymbolRepeat : char {
131       NEVER = 0,                    // never repeat the same duration symbol
132       SYSTEM,                       // repeat at the beginning of a new system
133       MEASURE,                      // repeat at the beginning of a new measure
134       ALWAYS                        // always repeat
135       };
136 
137 struct TablatureDurationFont {
138       QString family;                 // the family of the physical font to use
139       QString displayName;            // the name to display to the user
140       qreal   defPitch;               // the default size of the font
141       qreal   defYOffset;             // the default Y displacement
142       qreal   gridBeamWidth  = GRID_BEAM_DEF_WIDTH;   // the width of the 'grid'-style beam (in sp)
143       qreal   gridStemHeight = GRID_STEM_DEF_HEIGHT;  // the height of the 'grid'-style stem (in sp)
144       qreal   gridStemWidth  = GRID_STEM_DEF_WIDTH;   // the width of the 'grid'-style stem (in sp)
145       // the note value with no beaming in 'grid'-style beaming
146       TDuration::DurationType zeroBeamLevel = TDuration::DurationType::V_QUARTER;
147       QChar   displayDot;             // the char to use to draw a dot
148       QChar   displayValue[int(TabVal::NUM_OF)];       // the char to use to draw a duration value
149 
150       bool read(XmlReader&);
151       };
152 
153 // ready-made staff types
154 // keep in sync with the _presets initialization in StaffType::initStaffTypes()
155 
156 enum class StaffTypes : signed char {
157       STANDARD,
158       PERC_1LINE, PERC_3LINE, PERC_5LINE,
159       TAB_6SIMPLE, TAB_6COMMON, TAB_6FULL,
160       TAB_4SIMPLE, TAB_4COMMON, TAB_4FULL,
161       TAB_5SIMPLE, TAB_5COMMON, TAB_5FULL,
162       TAB_UKULELE, TAB_BALALAJKA, TAB_DULCIMER,
163       TAB_ITALIAN, TAB_FRENCH,
164       TAB_7COMMON, TAB_8COMMON,
165       STAFF_TYPES,
166       // some useful shorthands:
167       PERC_DEFAULT = StaffTypes::PERC_5LINE,
168       TAB_DEFAULT = StaffTypes::TAB_6COMMON,
169       };
170 
171 static const int  STAFF_GROUP_NAME_MAX_LENGTH   = 32;
172 
173 //---------------------------------------------------------
174 //   StaffType
175 //---------------------------------------------------------
176 
177 class StaffType {
178       friend class TabDurationSymbol;
179 
180       StaffGroup _group = StaffGroup::STANDARD;
181 
182       QString _xmlName;                   // the name used to reference this preset in instruments.xml
183       QString _name;                      // user visible name
184 
185       qreal _userMag           { 1.0   };       // allowed 0.1 - 10.0
186       Spatium _yoffset         { 0.0   };
187       bool _small              { false };
188       bool _invisible          { false };
189       QColor _color            { QColor(Qt::black) };
190 
191       int _lines            = 5;
192       int _stepOffset       = 0;
193       Spatium _lineDistance = Spatium(1);
194 
195       bool _showBarlines    = true;
196       bool _showLedgerLines = true;
197       bool _stemless        = false;      // do not show stems
198 
199       bool _genClef         = true;       // create clef at beginning of system
200       bool _genTimesig      = true;       // whether time signature is shown or not
201       bool _genKeysig       = true;       // create key signature at beginning of system
202 
203       // Standard: configurable properties
204       NoteHead::Scheme _noteHeadScheme = NoteHead::Scheme::HEAD_NORMAL;
205 
206       // TAB: configurable properties
207       qreal _durationFontSize = 15.0;     // the size (in points) for the duration symbol font
208       qreal _durationFontUserY = 0.0;     // the vertical offset (spatium units) for the duration symb. font
209                                           // user configurable
210       qreal _fretFontSize  = 10.0;        // the size (in points) for the fret marks font
211       qreal _fretFontUserY = 0.0;         // additional vert. offset of fret marks with respect to
212                                           // the string line (spatium unit); user configurable
213       bool  _genDurations = false;        // whether duration symbols are drawn or not
214       bool  _linesThrough = false;        // whether lines for strings and stems may pass through fret marks or not
215       TablatureMinimStyle _minimStyle = TablatureMinimStyle::NONE;    // how to draw minim stems (stem-and-beam durations only)
216       TablatureSymbolRepeat _symRepeat = TablatureSymbolRepeat::NEVER;// if and when to repeat the same duration symbol
217       bool  _onLines      = true;         // whether fret marks are drawn on the string lines or between them
218       bool  _showRests    = false;        // whether to draw rests or not
219       bool  _stemsDown    = true;         // stems are drawn downward (stem-and-beam durations only)
220       bool  _stemsThrough = true;         // stems are drawn through the staff rather than beside it (stem-and-beam durations only)
221       bool  _upsideDown   = false;        // whether lines are drawn with highest string at top (false) or at bottom (true)
222       bool  _showTabFingering   = false;        // Allow fingering in tablature staff (true) or not (false)
223       bool  _useNumbers   = true;         // true: use numbers ('0' - ...) for frets | false: use letters ('a' - ...)
224       bool  _showBackTied = true;         // whether back-tied notes are shown or not
225 
226       // TAB: internally managed variables
227       // Note: values in RASTER UNITS are independent from score scaling and
228       //    must be multiplied by magS() to be used in contexts using sp units
229       mutable qreal _durationBoxH = 0.0;
230       qreal mutable _durationBoxY = 0.0;          // the height and the y rect.coord. (relative to staff top line)
231                                           // of a box bounding all duration symbols (raster units) internally computed:
232                                           // depends upon _onString and the metrics of the duration font
233       QFont _durationFont;                // font used to draw dur. symbols; cached for efficiency
234       int   _durationFontIdx = 0;         // the index of current dur. font in dur. font array
235       mutable qreal _durationYOffset = 0.0;       // the vertical offset to draw duration symbols with respect to the
236                                           // string lines (raster units); internally computed: depends upon _onString and duration font
237       mutable qreal _durationGridYOffset = 0.0;   // the vertical offset to draw the bottom of duration grid with respect to the
238                                           // string lines (raster units); internally computed: depends upon _onstring and duration font
239       mutable bool  _durationMetricsValid = false;  // whether duration font metrics are valid or not
240       mutable qreal _fretBoxH = 0.0;
241       mutable qreal _fretBoxY = 0.0;              // the height and the y rect.coord. (relative to staff line)
242                                           // of a box bounding all fret characters (raster units) internally computed:
243                                           // depends upon _onString, _useNumbers and the metrics of the fret font
244       QFont _fretFont;                    // font used to draw fret marks; cached for efficiency
245       int   _fretFontIdx = 0;             // the index of current fret font in fret font array
246       mutable qreal _fretYOffset = 0.0;           // the vertical offset to draw fret marks with respect to the string lines;
247                                           // (raster units); internally computed: depends upon _onString, _useNumbers
248                                           // and the metrics of the fret font
249       mutable  bool _fretMetricsValid = false;    // whether fret font metrics are valid or not
250       mutable qreal _refDPI = 0.0;                // reference value used to last computed metrics and to see if they are still valid
251 
252       // the array of configured fonts
253       static QList<TablatureFretFont> _fretFonts;
254       static QList<TablatureDurationFont> _durationFonts;
255       static std::vector<StaffType> _presets;
256 
257       void  setDurationMetrics() const;
258       void  setFretMetrics() const;
259 
260       static bool readConfigFile(const QString& fileName);
261       static const char    groupNames[STAFF_GROUP_MAX][STAFF_GROUP_NAME_MAX_LENGTH];      // used in UI
262       static const QString fileGroupNames[STAFF_GROUP_MAX];                               // used in .msc? files
263 
264    public:
265       StaffType();
266       StaffType(StaffGroup sg, const QString& xml, const QString& name, int lines, int stpOff, qreal lineDist,
267             bool genClef, bool showBarLines, bool stemless, bool genTimeSig,
268             bool genKeySig, bool showLedgerLines, bool invisible, const QColor& color);
269 
270       StaffType(StaffGroup sg, const QString& xml, const QString& name, int lines, int stpOff, qreal lineDist,
271             bool genClef, bool showBarLines, bool stemless, bool genTimesig, bool invisible, const QColor& color,
272             const QString& durFontName, qreal durFontSize, qreal durFontUserY, qreal genDur,
273             const QString& fretFontName, qreal fretFontSize, qreal fretFontUserY, TablatureSymbolRepeat symRepeat,
274             bool linesThrough, TablatureMinimStyle minimStyle, bool onLines, bool showRests,
275             bool stemsDown, bool stemThrough, bool upsideDown, bool showTabFingering, bool useNumbers, bool showBackTied);
276 
~StaffType()277       virtual ~StaffType() {}
278       bool operator==(const StaffType&) const;
279       bool isSameStructure(const StaffType&) const;
280 
group()281       StaffGroup group() const                 { return _group;           }
name()282       const QString& name() const              { return _name;            }
xmlName()283       const QString& xmlName() const           { return _xmlName;         }
setName(const QString & val)284       void setName(const QString& val)         { _name = val;             }
setXmlName(const QString & val)285       void setXmlName(const QString& val)      { _xmlName = val;          }
286       const char* groupName() const;
287       static const char* groupName(StaffGroup);
288 
setLines(int val)289       void setLines(int val)                   { _lines = val;            }
lines()290       int lines() const                        { return _lines;           }
setStepOffset(int v)291       void setStepOffset(int v)                { _stepOffset = v;         }
stepOffset()292       int stepOffset() const                   { return _stepOffset;      }
setLineDistance(const Spatium & val)293       void setLineDistance(const Spatium& val) { _lineDistance = val;     }
lineDistance()294       Spatium lineDistance() const             { return _lineDistance;    }
setGenClef(bool val)295       void setGenClef(bool val)                { _genClef = val;          }
genClef()296       bool genClef() const                     { return _genClef;         }
setShowBarlines(bool val)297       void setShowBarlines(bool val)           { _showBarlines = val;     }
showBarlines()298       bool showBarlines() const                { return _showBarlines;    }
userMag()299       qreal userMag() const                    { return _userMag;         }
small()300       bool small() const                       { return _small;           }
invisible()301       bool invisible() const                   { return _invisible;       }
color()302       const QColor& color() const              { return _color;           }
setUserMag(qreal val)303       void setUserMag(qreal val)               { _userMag = val;          }
setSmall(bool val)304       void setSmall(bool val)                  { _small = val;            }
setInvisible(bool val)305       void setInvisible(bool val)              { _invisible = val;        }
setColor(const QColor & val)306       void setColor(const QColor& val)         { _color = val;            }
yoffset()307       Spatium yoffset() const                  { return _yoffset;         }
setYoffset(Spatium val)308       void setYoffset(Spatium val)             { _yoffset = val;          }
309       qreal spatium(Score*) const;
310 
311       void write(XmlWriter& xml) const;
312       void read(XmlReader&);
313 
setStemless(bool val)314       void setStemless(bool val)               { _stemless = val;       }
stemless()315       bool stemless() const                    { return _stemless;      }
genTimesig()316       bool genTimesig() const                  { return _genTimesig;      }
setGenTimesig(bool val)317       void setGenTimesig(bool val)             { _genTimesig = val;       }
318       qreal doty1() const;
319       qreal doty2() const;
320 
321       // static function to deal with presets
322       static const StaffType* getDefaultPreset(StaffGroup grp);
323       static const StaffType* preset(StaffTypes idx);
324       static const StaffType* presetFromXmlName(QString& xmlName);
325 
setGenKeysig(bool val)326       void setGenKeysig(bool val)              { _genKeysig = val;          }
genKeysig()327       bool genKeysig() const                   { return _genKeysig;         }
setShowLedgerLines(bool val)328       void setShowLedgerLines(bool val)        { _showLedgerLines = val;    }
showLedgerLines()329       bool showLedgerLines() const             { return _showLedgerLines;   }
setNoteHeadScheme(NoteHead::Scheme s)330       void setNoteHeadScheme(NoteHead::Scheme s) { _noteHeadScheme = s;     }
noteHeadScheme()331       NoteHead::Scheme noteHeadScheme() const    { return _noteHeadScheme;  }
332 
333       QString fretString(int fret, int string, bool ghost) const;   // returns a string with the text for fret
334       QString durationString(TDuration::DurationType type, int dots) const;
335 
336       // functions to cope with historic TAB's peculiarities, like upside-down, bass string notations
337       int     physStringToVisual(int strg) const;                 // return the string in visual order from physical string
338       int     visualStringToPhys(int line) const;                 // return the string in physical order from visual string
339       qreal   physStringToYOffset(int strg) const;                // return the string Y offset (in sp, chord-relative)
340       QString tabBassStringPrefix(int strg, bool* hasFret) const; // return a string with the prefix, if any, identifying a bass string
341       void    drawInputStringMarks(QPainter* p, int string, int voice, QRectF rect) const;
342       int     numOfTabLedgerLines(int string) const;
343 
344       // properties getters (some getters require updated metrics)
345       qreal durationBoxH() const;
346       qreal durationBoxY() const;
347 
durationFont()348       const QFont&  durationFont() const     { return _durationFont;     }
durationFontName()349       const QString durationFontName() const { return _durationFonts[_durationFontIdx].displayName; }
durationFontSize()350       qreal durationFontSize() const      { return _durationFontSize;   }
durationFontUserY()351       qreal durationFontUserY() const     { return _durationFontUserY;  }
durationFontYOffset()352       qreal durationFontYOffset() const        { setDurationMetrics(); return _durationYOffset + _durationFontUserY * SPATIUM20; }
durationGridYOffset()353       qreal durationGridYOffset() const        { setDurationMetrics(); return _durationGridYOffset;}
fretBoxH()354       qreal fretBoxH() const              { setFretMetrics(); return _fretBoxH; }
fretBoxY()355       qreal fretBoxY() const              { setFretMetrics(); return _fretBoxY + _fretFontUserY * SPATIUM20; }
356 
357       // 2 methods to return the size of a box masking lines under a fret mark
fretMaskH()358       qreal fretMaskH() const             { return _lineDistance.val() * SPATIUM20; }
fretMaskY()359       qreal fretMaskY() const             { return (_onLines ? -0.5 : -1.0) * _lineDistance.val() * SPATIUM20; }
360 
fretFont()361       const QFont&  fretFont() const      { return _fretFont;           }
fretFontName()362       const QString fretFontName() const  { return _fretFonts[_fretFontIdx].displayName; }
fretFontSize()363       qreal fretFontSize() const          { return _fretFontSize;       }
fretFontUserY()364       qreal fretFontUserY() const         { return _fretFontUserY;      }
fretFontYOffset()365       qreal fretFontYOffset() const       { setFretMetrics(); return _fretYOffset + _fretFontUserY * SPATIUM20; }
genDurations()366       bool  genDurations() const          { return _genDurations;       }
linesThrough()367       bool  linesThrough() const          { return _linesThrough;       }
minimStyle()368       TablatureMinimStyle minimStyle() const    { return _minimStyle;   }
symRepeat()369       TablatureSymbolRepeat symRepeat() const   { return _symRepeat;    }
onLines()370       bool  onLines() const               { return _onLines;            }
showRests()371       bool  showRests() const             { return _showRests;          }
stemsDown()372       bool  stemsDown() const             { return _stemsDown;          }
stemThrough()373       bool  stemThrough() const           { return _stemsThrough;       }
upsideDown()374       bool  upsideDown() const            { return _upsideDown;         }
showTabFingering()375       bool  showTabFingering() const            { return _showTabFingering;         }
useNumbers()376       bool  useNumbers() const            { return _useNumbers;         }
showBackTied()377       bool  showBackTied() const          { return _showBackTied;       }
378 
379       // properties setters (setting some props invalidates metrics)
380       void  setDurationFontName(const QString&);
381       void  setDurationFontSize(qreal);
setDurationFontUserY(qreal val)382       void  setDurationFontUserY(qreal val)     { _durationFontUserY = val; }
383       void  setFretFontName(const QString&);
384       void  setFretFontSize(qreal);
setFretFontUserY(qreal val)385       void  setFretFontUserY(qreal val)   { _fretFontUserY = val;       }
setGenDurations(bool val)386       void  setGenDurations(bool val)     { _genDurations = val;        }
setLinesThrough(bool val)387       void  setLinesThrough(bool val)     { _linesThrough = val;        }
setMinimStyle(TablatureMinimStyle val)388       void  setMinimStyle(TablatureMinimStyle val)          { _minimStyle = val;    }
setSymbolRepeat(TablatureSymbolRepeat val)389       void  setSymbolRepeat(TablatureSymbolRepeat val)      { _symRepeat  = val;    }
390       void  setOnLines(bool);
setShowRests(bool val)391       void  setShowRests(bool val)        { _showRests = val;           }
setStemsDown(bool val)392       void  setStemsDown(bool val)        { _stemsDown = val;           }
setStemsThrough(bool val)393       void  setStemsThrough(bool val)     { _stemsThrough = val;        }
setUpsideDown(bool val)394       void  setUpsideDown(bool val)       { _upsideDown = val;          }
setShowTabFingering(bool val)395       void  setShowTabFingering (bool val) { _showTabFingering = val;         }
setUseNumbers(bool val)396       void  setUseNumbers(bool val)       { _useNumbers = val; _fretMetricsValid = false; }
setShowBackTied(bool val)397       void  setShowBackTied(bool val)     { _showBackTied = val;        }
398 
399       // utility functions for tab specially managed elements
400       QPointF chordStemPos(const Chord*) const;
401       qreal   chordRestStemPosY(const ChordRest*) const;
chordStemPosX(const Chord *)402       qreal   chordStemPosX(const Chord*) const       { return STAFFTYPE_TAB_DEFAULTSTEMPOSX; }
403       QPointF chordStemPosBeam(const  Chord*) const;
404       qreal   chordStemLength(const Chord*) const;
405 
isTabStaff()406       bool isTabStaff() const  { return _group == StaffGroup::TAB; }
isDrumStaff()407       bool isDrumStaff() const { return _group == StaffGroup::PERCUSSION; }
408       // static functions for font config files
409       static QList<QString> fontNames(bool bDuration);
410       static bool fontData(bool bDuration, int nIdx, QString *pFamily, QString *pDisplayName, qreal * pSize, qreal *pYOff);
411 
412       static void initStaffTypes();
presets()413       static const std::vector<StaffType>& presets() { return _presets; }
414       };
415 
416 //---------------------------------------------------------
417 //   TabDurationSymbol
418 //    Element used to draw duration symbols above tablatures
419 //---------------------------------------------------------
420 
421 enum class TabBeamGrid : char {
422       NONE = 0,
423       INITIAL,
424       MEDIALFINAL,
425       NUM_OF
426       };
427 
428 class TabDurationSymbol final : public Element {
429       qreal       _beamLength { 0.0 };      // if _grid==MEDIALFINAL, length of the beam toward previous grid element
430       int         _beamLevel  { 0 };       // if _grid==MEDIALFINAL, the number of beams
431       TabBeamGrid _beamGrid   { TabBeamGrid::NONE };        // value for special 'English' grid display
432       const StaffType*  _tab  { nullptr};
433       QString     _text;
434       bool        _repeat     { false };
435 
436    public:
437       TabDurationSymbol(Score* s);
438       TabDurationSymbol(Score* s, const StaffType* tab, TDuration::DurationType type, int dots);
439       TabDurationSymbol(const TabDurationSymbol&);
clone()440       TabDurationSymbol* clone() const override  { return new TabDurationSymbol(*this); }
441       void draw(QPainter*) const override;
isEditable()442       bool isEditable() const override           { return false; }
443       void layout() override;
type()444       ElementType type() const override          { return ElementType::TAB_DURATION_SYMBOL; }
445 
beamGrid()446       TabBeamGrid beamGrid()                     { return _beamGrid; }
447       void layout2();               // second step of layout: after horiz. pos. are defined, compute width of 'grid beams'
setDuration(TDuration::DurationType type,int dots,const StaffType * tab)448       void setDuration(TDuration::DurationType type, int dots, const StaffType* tab) {
449             _tab = tab;
450             _text = tab->durationString(type, dots);
451             }
isRepeat()452       bool isRepeat() const                     { return _repeat; }
setRepeat(bool val)453       void setRepeat(bool val)                  { _repeat = val;  }
454       };
455 
456 }     // namespace Ms
457 #endif
458