]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
release: 1.3.93
[lilypond.git] / lily / dots.cc
1 /*
2   dots.cc -- implement Dots
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
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"
16
17
18 Real
19 Dots::quantised_position_callback (Score_element * me, Axis a)
20 {
21   assert (a == Y_AXIS);
22     
23   SCM d= me->get_elt_property ("dot-count");
24   if (gh_number_p (d) && gh_scm2int (d))
25     {
26       if (!Directional_element_interface::get (me))
27         Directional_element_interface::set (me, UP);
28
29       if (Staff_symbol_referencer::on_staffline (me))
30         return Staff_symbol_referencer::staff_space (me) / 2.0 * Directional_element_interface::get (me);
31     }
32
33   return  0.0;
34 }
35
36
37 MAKE_SCHEME_CALLBACK(Dots,brew_molecule);
38 SCM  
39 Dots::brew_molecule (SCM d)
40 {
41   Score_element *sc = unsmob_element (d);
42   Molecule mol (sc->lookup_l ()->blank (Box (Interval (0,0),
43                                          Interval (0,0))));
44
45   SCM c = sc->get_elt_property ("dot-count");
46   if (gh_number_p (c))
47     {
48       Molecule d = sc->lookup_l ()->afm_find (String ("dots-dot"));
49
50       Real dw = d.extent (X_AXIS).length ();
51       d.translate_axis (-dw, X_AXIS);
52
53
54       for (int i = gh_scm2int (c); i--; )
55         {
56           d.translate_axis (2*dw,X_AXIS);
57           mol.add_molecule (d);
58         }
59     }
60   return mol.create_scheme ();
61 }
62
63
64