]> git.donarmstrong.com Git - lilypond.git/blob - lily/grid-line-interface.cc
* input/regression/grid-lines.ly (Module): new file.
[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 "group-interface.hh"
11 #include "output-def.hh"
12 #include "stencil.hh"
13 #include "lookup.hh"
14 #include "grid-line-interface.hh"
15 #include "grob.hh"
16
17
18 MAKE_SCHEME_CALLBACK (Grid_line_interface, print, 1);
19 SCM
20 Grid_line_interface::print (SCM smobbed_me)
21 {
22   Grob *me = unsmob_grob (smobbed_me);
23   SCM first_elt = me->get_property ("elements");
24
25   /* compute common refpoint of elements */
26   Grob *refp = common_refpoint_of_list (first_elt, me, Y_AXIS);
27   Interval iv;
28   
29   for (SCM elts = first_elt; scm_is_pair (elts); elts = scm_cdr (elts))
30     {
31       Grob *point = unsmob_grob (scm_car (elts));
32
33       iv.unite (point->extent (refp, Y_AXIS));
34     }
35
36   if (iv.is_empty ())
37     {
38       me->suicide ();
39       return SCM_EOL;
40     }
41
42   Real staffline = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
43   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
44     * staffline;
45
46
47   iv += - me->relative_coordinate (refp, Y_AXIS);
48   Stencil st = Lookup::filled_box (Box (Interval (0, thick),
49                                         iv));
50
51   return st.smobbed_copy ();
52 }
53
54 void
55 Grid_line_interface::add_grid_point (Grob *me, Grob *b)
56 {
57   Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
58   me->add_dependency (b);
59 }
60
61 ADD_INTERFACE (Grid_line_interface, "grid-line-interface",
62                "A  line that spanned between grid-points. ",
63                "elements thickness");
64