]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/align-interface.cc
Doc: Color the Attic link (issue 3596).
[lilypond.git] / lily / align-interface.cc
index 00ea0029e31717f0767efdb6c260f6ac799850d5..8a2a8d9b819a4469f2b60c73f75f1d0899963d91 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2000--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -121,7 +121,7 @@ get_skylines (Grob *me,
                   Box b;
                   b[a] = begin_of_line_extent;
                   b[other_axis (a)] = Interval (-infinity_f, -1);
-                  skylines.insert (b, 0, other_axis (a));
+                  skylines.insert (b, other_axis (a));
                 }
             }
 
@@ -130,7 +130,7 @@ get_skylines (Grob *me,
               Box b;
               b[a] = extent;
               b[other_axis (a)] = Interval (0, infinity_f);
-              skylines.insert (b, 0, other_axis (a));
+              skylines.insert (b, other_axis (a));
             }
         }
 
@@ -167,7 +167,7 @@ Align_interface::get_minimum_translations_without_min_dist (Grob *me,
 }
 
 // If include_fixed_spacing is false, the only constraints that will be measured
-// here are those that result from collisions (+ padding) and minimum-distance
+// here are those that result from collisions (+ padding) and the spacing spec
 // between adjacent staves.
 // If include_fixed_spacing is true, constraints from line-break-system-details,
 // basic-distance+stretchable=0, and staff-staff-spacing of spaceable staves
@@ -185,6 +185,16 @@ Align_interface::internal_get_minimum_translations (Grob *me,
   if (!pure && a == Y_AXIS && dynamic_cast<Spanner *> (me) && !me->get_system ())
     me->programming_error ("vertical alignment called before line-breaking");
 
+  // check the cache
+  if (pure)
+    {
+      SCM fv = ly_assoc_get (scm_cons (scm_from_int (start), scm_from_int (end)),
+                             me->get_property ("minimum-translations-alist"),
+                             SCM_EOL);
+      if (fv != SCM_EOL)
+        return ly_scm2floatvector (fv);
+    }
+
   // If include_fixed_spacing is true, we look at things like system-system-spacing
   // and alignment-distances, which only make sense for the toplevel VerticalAlignment.
   // If we aren't toplevel, we're working on something like BassFigureAlignment
@@ -221,9 +231,13 @@ Align_interface::internal_get_minimum_translations (Grob *me,
 
           dy = down_skyline.distance (skylines[j][-stacking_dir]) + padding;
 
-          Real min_distance = 0;
-          if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance")))
-            dy = max (dy, min_distance);
+          Real spec_distance = 0;
+          if (Page_layout_problem::read_spacing_spec (spec, &spec_distance, ly_symbol2scm ("minimum-distance")))
+            dy = max (dy, spec_distance);
+          // Consider the likely final spacing when estimating distance between staves of the full score
+          if (INT_MAX == end && 0 == start
+              && Page_layout_problem::read_spacing_spec (spec, &spec_distance, ly_symbol2scm ("basic-distance")))
+            dy = max (dy, spec_distance);
 
           if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element)
             {
@@ -281,6 +295,15 @@ Align_interface::internal_get_minimum_translations (Grob *me,
           all_translates.push_back (w);
         }
     }
+
+  if (pure)
+    {
+      SCM mta = me->get_property ("minimum-translations-alist");
+      mta = scm_cons (scm_cons (scm_cons (scm_from_int (start), scm_from_int (end)),
+                                ly_floatvector2scm (all_translates)),
+                      mta);
+      me->set_property ("minimum-translations-alist", mta);
+    }
   return all_translates;
 }
 
@@ -370,6 +393,7 @@ ADD_INTERFACE (Align_interface,
                "align-dir "
                "axes "
                "elements "
+               "minimum-translations-alist "
                "padding "
                "positioning-done "
                "stacking-dir "