*** empty log message ***
[lilypond.git] / lily / measure-grouping-spanner.cc
blob62c7c287ab0d3148a40310aca28feab2dcd621f9
1 /*
2 measure-grouping-spanner.cc -- implement Measure_grouping
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "paper-def.hh"
11 #include "spanner.hh"
12 #include "measure-grouping-spanner.hh"
13 #include "lookup.hh"
14 #include "item.hh"
15 #include "staff-symbol-referencer.hh"
17 MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
18 SCM
19 Measure_grouping::print (SCM grob)
21 Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
24 TODO: robustify.
26 SCM which = me->get_property ("style");
27 Real height = robust_scm2double (me->get_property ("height"), 1);
29 Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1);
30 Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
31 X_AXIS);
33 Interval rext = me->get_bound (RIGHT)->extent (common, X_AXIS);
36 Real w =(rext.is_empty ()
37 ? me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)
38 : rext[RIGHT])
39 - me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
41 Interval iv (0,w);
43 Stencil m;
46 TODO: use line interface
48 if (which == ly_symbol2scm ("bracket"))
50 m = Lookup::bracket (X_AXIS, iv, t, -height, t);
52 else if (which == ly_symbol2scm ("triangle"))
54 m = Lookup::triangle (iv, t, height);
57 m.align_to (Y_AXIS, DOWN);
58 return m.smobbed_copy ();
61 ADD_INTERFACE (Measure_grouping,"measure-grouping-interface",
62 "This objectt indicates groups of beats. "
63 "Valid choices for @code{style} are @code{bracket} and @code{triangle}.",
64 "thickness style height");