]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spanner.cc
remove guile 1.6 compat code.
[lilypond.git] / lily / spanner.cc
index 0f020202419c494b6bf2db2a639f65c7173d28d2..09359644b98096c28c58c06e7aad9b0ed85ff93a 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1996--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "pointer-group-interface.hh"
@@ -334,16 +334,33 @@ SCM
 Spanner::set_spacing_rods (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-
-  Rod r;
-  Spanner *sp = dynamic_cast<Spanner *> (me);
-  r.item_drul_[LEFT] = sp->get_bound (LEFT);
-  r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
-
   SCM num_length = me->get_property ("minimum-length");
   if (scm_is_number (num_length))
     {
+      Rod r;
+      Spanner *sp = dynamic_cast<Spanner *> (me);
+      
+
+      System *root = get_root_system (me);
+      vector<Item*> cols (root->broken_col_range (sp->get_bound (LEFT)->get_column (),
+                                                 sp->get_bound (RIGHT)->get_column ()));
+
+      if (cols.size ())
+       {
+         Rod r ;
+         r.item_drul_[LEFT] = sp->get_bound (LEFT);
+         r.item_drul_[RIGHT] = cols[0]->find_prebroken_piece (LEFT);
+         r.distance_ = robust_scm2double (num_length, 0);
+         r.add_to_cols ();
+         
+         r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT);
+         r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
+         r.add_to_cols ();
+       }
+          
       r.distance_ = robust_scm2double (num_length, 0);
+      r.item_drul_[LEFT] = sp->get_bound (LEFT);
+      r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
       r.add_to_cols ();
     }
   
@@ -367,11 +384,30 @@ unsmob_spanner (SCM s)
   return dynamic_cast<Spanner *> (unsmob_grob (s));
 }
 
+MAKE_SCHEME_CALLBACK(Spanner, bounds_width, 1);
+SCM
+Spanner::bounds_width (SCM grob)
+{
+  Spanner *me = unsmob_spanner (grob);
+
+
+  Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
+
+  Interval w (me->get_bound (LEFT)->relative_coordinate (common, X_AXIS),
+             me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS));
+             
+  w -= me->relative_coordinate (common, X_AXIS);
+
+  return ly_interval2scm (w);
+}
+
 ADD_INTERFACE (Spanner,
               "Some objects are horizontally spanned between objects. For\n"
               "example, slur, beam, tie, etc. These grobs form a subtype called\n"
               "@code{Spanner}. All spanners have two span-points (these must be\n"
               "@code{Item} objects), one on the left and one on the right. The left bound is\n"
               "also the X-reference point of the spanner.\n",
-              "minimum-length");
+
+              "minimum-length "
+              );