]> git.donarmstrong.com Git - lilypond.git/blob - lily/measure-grouping-spanner.cc
* scm/music-functions.scm (has-request-chord): don't use
[lilypond.git] / lily / measure-grouping-spanner.cc
1 /*   
2         measure-grouping-spanner.cc --  implement Measure_grouping
3
4         source file of the GNU LilyPond music typesetter
5
6         (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8  */
9
10 #include "measure-grouping-spanner.hh"
11
12 #include "output-def.hh"
13 #include "spanner.hh"
14 #include "lookup.hh" 
15 #include "item.hh"
16 #include "staff-symbol-referencer.hh"
17
18 MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
19 SCM 
20 Measure_grouping::print (SCM grob)
21 {
22   Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
23
24   SCM which = me->get_property ("style");
25   Real height = robust_scm2double (me->get_property ("height"), 1);
26
27   Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1);
28   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
29                                                        X_AXIS);
30
31   Real right_point = robust_relative_extent (me->get_bound (RIGHT),
32                                              common, X_AXIS).linear_combination (CENTER);
33   Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
34
35
36   
37   Interval iv (left_point, right_point);
38   Stencil m;
39   
40   /*
41     TODO: use line interface
42    */
43   if (which == ly_symbol2scm ("bracket"))
44     {
45       m = Lookup::bracket (X_AXIS, iv, t, -height, t);
46     }
47   else if (which == ly_symbol2scm ("triangle"))
48     {
49       m = Lookup::triangle (iv, t, height);
50     }
51
52   m.align_to (Y_AXIS, DOWN);
53   m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
54   return m.smobbed_copy ();
55 }
56
57 ADD_INTERFACE (Measure_grouping, "measure-grouping-interface",
58                "This object indicates groups of beats. "
59                "Valid choices for @code{style} are @code{bracket} and @code{triangle}.",
60                "thickness style height");
61
62