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