]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/horizontal-bracket.cc
Run `make grand-replace'.
[lilypond.git] / lily / horizontal-bracket.cc
index 10d65316e0d80524b1c2d1d8df43d893177c9506..13eec0c3ff00664bfefd55b2d245700eb61d5ef2 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2002--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "horizontal-bracket.hh"       
@@ -16,6 +16,8 @@
 #include "staff-symbol-referencer.hh"
 #include "tuplet-bracket.hh"
 #include "axis-group-interface.hh"
+#include "spanner.hh"
+#include "item.hh"
 
 
 Stencil
@@ -30,6 +32,7 @@ Horizontal_bracket::make_bracket (Grob *me,
   Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
                                                  Interval (0, 0));
 
+  
   // Make sure that it points in the correct direction:
   scale_drul (&edge_height, Real (-dir));
  
@@ -37,6 +40,22 @@ Horizontal_bracket::make_bracket (Grob *me,
   Offset start;
   start[a] = length;
 
+  Drul_array<bool> connect_to_other =
+    robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
+                        Drul_array<bool> (false, false));
+
+  Direction d = LEFT;
+  do
+    {
+      if (connect_to_other[d])
+       {
+         edge_height[d] = 0.0;
+         flare[d] = 0.0;
+         shorten[d] = 0.0;
+       }
+    }
+  while (flip (&d) != LEFT);
+             
   /*
     ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. 
   */
@@ -47,49 +66,66 @@ Horizontal_bracket::make_bracket (Grob *me,
 
 Stencil
 Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
-                                           Link_array__Grob_ grobs,
+                                           vector<Grob*> grobs,
                                            Axis a, Direction dir)
 {
   Grob *common = common_refpoint_of_array (grobs, refpoint, a);
   Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a);
 
-  Stencil b = make_bracket (me, ext.length(), a, dir);
-  b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
+  if (ext.is_empty ())
+    {
+      me->programming_error ("Can't enclose empty extents with bracket");
+      return Stencil ();
+    }
+  else
+    {
+      Stencil b = make_bracket (me, ext.length (), a, dir);
+      b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
 
-  return b;
+      return b;
+    }
 }
 
-
 /*
   TODO:
 
   Support texts on the brackets?
 */
-
 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
 SCM
 Horizontal_bracket::print (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
+  Spanner *me = unsmob_spanner (smob);
   extract_grob_set (me, "columns", gs);
+
+  vector<Grob*> enclosed = gs;
   if (!gs.size ())
     {
       me->suicide ();
       return SCM_EOL;
     }
 
-  Stencil b = make_enclosing_bracket (me, me, gs, X_AXIS, get_grob_direction (me));
+  Direction d = LEFT;
+  do
+    {
+      Item *b = me->get_bound (d);
+      if (b->break_status_dir ())
+       enclosed.push_back (b);
+    }
+  while (flip (&d) != LEFT);
+  
+  Stencil b = make_enclosing_bracket (me, me, enclosed, X_AXIS, get_grob_direction (me));
   return b.smobbed_copy ();
 }
 
 ADD_INTERFACE (Horizontal_bracket,
-
-              "horizontal-bracket-interface",
               "A horizontal bracket encompassing notes.",
 
-              /* props */                
-              "columns "
+              /* properties */           
               "bracket-flare "
+              "columns "
+              "edge-height "
               "shorten-pair "
-              "edge-height");
+              "connect-to-neighbor "
+              );