Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / percent-repeat-item.cc
blob1e97753feecd95414538f4847f9613aac0d41b92
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2001--2011 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"
22 #include "item.hh"
23 #include "font-interface.hh"
24 #include "lookup.hh"
25 #include "stream-event.hh"
27 Stencil
28 Percent_repeat_item_interface::brew_slash (Grob *me, int count)
30 Real slope = robust_scm2double (me->get_property ("slope"), 1);
31 Real wid = 2.0 / slope;
34 todo: check out if in staff-rule thickness normally.
36 Real thick = robust_scm2double (me->get_property ("thickness"), 1);
37 Stencil slash = Lookup::repeat_slash (wid, slope, thick);
38 Stencil m = slash;
40 Real slash_neg_kern =
41 robust_scm2double (me->get_property ("slash-negative-kern"), 1.6);
42 for (int i = count - 1; i--;)
43 m.add_at_edge (X_AXIS, RIGHT, slash, -slash_neg_kern);
45 m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
46 return m;
49 Stencil
50 Percent_repeat_item_interface::x_percent (Grob *me, int count)
52 Stencil m = brew_slash (me, count);
54 Real dot_neg_kern =
55 robust_scm2double (me->get_property ("dot-negative-kern"), 0.75);
57 Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
58 Stencil d2 = d1;
59 d1.translate_axis (0.5, Y_AXIS);
60 d2.translate_axis (-0.5, Y_AXIS);
62 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
63 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
65 return m;
68 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
69 SCM
70 Percent_repeat_item_interface::double_percent (SCM grob)
72 Grob *me = unsmob_grob (grob);
73 Stencil m = x_percent (me, 2);
74 m.translate_axis (-m.extent (X_AXIS).center (), X_AXIS);
75 return m.smobbed_copy ();
78 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
79 SCM
80 Percent_repeat_item_interface::beat_slash (SCM grob)
82 Grob *me = unsmob_grob (grob);
83 Stream_event *cause = unsmob_stream_event (me->get_property ("cause"));
84 int count = robust_scm2int (cause->get_property ("slash-count"), 1);
86 Stencil m;
87 if (count == 0)
88 m = x_percent (me, 2);
89 else
90 m = brew_slash (me, count);
92 return m.smobbed_copy ();
95 ADD_INTERFACE (Percent_repeat_item_interface,
96 "Repeats that look like percent signs.",
98 /* properties */
99 "dot-negative-kern "
100 "slash-negative-kern "
101 "slope "
102 "thickness "