]> git.donarmstrong.com Git - lilypond.git/blob - lily/measure-grouping-spanner.cc
Run `make grand-replace'.
[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--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "measure-grouping-spanner.hh"
10
11 #include "output-def.hh"
12 #include "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   SCM which = me->get_property ("style");
24   Real height = robust_scm2double (me->get_property ("height"), 1);
25
26   Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1);
27   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
28                                                         X_AXIS);
29
30   Real right_point = robust_relative_extent (me->get_bound (RIGHT),
31                                              common, X_AXIS).linear_combination (CENTER);
32   Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
33
34   Interval iv (left_point, right_point);
35   Stencil m;
36
37   /*
38     TODO: use line interface
39   */
40   if (which == ly_symbol2scm ("bracket"))
41     m = Lookup::bracket (X_AXIS, iv, t, -height, t);
42   else if (which == ly_symbol2scm ("triangle"))
43     m = Lookup::triangle (iv, t, height);
44
45   m.align_to (Y_AXIS, DOWN);
46   m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
47   return m.smobbed_copy ();
48 }
49
50 ADD_INTERFACE (Measure_grouping,
51                "This object indicates groups of beats.  Valid choices for"
52                " @code{style} are @code{bracket} and @code{triangle}.",
53
54                /* properties */
55                "thickness "
56                "style "
57                "height "
58                );
59