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);
19 TODO: make different functions for special and normal timesigs.
22 Time_signature::brew_molecule (SCM smob
)
24 Grob
* me
= unsmob_grob (smob
);
25 SCM st
= me
->get_grob_property ("style");
26 SCM frac
= me
->get_grob_property ("fraction");
31 n
= gh_scm2int (gh_car (frac
));
32 d
= gh_scm2int (gh_cdr (frac
));
38 String
style (ly_scm2string (scm_symbol_to_string (st
)));
41 return time_signature (me
, n
, 0).smobbed_copy ();
45 return special_time_signature (me
, style
, n
, d
).smobbed_copy ();
49 return time_signature (me
, n
,d
).smobbed_copy ();
53 Time_signature::special_time_signature (Grob
*me
, String s
, int n
, int d
)
56 Randomly probing the font sucks?
59 SCM alist_chain
= Font_interface::font_alist_chain (me
);
62 Font_interface::add_style (me
, ly_symbol2scm ("timesig-symbol"),
65 Font_metric
*feta
= Font_interface::get_font (me
, style_chain
);
68 First guess: s contains only the signature style, append fraction.
70 String symbolname
= "timesig-" + s
+ to_str (n
) + "/" + to_str (d
);
72 Molecule m
= feta
->find_by_name (symbolname
);
77 Second guess: s contains the full signature name
79 m
= feta
->find_by_name ("timesig-" + s
);
83 // Resort to default layout with numbers
84 return time_signature (me
, n
, d
);
89 Time_signature::time_signature (Grob
*me
,int num
, int den
)
91 SCM chain
= Font_interface::font_alist_chain (me
);
93 Molecule n
= Text_item::text2molecule (me
,
94 ly_str02scm (to_str (num
).ch_C ()),
96 Molecule d
= Text_item::text2molecule (me
,
97 ly_str02scm (to_str (den
).ch_C ()),
99 n
.align_to (X_AXIS
, CENTER
);
100 d
.align_to (X_AXIS
, CENTER
);
104 m
.add_at_edge (Y_AXIS
, UP
, n
, 0.0);
105 m
.add_at_edge (Y_AXIS
, DOWN
, d
, 0.0);
110 m
.align_to (Y_AXIS
, CENTER
);