]> git.donarmstrong.com Git - lilypond.git/commitdiff
Tweaks to Note_spacing.
authorJoe Neeman <joeneeman@gmail.com>
Sun, 5 Aug 2007 07:31:54 +0000 (17:31 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 5 Aug 2007 07:31:54 +0000 (17:31 +1000)
lily/note-spacing.cc
lily/spacing-interface.cc

index 88c459240f029ab8b953728e0b9e01c3818341bd..139521b15eb7ac2382e97dbd5be79f897b8fe330 100644 (file)
@@ -66,16 +66,18 @@ Note_spacing::get_spacing (Grob *me, Item *right_col,
     adjust things so there are no collisions.
   */
   Drul_array<Skyline> skys = Spacing_interface::skylines (me, right_col);
-  Real min_dist = max (0.0, skys[LEFT].distance (skys[RIGHT]));
+  Real distance = skys[LEFT].distance (skys[RIGHT]);
+  Real min_dist = max (0.0, distance);
   Real min_desired_space = left_head_end + (min_dist - left_head_end) / 2;
+  Real ideal = max (base_space - increment + left_head_end, min_desired_space);
 
-  /* if the right object sticks out a lot, include a bit of extra space.
-     But only for non-musical-columns; this shouldn't apply to accidentals */
+  /* If the NonMusicalPaperColumn on the right sticks out a lot, ensure that
+     the amount of whitespace between the end of the note-head and that column is
+     (base_spacing - increment) (without this line, this would be the distance,
+     not the whitespace)
+  */
   if (!Paper_column::is_musical (right_col))
-    min_desired_space = max (min_desired_space,
-                            left_head_end + LEFT * skys[RIGHT].max_height ());
-
-  Real ideal = base_space - increment + min_desired_space;
+    ideal = max (ideal, base_space - increment + distance);
 
   stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space);
 
index 93bd1c2cfaf0549de703ef1892748916729b818e..8d1e0b036ade24df978d0370e4d31ba72bc993b7 100644 (file)
@@ -17,6 +17,7 @@
 #include "paper-column.hh"
 #include "separation-item.hh"
 #include "skyline.hh"
+#include "system.hh"
 
 /* return the right-pointing skyline of the left-items and the left-pointing
    skyline of the right-items (with the skyline of the left-items in
@@ -38,29 +39,41 @@ Spacing_interface::skylines (Grob *me, Grob *right_col)
   Drul_array<vector<Grob*> > items (ly_scm2link_array (orig->get_object ("left-items")),
                                    ly_scm2link_array (orig->get_object ("right-items")));
 
+  Grob *system = me->get_system ();
+  Grob *left_col = dynamic_cast<Item*> (me)->get_column ();
+
+  Drul_array<Grob*> columns (left_col, right_col);
+
   Direction d = LEFT;
   do
     {
-      skylines[d].set_minimum_height (0.0);
-
       for (vsize i = 0; i < items[d].size (); i++)
        {
-         Grob *g = items[d][i];
-         if (Item *it = dynamic_cast<Item*> (g))
-           if (Grob *piece = it->find_prebroken_piece (break_dirs[d]))
+         Item *g = dynamic_cast<Item*> (items[d][i]);
+         if (g)
+           if (Item *piece = g->find_prebroken_piece (break_dirs[d]))
              g = piece;
 
-         if (Separation_item::has_interface (g))
+         if (g && Separation_item::has_interface (g) && g->get_column () == columns[d])
            {
              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);
+
+             skylines[d].shift (-shift);
+             skylines[d].raise (-raise);
+
              if (sky)
                skylines[d].merge ((*sky)[-d]);
              else
                programming_error ("separation item has no skyline");
-           
+
              if (d == RIGHT && items[LEFT].size ())
                skylines[d].merge (Separation_item::conditional_skyline (items[d][i], items[LEFT][0]));
+
+             skylines[d].shift (shift);
+             skylines[d].raise (raise);
            }
        }
     }