]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-spacing.cc
Update source file headers. Fixes using standard GNU package conventions.
[lilypond.git] / lily / note-spacing.cc
index 24e79cd313b8c190fc72b911f705a76190b49e37..20c72829143f47da60c1f614eb187d5ef189df3a 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  note-spacing.cc -- implement Note_spacing
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2001--2009  Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 2001--2009  Han-Wen Nienhuys <hanwen@xs4all.nl>
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "note-spacing.hh"
@@ -191,7 +202,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.
@@ -219,6 +230,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);
@@ -233,12 +246,14 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
          Item *it = dynamic_cast<Item *> (items[i]);
          if (!Note_column::has_interface (it))
            continue;
+         if (d == RIGHT && it->get_column () != 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);
 
@@ -306,7 +321,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;