]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
patch::: 1.3.93.jcn2
[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 MAKE_SCHEME_CALLBACK(Dots,quantised_position_callback,2);
19 SCM
20 Dots::quantised_position_callback (SCM element_smob, SCM axis)
21 {
22   Score_element *me = unsmob_element (element_smob);
23   Axis a = (Axis) gh_scm2int (axis);
24   assert (a == Y_AXIS);
25     
26   SCM d= me->get_elt_property ("dot-count");
27   if (gh_number_p (d) && gh_scm2int (d))
28     {
29       if (!Directional_element_interface::get (me))
30         Directional_element_interface::set (me, UP);
31
32       if (Staff_symbol_referencer::on_staffline (me))
33         return gh_double2scm (Staff_symbol_referencer::staff_space (me) / 2.0 * Directional_element_interface::get (me));
34     }
35
36   return gh_double2scm  (0.0);
37 }
38
39
40 MAKE_SCHEME_CALLBACK(Dots,brew_molecule,1);
41 SCM  
42 Dots::brew_molecule (SCM d)
43 {
44   Score_element *sc = unsmob_element (d);
45   Molecule mol (sc->lookup_l ()->blank (Box (Interval (0,0),
46                                          Interval (0,0))));
47
48   SCM c = sc->get_elt_property ("dot-count");
49   if (gh_number_p (c))
50     {
51       Molecule d = sc->lookup_l ()->afm_find (String ("dots-dot"));
52
53       Real dw = d.extent (X_AXIS).length ();
54       d.translate_axis (-dw, X_AXIS);
55
56
57       for (int i = gh_scm2int (c); i--; )
58         {
59           d.translate_axis (2*dw,X_AXIS);
60           mol.add_molecule (d);
61         }
62     }
63   return mol.create_scheme ();
64 }
65
66
67