]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
Run `make grand-replace'.
[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--2008 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 "international.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       SCM scm_style = sc->get_property ("style");
30       string style ="";
31       if (scm_is_symbol (scm_style))
32         style = ly_symbol2string (scm_style);
33       string idx =  "dots.dot" + style;
34       Stencil d = Font_interface::get_default_font (sc)->find_by_name (idx);
35       if (d.is_empty ())
36         {
37           sc->warning (_f ("dot `%s' not found", idx.c_str ()));
38           return SCM_EOL;
39         }
40       Real dw = d.extent (X_AXIS).length ();
41
42       /*
43         we need to add a real blank box, to assure that
44         side-positioning doth not cancel the left-most padding.  */
45
46       /*
47         TODO: this should  be handled by side-position padding.
48       */
49       mol = Lookup::blank (Box (Interval (0, 0),
50                                 Interval (0, 0)));
51
52       for (int i = scm_to_int (c); i--;)
53         {
54           d.translate_axis (2 * dw, X_AXIS);
55           mol.add_at_edge (X_AXIS, RIGHT, d, dw);
56         }
57     }
58   return mol.smobbed_copy ();
59 }
60
61 ADD_INTERFACE (Dots,
62                "The dots to go with a notehead or rest.  @code{direction}"
63                " sets the preferred direction to move in case of staff line"
64                " collisions.  @code{style} defaults to undefined, which is"
65                " normal 19th/20th century traditional style.  Set"
66                " @code{style} to @code{vaticana} for ancient type dots.",
67
68                /* properties */
69                "direction "
70                "dot-count "
71                "style "
72                );