]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-spacing.cc
Merge branch 'master' of carldsorensen@git.sv.gnu.org:/srv/git/lilypond
[lilypond.git] / lily / note-spacing.cc
index 90db07a7e82ab1159a3804c4308b3f9bccc21fcb..bd796a71354f5d2376164781befe70a7f852a5cd 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2001--2007  Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2001--2009  Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "note-spacing.hh"
 #include "output-def.hh"
 #include "pointer-group-interface.hh"
 
+static bool
+non_empty_barline (Grob *me)
+{
+  return Bar_line::has_interface (me) && !me->extent (me, X_AXIS).is_empty ();
+}
+
 /*
   TODO: detect hshifts due to collisions, and account for them in
   spacing?
@@ -80,7 +86,7 @@ Note_spacing::get_spacing (Grob *me, Item *right_col,
     {
       Grob *bar = Pointer_group_interface::find_grob (right_col,
                                                      ly_symbol2scm ("elements"),
-                                                     Bar_line::has_interface);
+                                                     non_empty_barline);
 
       if (bar)
        {
@@ -185,7 +191,7 @@ same_direction_correction (Grob *note_spacing, Drul_array<Interval> head_posns)
 }
 
 
-/**
+/*
    Correct for optical illusions. See [Wanske] p. 138. The combination
    up-stem + down-stem should get extra space, the combination
    down-stem + up-stem less.
@@ -213,6 +219,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
 
   Direction d = LEFT;
 
+  bool acc_right = false;
+
   Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT,
                                                              rcolumn->break_status_dir (),
                                                              &bar_xextent);
@@ -229,10 +237,10 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
            continue;
 
          /*
-           don't correct if accidentals are sticking out of the right side.
+           Find accidentals which are sticking out of the right side.
          */
-         if (d == RIGHT && Note_column::accidentals (it))
-           return;
+        if (d == RIGHT)
+            acc_right = acc_right || Note_column::accidentals (it);
 
          Grob *stem = Note_column::get_stem (it);
 
@@ -300,7 +308,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
            correction *= 0.5;
        }
     }
-  else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1)
+  /*
+    Only apply same direction correction if there are no
+    accidentals sticking out of the right hand side.
+  */
+  else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1
+          && !acc_right)
     correction = same_direction_correction (me, head_posns);
 
   *space += correction;