Add display method for \bendAfter.
[lilypond/mpolesky.git] / lily / horizontal-bracket.cc
blobc0d91d123fb53769d6a102d23fa6461d6dcd9613
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2010 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 "horizontal-bracket.hh"
22 #include "lookup.hh"
23 #include "side-position-interface.hh"
24 #include "pointer-group-interface.hh"
25 #include "directional-element-interface.hh"
26 #include "output-def.hh"
27 #include "staff-symbol-referencer.hh"
28 #include "tuplet-bracket.hh"
29 #include "axis-group-interface.hh"
30 #include "spanner.hh"
31 #include "item.hh"
34 Stencil
35 Horizontal_bracket::make_bracket (Grob *me,
36 Real length,
37 Axis a, Direction dir)
39 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
40 Interval (1.0, 1.0));
41 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
42 Interval (0, 0));
43 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
44 Interval (0, 0));
47 // Make sure that it points in the correct direction:
48 scale_drul (&edge_height, Real (-dir));
50 Interval empty;
51 Offset start;
52 start[a] = length;
54 Drul_array<bool> connect_to_other =
55 robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
56 Drul_array<bool> (false, false));
58 Direction d = LEFT;
61 if (connect_to_other[d])
63 edge_height[d] = 0.0;
64 flare[d] = 0.0;
65 shorten[d] = 0.0;
68 while (flip (&d) != LEFT);
71 ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around.
73 return Tuplet_bracket::make_bracket (me, other_axis (a), start,
74 edge_height, empty, flare, shorten);
78 Stencil
79 Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
80 vector<Grob*> grobs,
81 Axis a, Direction dir)
83 Grob *common = common_refpoint_of_array (grobs, refpoint, a);
84 Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a);
86 if (ext.is_empty ())
88 me->programming_error ("Can't enclose empty extents with bracket");
89 return Stencil ();
91 else
93 Stencil b = make_bracket (me, ext.length (), a, dir);
94 b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
96 return b;
101 TODO:
103 Support texts on the brackets?
105 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
107 Horizontal_bracket::print (SCM smob)
109 Spanner *me = unsmob_spanner (smob);
110 extract_grob_set (me, "columns", gs);
112 vector<Grob*> enclosed = gs;
113 if (!gs.size ())
115 me->suicide ();
116 return SCM_EOL;
119 Direction d = LEFT;
122 Item *b = me->get_bound (d);
123 if (b->break_status_dir ())
124 enclosed.push_back (b);
126 while (flip (&d) != LEFT);
128 Stencil b = make_enclosing_bracket (me, me, enclosed, X_AXIS, get_grob_direction (me));
129 return b.smobbed_copy ();
132 ADD_INTERFACE (Horizontal_bracket,
133 "A horizontal bracket encompassing notes.",
135 /* properties */
136 "bracket-flare "
137 "columns "
138 "edge-height "
139 "shorten-pair "
140 "connect-to-neighbor "