@@ -60,6 +60,7 @@ export class TimeSignature extends StaveModifier {
60
60
bottomLine : number ;
61
61
topLine : number ;
62
62
63
+ protected timeSpec : string = '4/4' ;
63
64
protected line : number = 0 ;
64
65
protected glyph : Glyph ;
65
66
protected is_numeric : boolean = true ;
@@ -68,21 +69,25 @@ export class TimeSignature extends StaveModifier {
68
69
constructor ( timeSpec : string = '4/4' , customPadding = 15 , validate_args = true ) {
69
70
super ( ) ;
70
71
this . validate_args = validate_args ;
71
-
72
- // violates DRY w/ setTimeSig(timeSpec) but needed to convince TypeScript that all is well.
73
- const info = this . parseTimeSpec ( timeSpec ) ;
74
- this . glyph = info . glyph ;
75
- this . is_numeric = info . num ;
76
- this . line = info . line ;
72
+ this . timeSpec = timeSpec ;
77
73
78
74
const padding = customPadding ;
79
75
76
+ // point must be defined before parsing spec.
80
77
const musicFont = Tables . currentMusicFont ( ) ;
81
78
this . point = musicFont . lookupMetric ( 'digits.point' ) ;
79
+
82
80
const fontLineShift = musicFont . lookupMetric ( 'digits.shiftLine' , 0 ) ;
83
81
this . topLine = 2 + fontLineShift ;
84
82
this . bottomLine = 4 + fontLineShift ;
85
83
this . setPosition ( StaveModifierPosition . BEGIN ) ;
84
+
85
+ // violates DRY w/ setTimeSig(timeSpec) but needed to convince TypeScript that all is well.
86
+ const info = this . parseTimeSpec ( timeSpec ) ;
87
+ this . glyph = info . glyph ;
88
+ this . is_numeric = info . num ;
89
+ this . line = info . line ;
90
+
86
91
this . setWidth ( defined ( this . glyph . getMetrics ( ) . width ) ) ;
87
92
this . setPadding ( padding ) ;
88
93
}
@@ -124,15 +129,22 @@ export class TimeSignature extends StaveModifier {
124
129
125
130
/**
126
131
* Set a new time signature specification without changing customPadding, etc.
132
+ *
133
+ * The getter for this is `getTimeSpec` not `getTimeSig`.
127
134
*/
128
135
setTimeSig ( timeSpec : string ) : this {
136
+ this . timeSpec = timeSpec ;
129
137
const info = this . parseTimeSpec ( timeSpec ) ;
130
138
this . glyph = info . glyph ;
131
139
this . is_numeric = info . num ;
132
140
this . line = info . line ;
133
141
return this ;
134
142
}
135
143
144
+ getTimeSpec ( ) : string {
145
+ return this . timeSpec ;
146
+ }
147
+
136
148
getLine ( ) : number {
137
149
return this . line ;
138
150
}
0 commit comments