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 "text-item.hh"
13 #include "time-signature.hh"
14 #include "paper-def.hh"
15 #include "font-interface.hh"
17 MAKE_SCHEME_CALLBACK(Time_signature,brew_molecule,1);
20 Time_signature::brew_molecule (SCM smob)
22 Score_element * me = unsmob_element (smob);
23 SCM st = me->get_elt_property ("style");
24 SCM frac = me->get_elt_property ("fraction");
29 n = gh_scm2int (gh_car (frac));
30 d = gh_scm2int (gh_cdr (frac));
36 String style (ly_scm2string (st));
39 return time_signature (me, n, 0).create_scheme();
43 return special_time_signature (me, style, n, d).create_scheme();
47 return time_signature (me, n,d).create_scheme();
51 Time_signature::special_time_signature (Score_element*me, String s, int n, int d)
53 // First guess: s contains only the signature style
54 String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
56 Molecule m = Font_interface::get_default_font (me)->find_by_name (symbolname);
60 // Second guess: s contains the full signature name
61 m = Font_interface::get_default_font (me)->find_by_name ("timesig-"+s);
65 // Resort to default layout with numbers
66 return time_signature (me, n,d);
71 Time_signature::time_signature (Score_element*me,int num, int den)
73 SCM chain = gh_list (me->mutable_property_alist_, me->immutable_property_alist_, SCM_UNDEFINED);
75 Molecule n = Text_item::text2molecule (me,
76 ly_str02scm (to_str (num).ch_C ()),
78 Molecule d = Text_item::text2molecule (me,
79 ly_str02scm (to_str (den).ch_C ()),
81 n.align_to (X_AXIS, CENTER);
82 d.align_to (X_AXIS, CENTER);
86 m.add_at_edge (Y_AXIS, UP, n, 0.0);
87 m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
92 m.align_to (Y_AXIS, CENTER);