(parse_symbol_list): Bugfix.
[lilypond/patrick.git] / lily / horizontal-bracket.cc
blob57225c49d44d0f9f51a3ca679732455dedf9f4bb
1 /*
2 horizontal-bracket.cc -- implement Horizontal_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "side-position-interface.hh"
10 #include "lookup.hh"
11 #include "pointer-group-interface.hh"
12 #include "directional-element-interface.hh"
13 #include "output-def.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "tuplet-bracket.hh" // ugh.
17 struct Horizontal_bracket
19 DECLARE_SCHEME_CALLBACK (print, (SCM));
20 static bool has_interface (Grob *);
24 TODO:
26 This doesn't look very elegant: should support winged edges.
28 Support texts on the brackets?
30 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
32 SCM
33 Horizontal_bracket::print (SCM smob)
35 Grob *me = unsmob_grob (smob);
36 Spanner *sp = dynamic_cast<Spanner *> (me);
38 extract_grob_set (me, "columns", gs);
39 if (!gs.size ())
41 me->suicide ();
42 return SCM_EOL;
44 Grob *cx = common_refpoint_of_array (gs, me, X_AXIS);
45 cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
46 cx = cx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
48 Interval ext = gs.top ()->extent (cx, X_AXIS);
49 ext.unite (gs[0]->extent (cx, X_AXIS));
51 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
52 Interval (1.0, 1.0));
54 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
55 Interval (0, 0));
57 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
58 Interval (0, 0));
60 // Make sure that it points in the correct direction:
61 Real dir = get_grob_direction (me);
62 scale_drul (&edge_height, -dir);
64 Interval empty;
65 Stencil b
66 = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (ext.length (), 0),
67 edge_height, empty, flare, shorten);
69 b.translate_axis (ext[LEFT] - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
71 return b.smobbed_copy ();
74 ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface",
75 "A horizontal bracket encompassing notes.",
76 "columns bracket-flare shorten-pair edge-height");