2 percent-repeat-item.cc -- implement Percent_repeat_item_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "percent-repeat-item.hh"
14 #include "font-interface.hh"
17 Percent_repeat_item_interface::brew_slash (Grob *me)
19 Real slope = robust_scm2double (me->get_property ("slope"), 1);
20 Real wid = 2.0 / slope;
23 todo: check out if in staff-rule thickness normally.
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);
32 todo: use grob props for dot_neg_kern, slash_neg_kern?
35 Percent_repeat_item_interface::x_percent (Grob *me, int count,
40 Stencil s = brew_slash (me);
42 for (int i = count; i--;)
44 m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0);
46 Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
48 d1.translate_axis (0.5, Y_AXIS);
49 d2.translate_axis (-0.5, Y_AXIS);
51 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern, 0);
52 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0);
57 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
59 Percent_repeat_item_interface::double_percent (SCM grob)
61 Grob *me = unsmob_grob (grob);
62 Stencil m = x_percent (me, 2, 0.75, 1.6);
63 m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
64 return m.smobbed_copy ();
67 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
69 Percent_repeat_item_interface::beat_slash (SCM grob)
71 Grob *me = unsmob_grob (grob);
72 Stencil m = brew_slash (me);
74 return m.smobbed_copy ();
77 ADD_INTERFACE (Percent_repeat_item_interface, "percent-repeat-interface",
78 "Repeats that look like percent signs",