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)
24 Time_signature::do_brew_molecule () const
26 SCM st = get_elt_property ("style");
28 SCM frac = get_elt_property ("fraction");
33 n = gh_scm2int (gh_car (frac));
34 d = gh_scm2int (gh_cdr (frac));
40 String style (ly_scm2string (st));
43 return time_signature (n, 0);
47 return special_time_signature (style, n, d);
51 return time_signature (n,d);
55 Time_signature::special_time_signature (String s, int n, int d) const
57 // First guess: s contains only the signature style
58 String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
60 Molecule m = lookup_l ()->afm_find (symbolname, false);
64 // Second guess: s contains the full signature name
65 m = lookup_l ()->afm_find ("timesig-"+s, false);
69 // Resort to default layout with numbers
70 return time_signature (n,d);
75 Time_signature::time_signature (int num, int den) const
77 String sty = "timesig";
80 UGH: need to look at fontsize.
82 Molecule n (lookup_l ()->text (sty, to_str (num), paper_l ()));
83 Molecule d (lookup_l ()->text (sty, to_str (den), paper_l ()));
84 n.align_to (X_AXIS, CENTER);
85 d.align_to (X_AXIS, CENTER);
89 m.add_at_edge (Y_AXIS, UP, n, 0.0);
90 m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
95 m.align_to (Y_AXIS, CENTER);