2 time-signature.cc -- implement Time_signature
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "molecule.hh"
12 #include "time-signature.hh"
13 #include "paper-def.hh"
16 MAKE_SCHEME_CALLBACK(Time_signature
,brew_molecule
);
19 Time_signature::brew_molecule (SCM smob
)
21 Score_element
* me
= unsmob_element (smob
);
22 SCM st
= me
->get_elt_property ("style");
23 SCM frac
= me
->get_elt_property ("fraction");
28 n
= gh_scm2int (gh_car (frac
));
29 d
= gh_scm2int (gh_cdr (frac
));
35 String
style (ly_scm2string (st
));
38 return time_signature (me
, n
, 0).create_scheme();
42 return special_time_signature (me
, style
, n
, d
).create_scheme();
46 return time_signature (me
, n
,d
).create_scheme();
50 Time_signature::special_time_signature (Score_element
*me
, String s
, int n
, int d
)
52 // First guess: s contains only the signature style
53 String symbolname
= "timesig-" + s
+ to_str (n
) + "/" + to_str (d
);
55 Molecule m
= me
->lookup_l ()->afm_find (symbolname
, false);
59 // Second guess: s contains the full signature name
60 m
= me
->lookup_l ()->afm_find ("timesig-"+s
, false);
64 // Resort to default layout with numbers
65 return time_signature (me
, n
,d
);
70 Time_signature::time_signature (Score_element
*me
,int num
, int den
)
72 String sty
= "timesig";
75 UGH: need to look at fontsize.
77 Molecule
n (me
->lookup_l ()->text (sty
, to_str (num
), me
->paper_l ()));
78 Molecule
d (me
->lookup_l ()->text (sty
, to_str (den
), me
->paper_l ()));
79 n
.align_to (X_AXIS
, CENTER
);
80 d
.align_to (X_AXIS
, CENTER
);
84 m
.add_at_edge (Y_AXIS
, UP
, n
, 0.0);
85 m
.add_at_edge (Y_AXIS
, DOWN
, d
, 0.0);
90 m
.align_to (Y_AXIS
, CENTER
);