]> git.donarmstrong.com Git - lilypond.git/commitdiff
Vertical spacing, distinguish stretchability/compressibility
authorKeith OHara <k-ohara5a5a@oco.net>
Sun, 29 May 2011 06:38:34 +0000 (23:38 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Sat, 18 Jun 2011 03:18:45 +0000 (20:18 -0700)
When stretchability is changed,
leave inverse_compression_strength alone.

input/regression/page-breaking-min-distance2.ly
lily/align-interface.cc
lily/page-layout-problem.cc
lily/simple-spacer.cc
lily/spring.cc

index 90224e395710f2d17d4644624cfbc7c775c990e4..94e93ea1c268362d751cc1d67ba4c22dbf1b2809 100644 (file)
@@ -8,8 +8,7 @@
   \context {
     \Score
     \override VerticalAxisGroup #'staff-staff-spacing =
-      #'((basic-distance . 20)
-         (stretchability . 0))
+      #'((minimum-distance . 20))
   }
 }
 
index 2fd49f5162a2547c57606d76a5ddd4d0386e5cfd..403f903e490ccea3d811be8b1f99f6b0c341b960 100644 (file)
@@ -226,9 +226,6 @@ Align_interface::internal_get_minimum_translations (Grob *me,
          if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance")))
            dy = max (dy, min_distance);
 
-         if (include_fixed_spacing)
-           dy = max (dy, Page_layout_problem::get_fixed_spacing (elems[j-1], elems[j], spaceable_count, pure, start, end));
-
          if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element)
            {
              // Spaceable staves may have
index 9ee2b3fea11b9ae3a22ef74ebb140515b9224fd4..07c99586ee29c4715d21f1db56ad89255b9dfbc1 100644 (file)
@@ -775,12 +775,7 @@ Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable
        return robust_scm2double (cached, 0.0);
     }
 
-  SCM spec = Page_layout_problem::get_spacing_spec (before, after, pure, start, end);
   Real ret = -infinity_f;
-  Real stretchability = 0;
-  if (Page_layout_problem::read_spacing_spec (spec, &stretchability, ly_symbol2scm ("stretchability"))
-      && stretchability == 0)
-    Page_layout_problem::read_spacing_spec (spec, &ret, ly_symbol2scm ("basic-distance"));
 
   // If we're pure, then paper-columns have not had their systems set,
   // and so elts[i]->get_system () is unreliable.
@@ -894,10 +889,7 @@ Page_layout_problem::alter_spring_from_spacing_spec (SCM spec, Spring* spring)
   spring->set_default_strength ();
 
   if (read_spacing_spec (spec, &stretch, ly_symbol2scm ("stretchability")))
-    {
-      spring->set_inverse_stretch_strength (stretch);
-      spring->set_inverse_compress_strength (stretch);
-    }
+    spring->set_inverse_stretch_strength (stretch);
 }
 
 vector<Grob*>
index 14c7cbeebd113007989867aa65355a4b4c15320f..4376b0133c2d47942884acb8cce9686311ff8db3 100644 (file)
@@ -196,7 +196,6 @@ Simple_spacer::expand_line ()
 Real
 Simple_spacer::compress_line ()
 {
-  double inv_hooke = 0;
   double cur_len = configuration_length (force_);
   double cur_force = force_;
   bool compressed = false;
@@ -213,23 +212,24 @@ Simple_spacer::compress_line ()
     }
 
   fits_ = true;
-  for (vsize i=0; i < springs_.size (); i++)
-    inv_hooke += compressed
-      ? springs_[i].inverse_compress_strength ()
-      : springs_[i].inverse_stretch_strength ();
 
   assert (line_len_ <= cur_len);
 
   vector<Spring> sorted_springs = springs_;
   sort (sorted_springs.begin (), sorted_springs.end (), greater<Spring> ());
 
-  for (vsize i = 0; i < sorted_springs.size (); i++)
+  /* inv_hooke is the total flexibility of currently-active springs */
+  double inv_hooke = 0;
+  vsize i = sorted_springs.size ();
+  for ( ; i && sorted_springs[i - 1].blocking_force () < cur_force; i--)
+    inv_hooke += compressed
+      ? sorted_springs[i - 1].inverse_compress_strength ()
+      : sorted_springs[i - 1].inverse_stretch_strength ();
+  /* i now indexes the first active spring, so */
+  for ( ; i < sorted_springs.size (); i++)
     {
       Spring sp = sorted_springs[i];
 
-      if (sp.blocking_force () > cur_force)
-       continue;
-
       if (isinf (sp.blocking_force ()))
        break;
 
index 60bc0aec77ca736084ed1afd18430b6a4bc0d9ea..c576da374329bf22b196982c3276343587b56fbb 100644 (file)
@@ -45,20 +45,23 @@ Spring::Spring (Real dist, Real min_dist)
 void
 Spring::update_blocking_force ()
 {
+  // blocking_force_ is the value of force
+  //   below which length(force) is constant, and
+  //   above which length(force) varies according to inverse_*_strength.
+  // Simple_spacer::compress_line() depends on the condition above.
+  // We assume inverse_*_strength are non-negative.
   if (min_distance_ > distance_)
-    blocking_force_ = (min_distance_ - distance_) / inverse_stretch_strength_;
+    if (inverse_stretch_strength_ > 0.0)
+      blocking_force_ = (min_distance_ - distance_) / inverse_stretch_strength_;
+    else
+      // Conceptually, this should be +inf, but 0.0 meets the requirements
+      //  of Simple_spacer and creates fewer cases of 0.0*inf to handle.
+      blocking_force_ = 0.0;
   else
-    blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_;
-
-  // If the spring is fixed, it's not clear what the natural value
-  // of blocking_force_ would be (because it always blocks).
-  // -infinity_f works fine for now.
-  // If inverse_stretch_strength > 0, the spring is not fixed (because it can stretch).
-  if (isnan (blocking_force_) || blocking_force_ == infinity_f)
-    blocking_force_ = (inverse_stretch_strength_ > 0) ? 0.0 : -infinity_f;
-
-  if (blocking_force_ >= 0)
-    inverse_compress_strength_ = 0;
+    if (inverse_compress_strength_ > 0.0)
+      blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_;
+    else
+      blocking_force_ = 0.0;
 }
 
 /* scale a spring, but in a way that doesn't violate min_distance */
@@ -200,7 +203,7 @@ Spring::length (Real f) const
   Real force = max (f, blocking_force_);
   Real inv_k = force < 0.0 ? inverse_compress_strength_ : inverse_stretch_strength_;
 
-  if (force == infinity_f)
+  if (isinf(force))
     {
       programming_error ("cruelty to springs");
       force = 0.0;