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 Time_signature::Time_signature (SCM s)
23 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Time_signature)
25 Time_signature::do_brew_molecule () const
27 SCM st = get_elt_property ("style");
29 SCM frac = get_elt_property ("fraction");
34 n = gh_scm2int (gh_car (frac));
35 d = gh_scm2int (gh_cdr (frac));
41 String style (ly_scm2string (st));
44 return time_signature (n, 0);
48 return special_time_signature (style, n, d);
52 return time_signature (n,d);
56 Time_signature::special_time_signature (String s, int n, int d) const
58 // First guess: s contains only the signature style
59 String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
61 Molecule m = lookup_l ()->afm_find (symbolname, false);
65 // Second guess: s contains the full signature name
66 m = lookup_l ()->afm_find ("timesig-"+s, false);
70 // Resort to default layout with numbers
71 return time_signature (n,d);
76 Time_signature::time_signature (int num, int den) const
78 String sty = "timesig";
81 UGH: need to look at fontsize.
83 Molecule n (lookup_l ()->text (sty, to_str (num), paper_l ()));
84 Molecule d (lookup_l ()->text (sty, to_str (den), paper_l ()));
85 n.align_to (X_AXIS, CENTER);
86 d.align_to (X_AXIS, CENTER);
90 m.add_at_edge (Y_AXIS, UP, n, 0.0);
91 m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
96 m.align_to (Y_AXIS, CENTER);