]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[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--2006 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 #include "international.hh"
18
19 MAKE_SCHEME_CALLBACK (Dots, print, 1);
20 SCM
21 Dots::print (SCM d)
22 {
23   Grob *sc = unsmob_grob (d);
24   Stencil mol;
25
26   SCM c = sc->get_property ("dot-count");
27
28   if (scm_is_number (c))
29     {
30       SCM scm_style = sc->get_property ("style");
31       string style ="";
32       if (scm_is_symbol (scm_style))
33         style = ly_symbol2string (scm_style);
34       string idx =  "dots.dot" + style;
35       Stencil d = Font_interface::get_default_font (sc)->find_by_name (idx);
36       if (d.is_empty ())
37         {
38           sc->warning (_f ("dot `%s' not found", idx.c_str ()));
39           return SCM_EOL;
40         }
41       Real dw = d.extent (X_AXIS).length ();
42
43       /*
44         we need to add a real blank box, to assure that
45         side-positioning doth not cancel the left-most padding.  */
46
47       /*
48         TODO: this should  be handled by side-position padding.
49       */
50       mol = Lookup::blank (Box (Interval (0, 0),
51                                 Interval (0, 0)));
52
53       for (int i = scm_to_int (c); i--;)
54         {
55           d.translate_axis (2 * dw, X_AXIS);
56           mol.add_at_edge (X_AXIS, RIGHT, d, dw, 0);
57         }
58     }
59   return mol.smobbed_copy ();
60 }
61
62 ADD_INTERFACE (Dots,
63                "The dots to go with a notehead or rest."
64                "@code{direction} sets the preferred direction to move in case of staff "
65                "line collisions.",
66
67                /* properties */
68                "direction "
69                "dot-count "
70                "style "
71                );