]> git.donarmstrong.com Git - lilypond.git/blob - lily/dots.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / dots.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "dots.hh"
21
22 #include "item.hh"
23 #include "output-def.hh"
24 #include "font-interface.hh"
25 #include "lookup.hh"
26 #include "staff-symbol-referencer.hh"
27 #include "international.hh"
28
29 using std::string;
30
31 MAKE_SCHEME_CALLBACK (Dots, print, 1);
32 SCM
33 Dots::print (SCM d)
34 {
35   Grob *sc = unsmob<Grob> (d);
36   Stencil mol;
37
38   SCM c = sc->get_property ("dot-count");
39
40   if (scm_is_number (c))
41     {
42       SCM scm_style = sc->get_property ("style");
43       string style = "";
44       if (scm_is_symbol (scm_style))
45         style = ly_symbol2string (scm_style);
46       string idx = "dots.dot" + style;
47       Stencil d = Font_interface::get_default_font (sc)->find_by_name (idx);
48       if (d.is_empty ())
49         {
50           sc->warning (_f ("dot `%s' not found", idx.c_str ()));
51           return SCM_EOL;
52         }
53       Real dw = d.extent (X_AXIS).length ();
54
55       /*
56         we need to add a real blank box, to assure that
57         side-positioning doth not cancel the left-most padding.  */
58
59       /*
60         TODO: this should  be handled by side-position padding.
61       */
62       mol = Lookup::blank (Box (Interval (0, 0),
63                                 Interval (0, 0)));
64
65       for (int i = scm_to_int (c); i--;)
66         {
67           mol.add_at_edge (X_AXIS, RIGHT, d, dw);
68         }
69     }
70   return mol.smobbed_copy ();
71 }
72
73 ADD_INTERFACE (Dots,
74                "The dots to go with a notehead or rest.  @code{direction}"
75                " sets the preferred direction to move in case of staff line"
76                " collisions.  @code{style} defaults to undefined, which is"
77                " normal 19th/20th century traditional style.  Set"
78                " @code{style} to @code{vaticana} for ancient type dots.",
79
80                /* properties */
81                "direction "
82                "dot-count "
83                "style "
84               );