Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / grid-line-interface.cc
blobe942cb0a0eeed456f8761e580b145e1999b488ac
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "grid-line-interface.hh"
22 #include "grob.hh"
23 #include "pointer-group-interface.hh"
24 #include "lookup.hh"
25 #include "output-def.hh"
27 MAKE_SCHEME_CALLBACK (Grid_line_interface, print, 1);
28 SCM
29 Grid_line_interface::print (SCM smobbed_me)
31 Grob *me = unsmob_grob (smobbed_me);
33 extract_grob_set (me, "elements", elts);
34 /* compute common refpoint of elements */
35 Grob *refp = common_refpoint_of_array (elts, me, Y_AXIS);
36 Interval iv;
38 for (vsize i = 0; i < elts.size (); i++)
40 Grob *point = elts[i];
42 iv.unite (point->extent (refp, Y_AXIS));
45 if (iv.is_empty ())
47 me->suicide ();
48 return SCM_EOL;
51 Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
52 Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
53 * staffline;
55 iv += -me->relative_coordinate (refp, Y_AXIS);
56 Stencil st = Lookup::filled_box (Box (Interval (0, thick),
57 iv));
59 return st.smobbed_copy ();
62 MAKE_SCHEME_CALLBACK (Grid_line_interface, width, 1);
63 SCM
64 Grid_line_interface::width (SCM smob)
66 Grob *me = unsmob_grob (smob);
68 Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
69 Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
70 * staffline;
72 return ly_interval2scm (Interval (0, thick));
75 void
76 Grid_line_interface::add_grid_point (Grob *me, Grob *b)
78 Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
81 ADD_INTERFACE (Grid_line_interface,
82 "A line that is spanned between grid-points.",
84 /* properties */
85 "elements "
86 "thickness "
89 ADD_INTERFACE (Grid_point_interface,
90 "A spanning point for grid lines.",
92 /* properties */