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>
11 #include "horizontal-bracket.hh"
13 #include "axis-group-interface.hh"
14 #include "pointer-group-interface.hh"
16 struct Enclosing_bracket
18 DECLARE_GROB_INTERFACE ();
21 DECLARE_SCHEME_CALLBACK (print, (SCM));
22 DECLARE_SCHEME_CALLBACK (width, (SCM));
26 ADD_INTERFACE (Enclosing_bracket,
28 "Brackets alongside bass figures.",
39 /* ugh: should make bracket interface. */
42 MAKE_SCHEME_CALLBACK (Enclosing_bracket, width, 1);
44 Enclosing_bracket::width (SCM grob)
47 UGH. cut & paste code.
49 Grob *me = unsmob_grob (grob);
50 extract_grob_set (me, "elements", elements);
51 if (elements.empty ())
57 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
58 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
60 Stencil left_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
61 Stencil right_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
64 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
65 left_br.translate_axis (xext[LEFT], X_AXIS);
66 right_br.translate_axis (xext[RIGHT], X_AXIS);
68 left_br.add_stencil (right_br);
69 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
71 return ly_interval2scm (left_br.extent (X_AXIS));
74 MAKE_SCHEME_CALLBACK (Enclosing_bracket, print, 1);
76 Enclosing_bracket::print (SCM grob)
78 Grob *me = unsmob_grob (grob);
79 extract_grob_set (me, "elements", elements);
80 if (elements.empty ())
86 Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS);
87 Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
90 me->programming_error ("elements have no X extent.");
91 xext = Interval (0, 0);
94 Stencil left_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
96 Stencil right_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
99 xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
100 left_br.translate_axis (xext[LEFT], X_AXIS);
101 right_br.translate_axis (xext[RIGHT], X_AXIS);
103 left_br.add_stencil (right_br);
104 left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
106 return left_br.smobbed_copy ();