lilypond-1.3.72
[lilypond.git] / lily / dots.cc
blob1b702e293207749c85219d95b329ccb046041931
1 /*
2 dots.cc -- implement Dots
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 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 "lookup.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "directional-element-interface.hh"
18 Real
19 Dots::quantised_position_callback (Score_element * me, Axis a)
21 assert (a == Y_AXIS);
23 SCM d= me->get_elt_property ("dot-count");
24 if (gh_number_p (d) && gh_scm2int (d))
26 if (!Directional_element_interface (me).get ())
27 Directional_element_interface (me).set (UP);
30 int pos = int (Staff_symbol_referencer::position_f (me));
31 if (!(pos % 2))
32 return Staff_symbol_referencer::staff_space (me) / 2.0 * Directional_element_interface (me).get ();
35 return 0.0;
39 MAKE_SCHEME_CALLBACK(Dots,brew_molecule);
40 SCM
41 Dots::brew_molecule (SCM d)
43 Score_element *sc = unsmob_element (d);
44 Molecule mol (sc->lookup_l ()->blank (Box (Interval (0,0),
45 Interval (0,0))));
47 SCM c = sc->get_elt_property ("dot-count");
48 if (gh_number_p (c))
50 Molecule d = sc->lookup_l ()->afm_find (String ("dots-dot"));
52 Real dw = d.extent (X_AXIS).length ();
53 d.translate_axis (-dw, X_AXIS);
56 for (int i = gh_scm2int (c); i--; )
58 d.translate_axis (2*dw,X_AXIS);
59 mol.add_molecule (d);
62 return mol.create_scheme ();