]> git.donarmstrong.com Git - lilypond.git/blob - lily/measure-grouping-spanner.cc
(lilypond_version_re_str): handle
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8  */
9
10 #include "output-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"
16
17 MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
18 SCM 
19 Measure_grouping::print (SCM grob)
20 {
21   Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
22
23   /*
24     TODO: robustify.
25    */
26   SCM which = me->get_property ("style");
27   Real height = robust_scm2double (me->get_property ("height"), 1);
28
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);
32
33   Interval rext = me->get_bound (RIGHT)->extent (common, X_AXIS);
34   Real w =robust_relative_extent (me->get_bound (RIGHT),
35                                   common, X_AXIS).linear_combination (CENTER);
36     - me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
37
38   Interval iv (0,w);
39
40   Stencil m;
41
42   /*
43     TODO: use line interface
44    */
45   if (which == ly_symbol2scm ("bracket"))
46     {
47       m = Lookup::bracket (X_AXIS, iv, t, -height, t);
48     }
49   else if (which == ly_symbol2scm ("triangle"))
50     {
51       m = Lookup::triangle (iv, t, height);
52     }
53
54   m.align_to (Y_AXIS, DOWN);
55   return m.smobbed_copy ();
56 }
57
58 ADD_INTERFACE (Measure_grouping,"measure-grouping-interface",
59                "This objectt indicates groups of beats. "
60                "Valid choices for @code{style} are @code{bracket} and @code{triangle}.",
61                "thickness style height");
62
63