]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
Handle situations that either one of above and below is a valid
[lilypond.git] / lily / beam.cc
index e3135dadfa92609362dccfd467e5f164dde1bde7..627ffac0f0f06b4a934ee98c7bbfb994ed4f3f6d 100644 (file)
@@ -1276,7 +1276,7 @@ Beam::shift_region_to_valid (SCM grob, SCM posns)
               left_y -= dy;
 
               // Translate back to beam as ref point.
-              left_y -= -me->relative_coordinate (common[Y_AXIS], Y_AXIS);
+              left_y -= me->relative_coordinate (common[Y_AXIS], Y_AXIS);
             
               Interval allowed;
               allowed.set_full ();
@@ -1299,13 +1299,24 @@ Beam::shift_region_to_valid (SCM grob, SCM posns)
     {
       // We're good to go. Do nothing.
     }
+  else if (collision_free[DOWN].is_empty() != collision_free[UP].is_empty())
+    {
+      // Only one of them offers is feasible solution. Pick that one.
+      Interval v =
+        (!collision_free[DOWN].is_empty()) ?
+        collision_free[DOWN] : 
+        collision_free[UP];
+
+      beam_left_y = point_in_interval (v, 2.0);
+    }
   else if (!collision_free[DOWN].is_empty ()
-           || !collision_free[UP].is_empty ())
+           && !collision_free[UP].is_empty ())
     {
-      // We have space above or below collisions (or, no collisions at
-      // all).
+      // Above and below are candidates, take the one closest to the
+      // starting solution.
       Interval best =  
-        (collision_free[DOWN].length () > collision_free[UP].length ()) ?
+        (collision_free[DOWN].distance (beam_left_y)
+         < collision_free[UP].distance (beam_left_y)) ?
         collision_free[DOWN] : collision_free[UP];
 
       beam_left_y = point_in_interval (best, 2.0);
@@ -1818,6 +1829,8 @@ ADD_INTERFACE (Beam,
               "break-overshoot "
               "clip-edges "
               "concaveness "
+              "collision-interfaces "
+              "collision-voice-only "
               "covered-grobs "
               "damping "
               "details "