]> git.donarmstrong.com Git - lilypond.git/blob - lily/percent-repeat-item.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / percent-repeat-item.cc
1 /*
2   percent-repeat-item.cc -- implement Percent_repeat_item_interface
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2006  Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "percent-repeat-item.hh"
10 #include "item.hh"
11 #include "lookup.hh"
12 #include "font-interface.hh"
13
14 Stencil
15 Percent_repeat_item_interface::brew_slash (Grob *me)
16 {
17   Real slope = robust_scm2double (me->get_property ("slope"), 1);
18   Real wid = 2.0 / slope;
19
20   /*
21     todo: check out if in staff-rule thickness normally.
22   */
23   Real thick = robust_scm2double (me->get_property ("thickness"), 1);
24   Stencil m = Lookup::repeat_slash (wid, slope, thick);
25   m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
26   return m;
27 }
28
29 /*
30   todo: use grob props for dot_neg_kern, slash_neg_kern?
31 */
32 Stencil
33 Percent_repeat_item_interface::x_percent (Grob *me, int count,
34                                           Real dot_neg_kern,
35                                           Real slash_neg_kern)
36 {
37   Stencil m;
38   Stencil s = brew_slash (me);
39
40   for (int i = count; i--;)
41     m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0);
42   Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
43   Stencil d2 = d1;
44   d1.translate_axis (0.5, Y_AXIS);
45   d2.translate_axis (-0.5, Y_AXIS);
46
47   m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern, 0);
48   m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0);
49
50   return m;
51 }
52
53 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
54 SCM
55 Percent_repeat_item_interface::double_percent (SCM grob)
56 {
57   Grob *me = unsmob_grob (grob);
58   Stencil m = x_percent (me, 2, 0.75, 1.6);
59   m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
60   return m.smobbed_copy ();
61 }
62
63 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
64 SCM
65 Percent_repeat_item_interface::beat_slash (SCM grob)
66 {
67   Grob *me = unsmob_grob (grob);
68   Stencil m = brew_slash (me);
69
70   return m.smobbed_copy ();
71 }
72
73 ADD_INTERFACE (Percent_repeat_item_interface,
74                "Repeats that look like percent signs",
75                
76                "slope "
77                "thickness ");
78