]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-interface.cc
Run `make grand-replace'.
[lilypond.git] / lily / spacing-interface.cc
index 8d1e0b036ade24df978d0370e4d31ba72bc993b7..c5a7e000c1cc6199af743260142262b92ff0ad1e 100644 (file)
@@ -4,7 +4,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2007 Joe Neeman <joeneeman@gmail.com>
+  (c) 2007--2008 Joe Neeman <joeneeman@gmail.com>
 */
 
 #include "spacing-interface.hh"
@@ -17,6 +17,7 @@
 #include "paper-column.hh"
 #include "separation-item.hh"
 #include "skyline.hh"
+#include "skyline-pair.hh"
 #include "system.hh"
 
 /* return the right-pointing skyline of the left-items and the left-pointing
@@ -58,11 +59,12 @@ Spacing_interface::skylines (Grob *me, Grob *right_col)
            {
              SCM sky_scm = g->get_property ("horizontal-skylines");
              Skyline_pair *sky = Skyline_pair::unsmob (sky_scm);
-             Real shift = g->pure_relative_y_coordinate (system, 0, INT_MAX);
-             Real raise = g->relative_coordinate (columns[d], X_AXIS);
+
+             extract_grob_set (g, "elements", elts);
+             Grob *ycommon = common_refpoint_of_array (elts, g, Y_AXIS);
+             Real shift = ycommon->pure_relative_y_coordinate (system, 0, INT_MAX);
 
              skylines[d].shift (-shift);
-             skylines[d].raise (-raise);
 
              if (sky)
                skylines[d].merge ((*sky)[-d]);
@@ -73,7 +75,6 @@ Spacing_interface::skylines (Grob *me, Grob *right_col)
                skylines[d].merge (Separation_item::conditional_skyline (items[d][i], items[LEFT][0]));
 
              skylines[d].shift (shift);
-             skylines[d].raise (raise);
            }
        }
     }
@@ -96,6 +97,15 @@ Spacing_interface::minimum_distance (Grob *me, Grob *right)
   this will add a new column to RIGHT-ITEMS. Here we look at the
   columns, and return the left-most. If there are multiple columns, we
   prune RIGHT-ITEMS.
+
+  If we end up pruning, we add a left-neighbor to every column that
+  gets pruned. This ensures that loose columns in cross-staff music
+  do indeed get marked as loose. The problem situation is when a voice
+  passes from staff 1 to staff 2 and a clef appears later on in staff 1.
+  Then the NoteSpacing attached to the last note in staff 1 has two
+  right-items: one pointing to the next note in staff 2 and one pointing
+  to the clef. We will prune the clef right-item here and, unless we add
+  a left-neighbor to the clef, it won't get marked as loose.
 */
 Item *
 Spacing_interface::right_column (Grob *me)
@@ -122,6 +132,8 @@ Spacing_interface::right_column (Grob *me)
 
          mincol = col;
        }
+      else if (rank > min_rank)
+       prune = true;
     }
 
   if (prune && a)
@@ -130,7 +142,15 @@ Spacing_interface::right_column (Grob *me)
       for (vsize i = right.size (); i--;)
        {
          if (dynamic_cast<Item *> (right[i])->get_column () != mincol)
-           right.erase (right.begin () + i);
+           {
+             extract_grob_set (right[i], "left-neighbors", lns);
+             if (lns.empty ())
+               Pointer_group_interface::add_grob (right[i],
+                                                  ly_symbol2scm ("left-neighbors"),
+                                                  dynamic_cast<Item*> (me)->get_column ());
+
+             right.erase (right.begin () + i);
+           }
        }
     }
 
@@ -228,8 +248,10 @@ Spacing_interface::extremal_break_aligned_grob (Grob *me,
 
 
 ADD_INTERFACE (Spacing_interface,
-              "This object calculates the desired and minimum distances between two columns.",
+              "This object calculates the desired and minimum distances"
+              " between two columns.",
 
+              /* properties */
               "left-items "
               "right-items "
               );