]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/align-interface.cc
Run `make grand-replace'.
[lilypond.git] / lily / align-interface.cc
index 4d885b7a38de0896773058fb10582b137315e13d..7f7b9c3cf645a9eb8df727129309f1039a29335d 100644 (file)
@@ -3,20 +3,21 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2000--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "align-interface.hh"
-#include "spanner.hh"
-#include "item.hh"
 #include "axis-group-interface.hh"
-#include "pointer-group-interface.hh"
-#include "hara-kiri-group-spanner.hh"
 #include "grob-array.hh"
+#include "hara-kiri-group-spanner.hh"
 #include "international.hh"
+#include "item.hh"
+#include "paper-column.hh"
+#include "pointer-group-interface.hh"
+#include "spanner.hh"
+#include "skyline-pair.hh"
 #include "system.hh"
 #include "warn.hh"
-#include "paper-column.hh"
 
 /*
   TODO: for vertical spacing, should also include a rod & spring
@@ -90,37 +91,13 @@ get_skylines (Grob *me,
              bool pure, int start, int end,
              vector<Skyline_pair> *const ret)
 {
-  /* each child's skyline was calculated according to the common refpoint of its
-     elements. Here we need all the skylines to be positioned with respect to
-     a single refpoint, so we need the common refpoint of the common refpoints
-     of the elements of the children */
-  vector<Grob*> child_refpoints;
-  for (vsize i = 0; i < elements->size (); i++)
-    {
-      Grob *elt = (*elements)[i];
-      Grob *child_common = unsmob_grob ((a == Y_AXIS)
-                                       ? elt->get_object ("X-common")
-                                       : elt->get_object ("Y-common"));
-      
-      if (!child_common)
-       {
-         extract_grob_set (elt, "elements", child_elts);
-         child_common = common_refpoint_of_array (child_elts, elt, other_axis (a));
-       }
-      
-      child_refpoints.push_back (child_common);
-    }
-
-  Grob *other_common = common_refpoint_of_array (child_refpoints, me, other_axis (a));
+  Grob *other_common = common_refpoint_of_array (*elements, me, other_axis (a));
   
   for (vsize i = elements->size (); i--;)
     {
       Grob *g = (*elements)[i];
       Skyline_pair skylines;
 
-      /* each skyline is calculated relative to (potentially) a different other_axis
-        coordinate. In order to compare the skylines effectively, we need to shift them
-        to some absolute reference point */
       if (!pure)
        {
          Skyline_pair *skys = Skyline_pair::unsmob (g->get_property (a == Y_AXIS
@@ -146,7 +123,10 @@ get_skylines (Grob *me,
                skylines.insert (b, 0, other_axis (a));
            }
 
-         Real offset = child_refpoints[i]->relative_coordinate (other_common, other_axis (a));
+         /* This skyline was calculated relative to the grob g. In order to compare it to
+            skylines belonging to other grobs, we need to shift it so that it is relative
+            to the common reference. */
+         Real offset = g->relative_coordinate (other_common, other_axis (a));
          skylines.shift (offset);
        }
       else
@@ -221,6 +201,9 @@ Align_interface::get_extents_aligned_translates (Grob *me,
          dy = down_skyline.distance (skylines[j][-stacking_dir]);
        }
 
+      if (isinf (dy)) /* if the skyline is empty, maybe max_height is infinity_f */
+       dy = 0.0;
+
       dy = max (0.0, dy + padding + extra_space / elems.size ());
       down_skyline.raise (-stacking_dir * dy);
       where += stacking_dir * dy;
@@ -396,18 +379,16 @@ Align_interface::calc_max_stretch (SCM smob)
 }
 
 ADD_INTERFACE (Align_interface,
+              "Order grobs from top to bottom, left to right, right to left"
+              " or bottom to top.  For vertical alignments of staves, the"
+              " @code{break-system-details} of the left"
+              " @rinternals{NonMusicalPaperColumn} may be set to tune"
+              " vertical spacing.  Set @code{alignment-extra-space} to add"
+              " extra space for staves.  Set"
+              " @code{fixed-alignment-extra-space} to force staves in"
+              " @code{PianoStaff}s further apart.",
               
-              "Order grobs from top to bottom, left to right, right to left or bottom "
-              "to top.  "
-              "For vertical alignments of staves, the @code{break-system-details} of "
-              "the left @internalsref{NonMusicalPaperColumn} may be set to tune vertical spacing "
-              "Set @code{alignment-extra-space} to add extra space for staves. Set "
-              "@code{fixed-alignment-extra-space} to force staves in PianoStaves further apart."
-              ,
-              
-              /*
-                properties
-               */
+              /* properties */
               "align-dir "
               "axes "
               "elements "