2 percent-repeat-item.cc -- implement Percent_repeat_item_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "percent-repeat-item.hh"
13 #include "font-interface.hh"
16 Percent_repeat_item_interface::brew_slash (Grob *me)
18 Real slope = robust_scm2double (me->get_property ("slope"), 1);
19 Real wid = 2.0 / slope;
22 todo: check out if in staff-rule thickness normally.
24 Real thick = robust_scm2double (me->get_property ("thickness"), 1);
25 Stencil m = Lookup::repeat_slash (wid, slope, thick);
26 m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
31 todo: use grob props for dot_neg_kern, slash_neg_kern?
34 Percent_repeat_item_interface::x_percent (Grob *me, int count,
39 Stencil s = brew_slash (me);
41 for (int i = count; i--;)
42 m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0);
43 Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
45 d1.translate_axis (0.5, Y_AXIS);
46 d2.translate_axis (-0.5, Y_AXIS);
48 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern, 0);
49 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0);
54 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
56 Percent_repeat_item_interface::double_percent (SCM grob)
58 Grob *me = unsmob_grob (grob);
59 Stencil m = x_percent (me, 2, 0.75, 1.6);
60 m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
61 return m.smobbed_copy ();
64 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
66 Percent_repeat_item_interface::beat_slash (SCM grob)
68 Grob *me = unsmob_grob (grob);
69 Stencil m = brew_slash (me);
71 return m.smobbed_copy ();
74 ADD_INTERFACE (Percent_repeat_item_interface, "percent-repeat-interface",
75 "Repeats that look like percent signs",