release commit
[lilypond.git] / lily / dots.cc
blobb6343f17b4c9911b7e43123df29bc204758be74c
1 /*
2 dots.cc -- implement Dots
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 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. */
61 TODO: this should be handled by side-position padding.
63 mol = Lookup::blank (Box (Interval (0,0),
64 Interval (0,0)));
66 for (int i = gh_scm2int (c); i--;)
68 d.translate_axis (2*dw,X_AXIS);
69 mol.add_at_edge (X_AXIS, RIGHT, d, dw, 0);
72 return mol.smobbed_copy ();
78 ADD_INTERFACE (Dots, "dots-interface",
79 "The dots to go with a notehead/rest. A separate interface, since they "
80 " are a party in collision resolution. "
81 " #'direction is the Direction to handle staff-line collisions in.",
82 "direction dot-count");