]> git.donarmstrong.com Git - lilypond.git/commitdiff
Revert "pure-rest-collision-callback: Remain on staff lines; issue 2468"
authorDavid Kastrup <dak@gnu.org>
Sat, 21 Apr 2012 20:31:51 +0000 (22:31 +0200)
committerDavid Kastrup <dak@gnu.org>
Sat, 21 Apr 2012 20:31:51 +0000 (22:31 +0200)
This reverts commit f5abf75fb0a62527ea1c6339861aee34b210cc24.

input/regression/dot-column-rest-collision.ly
lily/beam.cc

index f1ddb9a1b6bbafbb60d53ca2fa9a667a2c4a8875..3419f7304fa7f56dc60411c884d1e7381edf6793 100644 (file)
@@ -1,12 +1,10 @@
 \header {
-  texidoc = "Dot columns do not trigger beam slanting too early.
-This input should compile with no programming error message,
-and the dots should be correctly placed on their rests."
+  texidoc = "Dot columns do not trigger beam slanting too early."
 }
 
 \version "2.14.0"
 \paper{ ragged-right=##t }
 <<
-  { e''8 e'' g'' g'' e''8[ r8. e''16 g''8] } \\
-  { e8 r4. c'8[ r8. f'16 e'8] }
+  { e''8 e''8 g'' g''} \\
+  { e8 r4. }
 >>
index d9be082b90d55bbaa1bbdef73ca9924d9dfb85c2..0cfc3e193cba6b3feea911abb09a6f9e5118d6c2 100644 (file)
@@ -1306,39 +1306,36 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
   return scm_from_double (offset + staff_space * shift);
 }
 
-/*
-  Estimate the position of a rest under a beam,
-  as the average position of its neighboring heads.
-*/
 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, pure_rest_collision_callback, 4, 1, "");
 SCM
 Beam::pure_rest_collision_callback (SCM smob,
-                                    SCM prev_offset,
+                                    SCM, /* prev_offset */
                                     SCM, /* start */
                                     SCM /* end */)
 {
-  Real previous = robust_scm2double (prev_offset, 0.0);
+  Real amount = 0.0;
 
   Grob *me = unsmob_grob (smob);
   Grob *stem = unsmob_grob (me->get_object ("stem"));
   if (!stem)
-    return scm_from_double (previous);
+    return scm_from_double (amount);
   Grob *beam = unsmob_grob (stem->get_object ("beam"));
   if (!beam
       || !Beam::normal_stem_count (beam)
       || !is_direction (beam->get_property_data ("direction")))
-    return scm_from_double (previous);
+    return scm_from_double (amount);
 
   Real ss = Staff_symbol_referencer::staff_space (me);
 
   /*
     This gives the extrema of rest positions.
-    Even with noteheads on ledgers, beams typically remain within the staff,
-    and push rests at most one staff-space (2 positions) from the staff.
+    In general, beams are never typeset more than one staff space away
+    from the staff in either direction.
   */
   Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
   Interval rest_max_pos = staff ? Staff_symbol::line_span (staff) : Interval (0.0, 0.0);
-  rest_max_pos.widen (2);
+  rest_max_pos.widen (1);
+  rest_max_pos *= ss / 2;
 
   extract_grob_set (beam, "stems", stems);
   vector<Grob *> my_stems;
@@ -1359,7 +1356,7 @@ Beam::pure_rest_collision_callback (SCM smob,
   Grob *right;
 
   if (idx == (vsize) - 1 || my_stems.size () == 1)
-    return scm_from_double (previous);
+    return scm_from_double (amount);
   else if (idx == 0)
     left = right = my_stems[1];
   else if (idx == my_stems.size () - 1)
@@ -1370,18 +1367,14 @@ Beam::pure_rest_collision_callback (SCM smob,
       right = my_stems[idx + 1];
     }
   Direction beamdir = get_grob_direction (beam);
+  /*
+    Take the position between the two bounding head_positions,
+    then bound it by the minimum and maximum positions outside the staff.
+    4.0 = 2.0 to get out of staff space * 2.0 for the average
+  */
+  amount = min (max ((Stem::head_positions (left)[beamdir] + Stem::head_positions (right)[beamdir]) / 4.0, rest_max_pos[DOWN]), rest_max_pos[UP]);
 
-  /* In stems with several heads, use the one closest to the beam. */
-  Real shift = min (max ( (Stem::head_positions (left)[beamdir]
-                           + Stem::head_positions (right)[beamdir]) / 2.0,
-                          rest_max_pos[DOWN]),
-                    rest_max_pos[UP]
-                   ) * ss / 2.0
-               - previous;
-  /* Always move by a whole number of staff spaces */
-  shift = ceil (fabs (shift / ss)) * ss * sign (shift);
-
-  return scm_from_double (previous + shift);
+  return scm_from_double (amount);
 }
 
 bool