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"
23 #include "font-interface.hh"
25 #include "stream-event.hh"
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
);
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
);
50 Percent_repeat_item_interface::x_percent (Grob
*me
, int count
)
52 Stencil m
= brew_slash (me
, count
);
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");
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
);
68 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface
, double_percent
, 1);
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);
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);
88 m
= x_percent (me
, 2);
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.",
100 "slash-negative-kern "