]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
release: 1.3.62
[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 "molecule.hh"
11 #include "paper-def.hh"
12 #include "lookup.hh"
13 #include "staff-symbol-referencer.hh"
14 #include "directional-element-interface.hh"
15
16 Dots::Dots (SCM s)
17   : Item (s)
18 {
19 }
20
21 GLUE_SCORE_ELEMENT(Dots,after_line_breaking);
22 SCM
23 Dots::member_after_line_breaking ()
24 {
25   SCM d= get_elt_property ("dot-count");
26   if (gh_number_p (d) && gh_scm2int (d))
27     {
28       if (!directional_element (this).get ())
29         directional_element (this).set (UP);
30
31       Staff_symbol_referencer_interface si (this);
32       int p = int (si.position_f ());
33       if (!(p % 2))
34         si.set_position (p  + directional_element (this).get ());
35     }
36
37     return SCM_UNDEFINED;
38
39 }
40
41 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Dots,brew_molecule);
42
43 SCM  
44 Dots::brew_molecule (SCM d)
45 {
46   Score_element *sc = unsmob_element (d);
47   Molecule mol (sc->lookup_l ()->blank (Box (Interval (0,0),
48                                          Interval (0,0))));
49
50   SCM c = sc->get_elt_property ("dot-count");
51   if (gh_number_p (c))
52     {
53       Molecule d = sc->lookup_l ()->afm_find (String ("dots-dot"));
54
55       Real dw = d.extent (X_AXIS).length ();
56       d.translate_axis (-dw, X_AXIS);
57
58
59       for (int i = gh_scm2int (c); i--; )
60         {
61           d.translate_axis (2*dw,X_AXIS);
62           mol.add_molecule (d);
63         }
64     }
65   return mol.create_scheme ();
66 }
67
68
69