2 dots.cc -- implement Dots
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "molecule.hh"
12 #include "paper-def.hh"
13 #include "font-interface.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "directional-element-interface.hh"
19 MAKE_SCHEME_CALLBACK (Dots
,quantised_position_callback
,2);
21 Dots::quantised_position_callback (SCM element_smob
, SCM axis
)
23 Grob
*me
= unsmob_grob (element_smob
);
24 Axis a
= (Axis
) gh_scm2int (axis
);
27 SCM d
= me
->get_grob_property ("dot-count");
28 if (gh_number_p (d
) && gh_scm2int (d
))
30 if (!Directional_element_interface::get (me
))
31 Directional_element_interface::set (me
, UP
);
33 if (Staff_symbol_referencer::on_staffline (me
))
34 return gh_double2scm (Staff_symbol_referencer::staff_space (me
) / 2.0 * Directional_element_interface::get (me
));
37 return gh_double2scm (0.0);
41 MAKE_SCHEME_CALLBACK (Dots
,brew_molecule
,1);
43 Dots::brew_molecule (SCM d
)
45 Grob
*sc
= unsmob_grob (d
);
48 SCM c
= sc
->get_grob_property ("dot-count");
52 Molecule d
= Font_interface::get_default_font (sc
)->find_by_name (String ("dots-dot"));
53 Real dw
= d
.extent (X_AXIS
).length ();
57 we need to add a real blank box, to assure that
58 side-positioning doth not cancel the left-most padding. */
59 mol
= Lookup::blank (Box (Interval (0,0),
62 for (int i
= gh_scm2int (c
); i
--;)
64 d
.translate_axis (2*dw
,X_AXIS
);
65 mol
.add_at_edge (X_AXIS
, RIGHT
, d
, dw
);
68 return mol
.smobbed_copy ();