]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-collision.cc
2003 -> 2004
[lilypond.git] / lily / note-collision.cc
index 01364cb838cff207228101158db8f718fbbf922e..d664121daa52090bf4a942bf7658195bdfd8036b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "warn.hh"
@@ -15,6 +15,8 @@
 #include "axis-group-interface.hh"
 #include "item.hh"
 #include "stem.hh"
+#include "side-position-interface.hh"
+#include "dot-column.hh"
 
 MAKE_SCHEME_CALLBACK (Note_collision_interface,force_shift_callback,2);
 
@@ -86,7 +88,8 @@ check_meshing_chords (Grob *me,
       && !to_boolean (me->get_grob_property ("merge-differently-headed")))
     merge_possible = false;
 
-  /* Can never merge quarter and half notes. */
+  /* Should never merge quarter and half notes, as this would make
+     them indistinguishable.  */
   if (merge_possible
       && ((Rhythmic_head::duration_log (nu) == 1
           && Rhythmic_head::duration_log (nd) == 2)
@@ -168,12 +171,10 @@ check_meshing_chords (Grob *me,
   if (touch)
     shift_amount *= -1;
 
-  /*
-    for full collisions, the right hand head may obscure dots, so
-    make sure the dotted heads go to the right.
-   */
-  if ((Rhythmic_head::dot_count (nu) > Rhythmic_head::dot_count (nd)
-       && full_collide))
+  /* For full collisions, the right hand head may obscure dots, so
+     make sure the dotted heads go to the right.  */
+  if (Rhythmic_head::dot_count (nu) > Rhythmic_head::dot_count (nd)
+      && full_collide)
     shift_amount = 1;
 
   if (merge_possible)
@@ -218,6 +219,18 @@ check_meshing_chords (Grob *me,
   else
     shift_amount *= 0.25;
 
+  /* For full or close half collisions, the right hand head may
+     obscure dots.  Move dots to the right.  */
+  if (abs (shift_amount) > 1e-6
+      && Rhythmic_head::dot_count (nd) > Rhythmic_head::dot_count (nu)
+      && (full_collide || close_half_collide))
+    {
+      Grob *d = unsmob_grob (nd->get_grob_property ("dot"));
+      Grob *parent = d->get_parent (X_AXIS);
+      if (Dot_column::has_interface (parent))
+       Side_position_interface::add_support (parent, nu);
+    }
+
   Direction d = UP;
   do
     {
@@ -387,8 +400,9 @@ Note_collision_interface::automatic_shift (Grob *me,
   do
     {
       for (int i=0; i < clash_groups[d].size (); i++)
-       tups = gh_cons (gh_cons (clash_groups[d][i]->self_scm (), gh_double2scm (offsets[d][i])),
-                                tups);
+       tups = gh_cons (gh_cons (clash_groups[d][i]->self_scm (),
+                                gh_double2scm (offsets[d][i])),
+                       tups);
     }
   while (flip (&d) != UP);
   return tups;