lilypond-1.5.10
[lilypond.git] / lily / dots.cc
blob2f8202a4653ec36d83d0943f145cc24cd7222734
1 /*
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>
7 */
9 #include "dots.hh"
10 #include "item.hh"
11 #include "molecule.hh"
12 #include "paper-def.hh"
13 #include "font-interface.hh"
14 #include "lookup.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "directional-element-interface.hh"
19 MAKE_SCHEME_CALLBACK (Dots,quantised_position_callback,2);
20 SCM
21 Dots::quantised_position_callback (SCM element_smob, SCM axis)
23 Grob *me = unsmob_grob (element_smob);
24 Axis a = (Axis) gh_scm2int (axis);
25 assert (a == Y_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);
42 SCM
43 Dots::brew_molecule (SCM d)
45 Grob *sc = unsmob_grob (d);
46 Molecule mol;
48 SCM c = sc->get_grob_property ("dot-count");
50 if (gh_number_p (c))
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),
60 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 ();