Compile fix.
[lilypond.git] / lily / enclosing-bracket.cc
blobe16a8e9bbc5c4ef0873c4aba0a58792697f38fe2
1 /*
2 enclosing-bracket.cc -- implement Enclosing_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "stencil.hh"
11 #include "horizontal-bracket.hh"
12 #include "grob.hh"
13 #include "axis-group-interface.hh"
14 #include "pointer-group-interface.hh"
16 struct Enclosing_bracket
18 DECLARE_GROB_INTERFACE ();
20 public:
21 DECLARE_SCHEME_CALLBACK (print, (SCM));
22 DECLARE_SCHEME_CALLBACK (width, (SCM));
26 ADD_INTERFACE (Enclosing_bracket,
27 "Brackets alongside bass figures.",
29 /* properties */
30 "bracket-flare "
31 "edge-height "
32 "elements "
33 "padding "
34 "shorten-pair "
35 "thickness "
38 /* ugh: should make bracket interface. */
41 MAKE_SCHEME_CALLBACK (Enclosing_bracket, width, 1);
42 SCM
43 Enclosing_bracket::width (SCM grob)
46 UGH. cut & paste code.
48 Grob *me = unsmob_grob (grob);
49 extract_grob_set (me, "elements", elements);
50 if (elements.empty ())
52 me->suicide ();
53 return SCM_EOL;
56 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
57 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
59 Stencil left_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
60 Stencil right_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
63 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
64 left_br.translate_axis (xext[LEFT], X_AXIS);
65 right_br.translate_axis (xext[RIGHT], X_AXIS);
67 left_br.add_stencil (right_br);
68 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
70 return ly_interval2scm (left_br.extent (X_AXIS));
73 MAKE_SCHEME_CALLBACK (Enclosing_bracket, print, 1);
74 SCM
75 Enclosing_bracket::print (SCM grob)
77 Grob *me = unsmob_grob (grob);
78 extract_grob_set (me, "elements", elements);
79 if (elements.empty ())
81 me->suicide ();
82 return SCM_EOL;
85 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
86 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
87 if (xext.is_empty ())
89 me->programming_error ("elements have no X extent.");
90 xext = Interval (0, 0);
93 Stencil left_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
94 Y_AXIS, LEFT);
95 Stencil right_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
96 Y_AXIS, RIGHT);
98 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
99 left_br.translate_axis (xext[LEFT], X_AXIS);
100 right_br.translate_axis (xext[RIGHT], X_AXIS);
102 left_br.add_stencil (right_br);
103 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
105 return left_br.smobbed_copy ();