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 ()
23 Time_signature::do_brew_molecule () const
25 SCM st = get_elt_property ("style");
27 SCM frac = get_elt_property ("fraction");
32 n = gh_scm2int (gh_car (frac));
33 d = gh_scm2int (gh_cdr (frac));
39 String style (ly_scm2string (st));
42 return time_signature (n, 0);
46 return special_time_signature (style, n, d);
50 return time_signature (n,d);
54 Time_signature::special_time_signature (String s, int n, int d) const
56 // First guess: s contains only the signature style
57 String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
59 Molecule m = lookup_l ()->afm_find (symbolname, false);
63 // Second guess: s contains the full signature name
64 m = lookup_l ()->afm_find ("timesig-"+s, false);
68 // Resort to default layout with numbers
69 return time_signature (n,d);
74 Time_signature::time_signature (int num, int den) const
76 String sty = "timesig";
79 UGH: need to look at fontsize.
81 Molecule n (lookup_l ()->text (sty, to_str (num), paper_l ()));
82 Molecule d (lookup_l ()->text (sty, to_str (den), paper_l ()));
83 n.align_to (X_AXIS, CENTER);
84 d.align_to (X_AXIS, CENTER);
88 m.add_at_edge (Y_AXIS, UP, n, 0.0);
89 m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
94 m.align_to (Y_AXIS, CENTER);