]> git.donarmstrong.com Git - lilypond.git/blob - lily/percent-repeat-item.cc
Typo.
[lilypond.git] / lily / percent-repeat-item.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2001--2011  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 "percent-repeat-item.hh"
21 #include "item.hh"
22 #include "lookup.hh"
23 #include "font-interface.hh"
24
25 Stencil
26 Percent_repeat_item_interface::brew_slash (Grob *me)
27 {
28   Real slope = robust_scm2double (me->get_property ("slope"), 1);
29   Real wid = 2.0 / slope;
30
31   /*
32     todo: check out if in staff-rule thickness normally.
33   */
34   Real thick = robust_scm2double (me->get_property ("thickness"), 1);
35   Stencil m = Lookup::repeat_slash (wid, slope, thick);
36   m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
37   return m;
38 }
39
40 Stencil
41 Percent_repeat_item_interface::x_percent (Grob *me, int count)
42 {
43   Stencil m;
44   Stencil s = brew_slash (me);
45
46   Real dot_neg_kern =
47     robust_scm2double (me->get_property ("dot-negative-kern"), 0.75);
48   Real slash_neg_kern =
49     robust_scm2double (me->get_property ("slash-negative-kern"), 1.6);
50
51   for (int i = count; i--;)
52     m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern);
53   Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
54   Stencil d2 = d1;
55   d1.translate_axis (0.5, Y_AXIS);
56   d2.translate_axis (-0.5, Y_AXIS);
57
58   m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
59   m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
60
61   m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
62   return m;
63 }
64
65 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
66 SCM
67 Percent_repeat_item_interface::double_percent (SCM grob)
68 {
69   Grob *me = unsmob_grob (grob);
70   Stencil m = x_percent (me, 2);
71   return m.smobbed_copy ();
72 }
73
74 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
75 SCM
76 Percent_repeat_item_interface::beat_slash (SCM grob)
77 {
78   Grob *me = unsmob_grob (grob);
79   Stencil m = brew_slash (me);
80
81   return m.smobbed_copy ();
82 }
83
84 ADD_INTERFACE (Percent_repeat_item_interface,
85                "Repeats that look like percent signs.",
86                
87                /* properties */
88                "dot-negative-kern "
89                "slash-negative-kern "
90                "slope "
91                "thickness "
92                );
93