lilypond-1.3.66
[lilypond.git] / lily / dots.cc
blobccd29ae3b61a04843be48771f2eb31a665dac3d3
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"
17 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Dots,after_line_breaking);
19 SCM
20 Dots::after_line_breaking (SCM smob)
22 Item * p = dynamic_cast<Item*> (unsmob_element (smob));
24 SCM d= p->get_elt_property ("dot-count");
25 if (gh_number_p (d) && gh_scm2int (d))
27 if (!Directional_element_interface (p).get ())
28 Directional_element_interface (p).set (UP);
30 Staff_symbol_referencer_interface si (p);
31 int pos = int (si.position_f ());
32 if (!(pos % 2))
33 si.set_position (pos + Directional_element_interface (p).get ());
36 return SCM_UNDEFINED;
39 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Dots,brew_molecule);
41 SCM
42 Dots::brew_molecule (SCM d)
44 Score_element *sc = unsmob_element (d);
45 Molecule mol (sc->lookup_l ()->blank (Box (Interval (0,0),
46 Interval (0,0))));
48 SCM c = sc->get_elt_property ("dot-count");
49 if (gh_number_p (c))
51 Molecule d = sc->lookup_l ()->afm_find (String ("dots-dot"));
53 Real dw = d.extent (X_AXIS).length ();
54 d.translate_axis (-dw, X_AXIS);
57 for (int i = gh_scm2int (c); i--; )
59 d.translate_axis (2*dw,X_AXIS);
60 mol.add_molecule (d);
63 return mol.create_scheme ();