Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / grid-line-interface.cc
blobfd47291580c2fef8f2569b1eed32763ee79706d6
1 /*
2 grid-line-interface.cc -- implement Grid_line_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "grid-line-interface.hh"
11 #include "grob.hh"
12 #include "pointer-group-interface.hh"
13 #include "lookup.hh"
14 #include "output-def.hh"
16 MAKE_SCHEME_CALLBACK (Grid_line_interface, print, 1);
17 SCM
18 Grid_line_interface::print (SCM smobbed_me)
20 Grob *me = unsmob_grob (smobbed_me);
22 extract_grob_set (me, "elements", elts);
23 /* compute common refpoint of elements */
24 Grob *refp = common_refpoint_of_array (elts, me, Y_AXIS);
25 Interval iv;
27 for (vsize i = 0; i < elts.size (); i++)
29 Grob *point = elts[i];
31 iv.unite (point->extent (refp, Y_AXIS));
34 if (iv.is_empty ())
36 me->suicide ();
37 return SCM_EOL;
40 Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
41 Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
42 * staffline;
44 iv += -me->relative_coordinate (refp, Y_AXIS);
45 Stencil st = Lookup::filled_box (Box (Interval (0, thick),
46 iv));
48 return st.smobbed_copy ();
51 MAKE_SCHEME_CALLBACK (Grid_line_interface, width, 1);
52 SCM
53 Grid_line_interface::width (SCM smob)
55 Grob *me = unsmob_grob (smob);
57 Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
58 Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
59 * staffline;
61 return ly_interval2scm (Interval (0, thick));
64 void
65 Grid_line_interface::add_grid_point (Grob *me, Grob *b)
67 Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
70 ADD_INTERFACE (Grid_line_interface,
71 "A line that is spanned between grid-points.",
73 /* properties */
74 "elements "
75 "thickness "
78 ADD_INTERFACE (Grid_point_interface,
79 "A spanning point for grid lines.",
81 /* properties */