(all-grob-descriptions): remove gap from
[lilypond.git] / lily / percent-repeat-item.cc
blob2c0ae42d2023f4dc2317f52ad2a3a8fd14a7df28
1 /*
2 percent-repeat-item.cc -- implement Percent_repeat_item_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9 #include <math.h>
11 #include "grob.hh"
12 #include "lookup.hh"
13 #include "stencil.hh"
14 #include "font-interface.hh"
15 #include "font-metric.hh"
16 #include "percent-repeat-item.hh"
19 Stencil
20 Percent_repeat_item_interface::brew_slash ( Grob *me)
22 Real slope = robust_scm2double (me->get_property ("slope"), 1);
23 Real wid = 2.0 / slope;
26 todo: check out if in staff-rule thickness normally.
28 Real thick = robust_scm2double (me->get_property ("thickness"), 1);
29 Stencil m = Lookup::repeat_slash (wid, slope, thick);
30 m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
31 return m;
35 todo: use grob props for dot_neg_kern, slash_neg_kern?
37 Stencil
38 Percent_repeat_item_interface::x_percent (Grob *me, int count,
39 Real dot_neg_kern,
40 Real slash_neg_kern)
42 Stencil m ;
43 Stencil s = brew_slash (me);
45 for (int i = count; i--;)
47 m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern,0);
49 Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots-dot");
50 Stencil d2 = d1;
51 d1.translate_axis (0.5, Y_AXIS );
52 d2.translate_axis (-0.5, Y_AXIS);
54 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern,0);
55 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern,0);
57 return m;
60 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface,double_percent,1);
61 SCM
62 Percent_repeat_item_interface::double_percent (SCM grob)
64 Grob *me = unsmob_grob (grob);
65 Stencil m = x_percent (me, 2, 0.75, 1.6);
66 m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
67 return m.smobbed_copy ();
70 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface,beat_slash,1);
71 SCM
72 Percent_repeat_item_interface::beat_slash (SCM grob)
74 Grob *me = unsmob_grob (grob);
75 Stencil m = brew_slash (me);
77 return m.smobbed_copy ();
80 ADD_INTERFACE (Percent_repeat_item_interface,"percent-repeat-interface",
81 "Repeats that look like percent signs",
82 "slope thickness");