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 GLUE_SCORE_ELEMENT(Time_signature
,brew_molecule
);
26 Time_signature::member_brew_molecule () const
28 SCM st
= get_elt_property ("style");
30 SCM frac
= get_elt_property ("fraction");
35 n
= gh_scm2int (gh_car (frac
));
36 d
= gh_scm2int (gh_cdr (frac
));
42 String
style (ly_scm2string (st
));
45 return time_signature (n
, 0).create_scheme();
49 return special_time_signature (style
, n
, d
).create_scheme();
53 return time_signature (n
,d
).create_scheme();
57 Time_signature::special_time_signature (String s
, int n
, int d
) const
59 // First guess: s contains only the signature style
60 String symbolname
= "timesig-" + s
+ to_str (n
) + "/" + to_str (d
);
62 Molecule m
= lookup_l ()->afm_find (symbolname
, false);
66 // Second guess: s contains the full signature name
67 m
= lookup_l ()->afm_find ("timesig-"+s
, false);
71 // Resort to default layout with numbers
72 return time_signature (n
,d
);
77 Time_signature::time_signature (int num
, int den
) const
79 String sty
= "timesig";
82 UGH: need to look at fontsize.
84 Molecule
n (lookup_l ()->text (sty
, to_str (num
), paper_l ()));
85 Molecule
d (lookup_l ()->text (sty
, to_str (den
), paper_l ()));
86 n
.align_to (X_AXIS
, CENTER
);
87 d
.align_to (X_AXIS
, CENTER
);
91 m
.add_at_edge (Y_AXIS
, UP
, n
, 0.0);
92 m
.add_at_edge (Y_AXIS
, DOWN
, d
, 0.0);
97 m
.align_to (Y_AXIS
, CENTER
);