Fix substitution error in shape noteheads
[lilypond/mpolesky.git] / lily / percent-repeat-item.cc
blob7b09d44601769e52db5efa96deeda6605e3cd83c
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2001--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "percent-repeat-item.hh"
21 #include "item.hh"
22 #include "lookup.hh"
23 #include "font-interface.hh"
25 Stencil
26 Percent_repeat_item_interface::brew_slash (Grob *me)
28 Real slope = robust_scm2double (me->get_property ("slope"), 1);
29 Real wid = 2.0 / slope;
32 todo: check out if in staff-rule thickness normally.
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;
40 Stencil
41 Percent_repeat_item_interface::x_percent (Grob *me, int count)
43 Stencil m;
44 Stencil s = brew_slash (me);
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);
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);
58 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
59 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
61 m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
62 return m;
65 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
66 SCM
67 Percent_repeat_item_interface::double_percent (SCM grob)
69 Grob *me = unsmob_grob (grob);
70 Stencil m = x_percent (me, 2);
71 return m.smobbed_copy ();
74 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
75 SCM
76 Percent_repeat_item_interface::beat_slash (SCM grob)
78 Grob *me = unsmob_grob (grob);
79 Stencil m = brew_slash (me);
81 return m.smobbed_copy ();
84 ADD_INTERFACE (Percent_repeat_item_interface,
85 "Repeats that look like percent signs.",
87 /* properties */
88 "dot-negative-kern "
89 "slash-negative-kern "
90 "slope "
91 "thickness "