]> git.donarmstrong.com Git - lilypond.git/commitdiff
Modifies Spanner::spanner_length to better handle line spanners.
authorMike Solomon <mike@apollinemike.com>
Thu, 16 Jun 2011 08:34:48 +0000 (10:34 +0200)
committerMike Solomon <mike@apollinemike.com>
Thu, 16 Jun 2011 08:34:48 +0000 (10:34 +0200)
With this change, the normalized endpoints should be correct for
all spanners with correct bound information.

lily/spanner.cc

index 9fe94ab3acbfa5a9bc1f6bcd93abcca29ed73ae8..30638bfed44d64f7c44743b8a2a465d0b543ee47 100644 (file)
@@ -239,13 +239,28 @@ Spanner::Spanner (Spanner const &s)
 Real
 Spanner::spanner_length () const
 {
-  Real l = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS);
-  Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS);
+  Interval lr;
 
-  if (r < l)
+  Drul_array<SCM> bounds (get_property ("left-bound-info"),
+                          get_property ("right-bound-info"));
+
+  Direction d =  LEFT;
+  do
+    lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"),
+                                             bounds[d], SCM_BOOL_F), -d);
+  while (flip (&d) != LEFT);
+
+  if (lr.is_empty ())
+    {
+      do
+        lr[d] = spanned_drul_[d]->relative_coordinate (0, X_AXIS);
+      while (flip (&d) != LEFT);
+    }
+
+  if (lr.is_empty ())
     programming_error ("spanner with negative length");
 
-  return r - l;
+  return lr.length ();
 }
 
 System *