]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/enclosing-bracket.cc
* lily/enclosing-bracket.cc (width): new function.
[lilypond.git] / lily / enclosing-bracket.cc
index c1e6f57cf55075e18aa5040a1028af05af1846bc..81a292a2ecbefb208cf0f80d0fbdde609de94964 100644 (file)
@@ -19,25 +19,59 @@ struct Enclosing_bracket
   
 public:
   DECLARE_SCHEME_CALLBACK(print, (SCM));
+  DECLARE_SCHEME_CALLBACK(width, (SCM));
 };
 
 
 ADD_INTERFACE(Enclosing_bracket,
              "enclosing-bracket-interface",
+             
              "Brackets alongside bass figures.",
              
              /* props */
              "bracket-flare "
-             "shorten-pair "
              "edge-height "
+             "elements "
              "padding "
+             "shorten-pair "
              "thickness "
-             "elements "
              );
 
 /* ugh: should make bracket interface. */
 
 
+MAKE_SCHEME_CALLBACK (Enclosing_bracket, width, 1);
+SCM
+Enclosing_bracket::width (SCM grob)
+{
+  /*
+     UGH. cut & paste code.
+  */
+  Grob *me = unsmob_grob (grob);
+  extract_grob_set (me, "elements", elements);
+  if (elements.empty ())
+    {
+      me->suicide ();
+      return SCM_EOL;
+    }
+
+  Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); 
+  Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
+
+  Stencil left_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
+  Stencil right_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT);
+
+
+  xext.widen (robust_scm2double (me->get_property ("padding"), 0.25));
+  left_br.translate_axis (xext[LEFT], X_AXIS);
+  right_br.translate_axis (xext[RIGHT], X_AXIS);
+
+  left_br.add_stencil (right_br);
+  left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS);
+
+  return ly_interval2scm (left_br.extent (X_AXIS));
+}
+
 MAKE_SCHEME_CALLBACK (Enclosing_bracket, print, 1);
 SCM
 Enclosing_bracket::print (SCM grob)