]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-collision.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / note-collision.cc
index b6185e4458deced9394837376ee02d515cfbea57..1430463ab958d506856deee33669fcb414933b60 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2014 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
@@ -178,7 +178,7 @@ check_meshing_chords (Grob *me,
   full_collide = full_collide || (close_half_collide
                                   && distant_half_collide)
                  || ( distant_half_collide // like full_ for wholes and longer
-                     && (up_ball_type <= 0 || down_ball_type <= 0));
+                      && (up_ball_type <= 0 || down_ball_type <= 0));
 
   /* Determine which chord goes on the left, and which goes right.
      Up-stem usually goes on the right, but if chords just 'touch' we can put
@@ -231,7 +231,8 @@ check_meshing_chords (Grob *me,
 
       /* If possible, don't wipe any heads.  Else, wipe shortest head,
          or head with smallest amount of dots.  Note: when merging
-         different heads, dots on the smaller one disappear. */
+         different heads, dots on the smaller one disappear; and when
+         merging identical heads, dots on the down-stem head disappear */
       Grob *wipe_ball = 0;
       Grob *dot_wipe_head = head_up;
 
@@ -248,7 +249,7 @@ check_meshing_chords (Grob *me,
               wipe_ball = head_up;
             }
           else
-            dot_wipe_head = head_up;
+            dot_wipe_head = head_down;
         }
       else if (down_ball_type > up_ball_type)
         {
@@ -353,8 +354,8 @@ check_meshing_chords (Grob *me,
           Grob *stem = unsmob_grob (head_down->get_object ("stem"));
           extract_grob_set (stem, "note-heads", heads);
           for (vsize i = 0; i < heads.size (); i++)
-            unsmob_grob (heads[i]->get_object ("dot"))
-            ->set_property ("direction", scm_from_int (dir));
+            if (Grob *dot = unsmob_grob (heads[i]->get_object ("dot")))
+              dot->set_property ("direction", scm_from_int (dir));
         }
     }
 
@@ -593,6 +594,22 @@ Note_collision_interface::add_column (Grob *me, Grob *ncol)
   Axis_group_interface::add_element (me, ncol);
 }
 
+vector<int>
+Note_collision_interface::note_head_positions (Grob *me)
+{
+  vector<int> out;
+  extract_grob_set (me, "elements", elts);
+  for (vsize i = 0; i < elts.size (); i++)
+    if (Grob *stem = unsmob_grob (elts[i]->get_object ("stem")))
+      {
+        vector<int> nhp = Stem::note_head_positions (stem);
+        out.insert (out.end (), nhp.begin (), nhp.end ());
+      }
+
+  vector_sort (out, less<int> ());
+  return out;
+}
+
 ADD_INTERFACE (Note_collision_interface,
                "An object that handles collisions between notes with"
                " different stem directions and horizontal shifts.  Most of"