]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/page-layout-problem.cc
Fix 1442.
[lilypond.git] / lily / page-layout-problem.cc
index 54624304d540f60b85367e2bdf54be296b415ef3..c1cfeb0656bbdff88e9eb0c2b56cb4ba3e91de55 100644 (file)
@@ -424,8 +424,7 @@ Page_layout_problem::find_system_offsets ()
                      loose_line_min_distances.clear ();
                    }
                  last_spaceable_line = staff;
-                 // Negative is down but the translation is relative to the whole page.
-                 last_spaceable_line_translation = -system_position + translation;
+                 last_spaceable_line_translation = -solution_[spring_idx - 1];
 
                  staff->translate_axis (translation, Y_AXIS);
                  found_spaceable_staff = true;
@@ -436,6 +435,10 @@ Page_layout_problem::find_system_offsets ()
                    loose_lines.push_back (last_spaceable_line);
 
                  if (staff_idx)
+                   // NOTE: the way we do distances between loose lines (and other lines too, actually)
+                   // is not the most accurate way possible: we only insert rods between adjacent
+                   // lines.  To be more accurate, we could insert rods between non-adjacent lines
+                   // using a scheme similar to the one in set_column_rods.
                    loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
                  else
                    {
@@ -658,6 +661,19 @@ Page_layout_problem::read_spacing_spec (SCM spec, Real* dest, SCM sym)
 Real
 Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end)
 {
+  Spanner *after_sp = dynamic_cast<Spanner*> (after);
+  SCM cache_symbol = (is_spaceable (before) && is_spaceable (after))
+    ? ly_symbol2scm ("spaceable-fixed-spacing")
+    : ly_symbol2scm ("loose-fixed-spacing");
+  if (pure)
+    {
+      // The result of this function doesn't depend on "end," so we can reduce the
+      // size of the cache by ignoring it.
+      SCM cached = after_sp->get_cached_pure_property (cache_symbol, start, 0);
+      if (scm_is_number (cached))
+       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;
@@ -681,6 +697,11 @@ Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable
            ret = max (ret, scm_to_double (forced));
        }
     }
+
+  // Cache the result.  As above, we ignore "end."
+  if (pure)
+    after_sp->cache_pure_property (cache_symbol, start, 0, scm_from_double (ret));
+    
   return ret;
 }