]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/align-interface.cc
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / align-interface.cc
index 2f23220c5a1bfe518f3b5998b8c063101eb54835..07c9ebe3c91c0f0388779c766caee2eb7b34adea 100644 (file)
@@ -60,7 +60,7 @@ Align_interface::stretch_after_break (SCM grob)
       for (vsize i = 0; i < elems.size (); i++)
        elems[i]->relative_coordinate (common, Y_AXIS);
 
-      SCM details =  me_spanner->get_bound (LEFT)->get_property ("line-break-system-details");
+      SCM details = me_spanner->get_bound (LEFT)->get_property ("line-break-system-details");
       SCM extra_space_handle = scm_assoc (ly_symbol2scm ("fixed-alignment-extra-space"), details);
       
       Real extra_space = robust_scm2double (scm_is_pair (extra_space_handle)
@@ -138,15 +138,29 @@ get_skylines (Grob *me,
              bool pure, int start, int end,
              vector<Skyline_pair> *const ret)
 {
-  Grob *other_axis_common = common_refpoint_of_array (*elements, me, other_axis (a));
+  /* 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++)
+    {
+      extract_grob_set ((*elements)[i], "elements", child_elts);
+      Grob *child_common = common_refpoint_of_array (child_elts, (*elements)[i], other_axis (a));
+      child_refpoints.push_back (child_common);
+    }
+  Grob *common_refpoint = common_refpoint_of_array (child_refpoints, me, other_axis (a));
+  
   for (vsize i = elements->size (); i--;)
     {
       Grob *g = (*elements)[i];
       Interval extent = g->maybe_pure_extent (g, a, pure, start, end);
       Interval other_extent = pure ? Interval (-infinity_f, infinity_f)
-       : g->extent (other_axis_common, other_axis (a));
-      Box b = (a == X_AXIS) ? Box (extent, other_extent) : Box (other_extent, extent);
-      
+       : g->extent (common_refpoint, other_axis (a));
+      Box b;
+      b[a] = extent;
+      b[other_axis (a)] = other_extent;
+
       if (extent.is_empty ())
        {
          elements->erase (elements->begin () + i);
@@ -179,8 +193,9 @@ get_skylines (Grob *me,
              b[a] = ly_scm2interval (min_extent);
              skylines.insert (b, 0, other_axis (a));
            }
-         Real offset = g->relative_coordinate (other_axis_common, other_axis (a));
-         skylines.shift (-offset);
+
+         Real offset = child_refpoints[i]->relative_coordinate (common_refpoint, other_axis (a));
+         skylines.shift (offset);
        }
 
 
@@ -234,7 +249,7 @@ Align_interface::get_extents_aligned_translates (Grob *me,
       else
        dy = skylines[j-1][stacking_dir].distance (skylines[j][-stacking_dir]);
 
-      where += stacking_dir * (dy + padding + extra_space / elems.size ());
+      where += stacking_dir * max (0.0, dy + padding + extra_space / elems.size ());
       translates.push_back (where);
     }
 
@@ -274,8 +289,8 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a)
 
   vector<Real> translates = get_extents_aligned_translates (me, all_grobs, a, false, 0, 0);
   if (translates.size ())
-      for (vsize j = 0; j < all_grobs.size (); j++)
-       all_grobs[j]->translate_axis (translates[j], a);
+    for (vsize j = 0; j < all_grobs.size (); j++)
+      all_grobs[j]->translate_axis (translates[j], a);
 }
 
 Real
@@ -311,7 +326,7 @@ Align_interface::get_pure_child_y_translation (Grob *me, Grob *ch, int start, in
        return 0;
     }
 
-  programming_error (_ ("tried to get a translation for something that isn't my child"));
+  programming_error (_ ("tried to get a translation for something that is no child of mine"));
   return 0;
 }