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)
54 Randomly probing the font sucks?
57 SCM alist_chain = Font_interface::font_alist_chain (me);
60 Font_interface::add_style (me, ly_symbol2scm ("timesig-symbol"),
63 Font_metric *feta = Font_interface::get_font (me, style_chain);
66 First guess: s contains only the signature style, append fraction.
68 String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
70 Molecule m = feta->find_by_name (symbolname);
75 Second guess: s contains the full signature name
77 m = feta->find_by_name ("timesig-" + s);
81 // Resort to default layout with numbers
82 return time_signature (me, n, d);
87 Time_signature::time_signature (Score_element*me,int num, int den)
89 SCM chain = Font_interface::font_alist_chain (me);
91 Molecule n = Text_item::text2molecule (me,
92 ly_str02scm (to_str (num).ch_C ()),
94 Molecule d = Text_item::text2molecule (me,
95 ly_str02scm (to_str (den).ch_C ()),
97 n.align_to (X_AXIS, CENTER);
98 d.align_to (X_AXIS, CENTER);
102 m.add_at_edge (Y_AXIS, UP, n, 0.0);
103 m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
108 m.align_to (Y_AXIS, CENTER);