Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / enclosing-bracket.cc
blobd7cd67284377ac23f607e4578296cb326441badc
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "stencil.hh"
22 #include "horizontal-bracket.hh"
23 #include "grob.hh"
24 #include "axis-group-interface.hh"
25 #include "pointer-group-interface.hh"
27 struct Enclosing_bracket
29 DECLARE_GROB_INTERFACE ();
31 public:
32 DECLARE_SCHEME_CALLBACK (print, (SCM));
33 DECLARE_SCHEME_CALLBACK (width, (SCM));
37 ADD_INTERFACE (Enclosing_bracket,
38 "Brackets alongside bass figures.",
40 /* properties */
41 "bracket-flare "
42 "edge-height "
43 "elements "
44 "padding "
45 "shorten-pair "
46 "thickness "
49 /* ugh: should make bracket interface. */
52 MAKE_SCHEME_CALLBACK (Enclosing_bracket, width, 1);
53 SCM
54 Enclosing_bracket::width (SCM grob)
57 UGH. cut & paste code.
59 Grob *me = unsmob_grob (grob);
60 extract_grob_set (me, "elements", elements);
61 if (elements.empty ())
63 me->suicide ();
64 return SCM_EOL;
67 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
68 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
70 Stencil left_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
71 Stencil right_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
74 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
75 left_br.translate_axis (xext[LEFT], X_AXIS);
76 right_br.translate_axis (xext[RIGHT], X_AXIS);
78 left_br.add_stencil (right_br);
79 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
81 return ly_interval2scm (left_br.extent (X_AXIS));
84 MAKE_SCHEME_CALLBACK (Enclosing_bracket, print, 1);
85 SCM
86 Enclosing_bracket::print (SCM grob)
88 Grob *me = unsmob_grob (grob);
89 extract_grob_set (me, "elements", elements);
90 if (elements.empty ())
92 me->suicide ();
93 return SCM_EOL;
96 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
97 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
98 if (xext.is_empty ())
100 me->programming_error ("elements have no X extent.");
101 xext = Interval (0, 0);
104 Stencil left_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
105 Y_AXIS, LEFT);
106 Stencil right_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
107 Y_AXIS, RIGHT);
109 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
110 left_br.translate_axis (xext[LEFT], X_AXIS);
111 right_br.translate_axis (xext[RIGHT], X_AXIS);
113 left_br.add_stencil (right_br);
114 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
116 return left_br.smobbed_copy ();