]> git.donarmstrong.com Git - lilypond.git/blob - lily/grid-line-interface.cc
* lily/translator-scheme.cc (ly:translator-property): Remove.
[lilypond.git] / lily / grid-line-interface.cc
1 /*
2   grid-line-interface.cc --  implement Grid_line_interface
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "grid-line-interface.hh"
11
12 #include "grob.hh"
13 #include "group-interface.hh"
14 #include "lookup.hh"
15 #include "output-def.hh"
16 #include "stencil.hh"
17
18
19 MAKE_SCHEME_CALLBACK (Grid_line_interface, print, 1);
20 SCM
21 Grid_line_interface::print (SCM smobbed_me)
22 {
23   Grob *me = unsmob_grob (smobbed_me);
24   SCM first_elt = me->get_property ("elements");
25
26   /* compute common refpoint of elements */
27   Grob *refp = common_refpoint_of_list (first_elt, me, Y_AXIS);
28   Interval iv;
29   
30   for (SCM elts = first_elt; scm_is_pair (elts); elts = scm_cdr (elts))
31     {
32       Grob *point = unsmob_grob (scm_car (elts));
33
34       iv.unite (point->extent (refp, Y_AXIS));
35     }
36
37   if (iv.is_empty ())
38     {
39       me->suicide ();
40       return SCM_EOL;
41     }
42
43   Real staffline = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
44   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
45     * staffline;
46
47
48   iv += - me->relative_coordinate (refp, Y_AXIS);
49   Stencil st = Lookup::filled_box (Box (Interval (0, thick),
50                                         iv));
51
52   return st.smobbed_copy ();
53 }
54
55 MAKE_SCHEME_CALLBACK (Grid_line_interface, width_callback, 2);
56 SCM
57 Grid_line_interface::width_callback (SCM element_smob, SCM scm_axis)
58 {
59   Grob *me = unsmob_grob (element_smob);
60   (void) scm_axis;
61   assert (scm_to_int (scm_axis) == X_AXIS);
62
63   Real staffline = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
64   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
65     * staffline;
66   
67   return ly_interval2scm (Interval (0, thick));
68 }
69
70 void
71 Grid_line_interface::add_grid_point (Grob *me, Grob *b)
72 {
73   Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
74   me->add_dependency (b);
75 }
76
77 ADD_INTERFACE (Grid_line_interface, "grid-line-interface",
78                "A  line that spanned between grid-points. ",
79                "elements thickness");
80
81
82 ADD_INTERFACE (Grid_point_interface, "grid-point-interface",
83                "A spanning point for grid lines. ",
84                "");