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