]> git.donarmstrong.com Git - lilypond.git/blob - lily/measure-grouping-spanner.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / measure-grouping-spanner.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2002--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "measure-grouping-spanner.hh"
21
22 #include "output-def.hh"
23 #include "spanner.hh"
24 #include "lookup.hh"
25 #include "item.hh"
26 #include "staff-symbol-referencer.hh"
27
28 MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
29 SCM
30 Measure_grouping::print (SCM grob)
31 {
32   Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (grob));
33
34   SCM which = me->get_property ("style");
35   Real height = robust_scm2double (me->get_property ("height"), 1);
36
37   Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1);
38   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
39                                                         X_AXIS);
40
41   Real right_point = robust_relative_extent (me->get_bound (RIGHT),
42                                              common, X_AXIS).linear_combination (CENTER);
43   Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
44
45   Interval iv (left_point, right_point);
46   Stencil m;
47
48   /*
49     TODO: use line interface
50   */
51   if (which == ly_symbol2scm ("bracket"))
52     m = Lookup::bracket (X_AXIS, iv, t, -height, t);
53   else if (which == ly_symbol2scm ("triangle"))
54     m = Lookup::triangle (iv, t, height);
55
56   m.align_to (Y_AXIS, DOWN);
57   m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
58   return m.smobbed_copy ();
59 }
60
61 ADD_INTERFACE (Measure_grouping,
62                "This object indicates groups of beats.  Valid choices for"
63                " @code{style} are @code{bracket} and @code{triangle}.",
64
65                /* properties */
66                "thickness "
67                "style "
68                "height "
69               );
70