Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / percent-repeat-item.cc
blobae8910fca496c61353eb1991c8cffa54d8d824ab
1 /*
2 percent-repeat-item.cc -- implement Percent_repeat_item_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "percent-repeat-item.hh"
10 #include "item.hh"
11 #include "lookup.hh"
12 #include "font-interface.hh"
14 Stencil
15 Percent_repeat_item_interface::brew_slash (Grob *me)
17 Real slope = robust_scm2double (me->get_property ("slope"), 1);
18 Real wid = 2.0 / slope;
21 todo: check out if in staff-rule thickness normally.
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;
29 Stencil
30 Percent_repeat_item_interface::x_percent (Grob *me, int count)
32 Stencil m;
33 Stencil s = brew_slash (me);
35 Real dot_neg_kern =
36 robust_scm2double (me->get_property ("dot-negative-kern"), 0.75);
37 Real slash_neg_kern =
38 robust_scm2double (me->get_property ("slash-negative-kern"), 1.6);
40 for (int i = count; i--;)
41 m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern);
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);
47 m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
48 m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
50 m.translate_axis (- m.extent (X_AXIS).center (), X_AXIS);
51 return m;
54 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, double_percent, 1);
55 SCM
56 Percent_repeat_item_interface::double_percent (SCM grob)
58 Grob *me = unsmob_grob (grob);
59 Stencil m = x_percent (me, 2);
60 return m.smobbed_copy ();
63 MAKE_SCHEME_CALLBACK (Percent_repeat_item_interface, beat_slash, 1);
64 SCM
65 Percent_repeat_item_interface::beat_slash (SCM grob)
67 Grob *me = unsmob_grob (grob);
68 Stencil m = brew_slash (me);
70 return m.smobbed_copy ();
73 ADD_INTERFACE (Percent_repeat_item_interface,
74 "Repeats that look like percent signs.",
76 /* properties */
77 "dot-negative-kern "
78 "slash-negative-kern "
79 "slope "
80 "thickness "