Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / measure-grouping-spanner.cc
blobdb6b4fced215a32f682251c42d14c0590424df9e
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "measure-grouping-spanner.hh"
22 #include "output-def.hh"
23 #include "spanner.hh"
24 #include "lookup.hh"
25 #include "item.hh"
26 #include "staff-symbol-referencer.hh"
28 MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
29 SCM
30 Measure_grouping::print (SCM grob)
32 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (grob));
34 SCM which = me->get_property ("style");
35 Real height = robust_scm2double (me->get_property ("height"), 1);
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);
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);
45 Interval iv (left_point, right_point);
46 Stencil m;
49 TODO: use line interface
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);
56 m.align_to (Y_AXIS, DOWN);
57 m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
58 return m.smobbed_copy ();
61 ADD_INTERFACE (Measure_grouping,
62 "This object indicates groups of beats. Valid choices for"
63 " @code{style} are @code{bracket} and @code{triangle}.",
65 /* properties */
66 "thickness "
67 "style "
68 "height "