]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
release commit
[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--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "dots.hh"
10
11 #include "item.hh"
12 #include "output-def.hh"
13 #include "font-interface.hh"
14 #include "lookup.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "directional-element-interface.hh"
17
18 MAKE_SCHEME_CALLBACK (Dots, print, 1);
19 SCM
20 Dots::print (SCM d)
21 {
22   Grob *sc = unsmob_grob (d);
23   Stencil mol;
24
25   SCM c = sc->get_property ("dot-count");
26
27   if (scm_is_number (c))
28     {
29       Stencil d = Font_interface::get_default_font (sc)->find_by_name (String ("dots.dot"));
30       Real dw = d.extent (X_AXIS).length ();
31
32       /*
33         we need to add a real blank box, to assure that
34         side-positioning doth not cancel the left-most padding.  */
35
36       /*
37         TODO: this should  be handled by side-position padding.
38       */
39       mol = Lookup::blank (Box (Interval (0, 0),
40                                 Interval (0, 0)));
41
42       for (int i = scm_to_int (c); i--;)
43         {
44           d.translate_axis (2 * dw, X_AXIS);
45           mol.add_at_edge (X_AXIS, RIGHT, d, dw, 0);
46         }
47     }
48   return mol.smobbed_copy ();
49 }
50
51 ADD_INTERFACE (Dots, "dots-interface",
52                "The dots to go with a notehead or rest."
53                "@code{direction} sets the preferred direction to move in case of staff "
54                "line collisions.",
55
56                /* properties */
57                "direction "
58                "dot-count");
59