]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/horizontal-bracket.cc
*** empty log message ***
[lilypond.git] / lily / horizontal-bracket.cc
index 8c206bb7292a06e518414eb6a7890db688dab1df..80baa95de5742306d454fdbee80c4eef0e179160 100644 (file)
@@ -1,39 +1,28 @@
 /*
-  horizontal-bracket.cc -- implement  Horizontal_bracket
+  horizontal-bracket.cc -- implement Horizontal_bracket
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
-#include "side-position-interface.hh"
+#include "horizontal-bracket.hh"       
+
 #include "lookup.hh"
+#include "side-position-interface.hh"
 #include "pointer-group-interface.hh"
 #include "directional-element-interface.hh"
 #include "output-def.hh"
 #include "staff-symbol-referencer.hh"
-#include "tuplet-bracket.hh"   // ugh.
-#include "horizontal-bracket.hh"       // ugh.
+#include "tuplet-bracket.hh"
+#include "axis-group-interface.hh"
 
-/*
-  TODO:
-
-  This doesn't look very elegant: should support winged edges.
-
-  Support texts on the brackets?
-*/
 
 Stencil
-Horizontal_bracket::make_bracket (Grob *me, Grob *common,
-                                 Link_array<Grob> grobs, Axis a, Direction dir)
+Horizontal_bracket::make_bracket (Grob *me,
+                                 Real length,
+                                 Axis a, Direction dir)                                 
 {
-  Axis other = other_axis (a);
-  
-  Grob *cx = common_refpoint_of_array (grobs, common, a);
-
-  Interval ext = grobs.top ()->extent (cx, a);
-  ext.unite (grobs[0]->extent (cx, a));
-
   Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
                                                      Interval (1.0, 1.0));
   Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
@@ -43,26 +32,45 @@ Horizontal_bracket::make_bracket (Grob *me, Grob *common,
 
   // Make sure that it points in the correct direction:
   scale_drul (&edge_height, Real (-dir));
-
   Interval empty;
   Offset start;
-  start[a] = ext.length ();
-  Stencil b
-    = Tuplet_bracket::make_bracket (me, other, start, 
-                                   edge_height, empty, flare, shorten);
+  start[a] = length;
+
+  /*
+    ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. 
+  */
+  return Tuplet_bracket::make_bracket (me, other_axis (a), start, 
+                                      edge_height, empty, flare, shorten);
+}
 
-  b.translate_axis (ext[LEFT], a);
+
+Stencil
+Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
+                                           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);
 
   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 *sp = dynamic_cast<Spanner *> (me);
-
   extract_grob_set (me, "columns", gs);
   if (!gs.size ())
     {
@@ -70,22 +78,19 @@ Horizontal_bracket::print (SCM smob)
       return SCM_EOL;
     }
 
-  Grob *cx = me->common_refpoint (sp->get_bound (LEFT), X_AXIS);
-  cx = cx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
-
-  Stencil b = make_bracket (me, cx, gs, X_AXIS, get_grob_direction (me));
-  b.translate_axis (- sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
-
+  Stencil b = make_enclosing_bracket (me, me, gs, X_AXIS, get_grob_direction (me));
   return b.smobbed_copy ();
 }
 
-ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface",
+ADD_INTERFACE (Horizontal_bracket,
+
+              "horizontal-bracket-interface",
               "A horizontal bracket encompassing notes.",
 
               /* props */                
-              "columns "
               "bracket-flare "
+              "columns "
+              "edge-height "
               "shorten-pair "
-              "edge-height");
+              );