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