]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
release: 1.3.55
[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   set_elt_property ("dot-count", gh_int2scm (0));
20 }
21
22 void
23 Dots::after_line_breaking ()
24 {
25   SCM d= get_elt_property ("dot-count");
26   if (!gh_number_p (d) || !gh_scm2int (d))
27     {
28       set_elt_property ("transparent", SCM_BOOL_T);
29       set_extent_callback (0, X_AXIS);
30       set_extent_callback (0, Y_AXIS);
31     }
32   else
33     {
34       if (!directional_element (this).get ())
35         directional_element (this).set (UP);
36
37       Staff_symbol_referencer_interface si (this);
38       int p = int (si.position_f ());
39       if (!(p % 2))
40         si.set_position (p  + directional_element (this).get ());
41     }
42 }
43
44 Molecule  
45 Dots::do_brew_molecule () const
46 {
47   Molecule mol (lookup_l ()->blank (Box (Interval (0,0),
48                                          Interval (0,0))));
49   Molecule d = lookup_l ()->afm_find (String ("dots-dot"));
50
51   Real dw = d.extent (X_AXIS).length ();
52   d.translate_axis (-dw, X_AXIS);
53
54
55   for (int i = gh_scm2int (get_elt_property ("dot-count")); i--; )
56     {
57       d.translate_axis (2*dw,X_AXIS);
58       mol.add_molecule (d);
59     }
60
61   return mol;
62 }
63
64
65