]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-collision.cc
* lily/relocate.cc (setup_paths): only check path for non-absolute
[lilypond.git] / lily / note-collision.cc
index 8dab14f3daca935443150e56bb1413e17137c789..31c9d41cc369bacf3daaae472a2dfcbe00af3a05 100644 (file)
@@ -3,12 +3,11 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "note-collision.hh"
 
-#include <math.h>
 
 #include "warn.hh"
 #include "note-column.hh"
 #include "dot-column.hh"
 #include "pointer-group-interface.hh"
 
-MAKE_SCHEME_CALLBACK (Note_collision_interface, force_shift_callback, 2);
 
-SCM
-Note_collision_interface::force_shift_callback (SCM element_smob, SCM axis)
-{
-  Grob *me = unsmob_grob (element_smob);
-  Axis a = (Axis) scm_to_int (axis);
-  assert (a == X_AXIS);
-
-  me = me->get_parent (a);
-
-  if (! to_boolean (me->get_property ("positioning-done")))
-    {
-      me->set_property ("positioning-done", SCM_BOOL_T);
-      do_shifts (me);
-    }
-
-  return scm_from_double (0.0);
-}
 
 void
 check_meshing_chords (Grob *me,
@@ -73,7 +54,7 @@ check_meshing_chords (Grob *me,
 
   /* Do not merge notes typeset in different style. */
   if (!ly_is_equal (nu->get_property ("style"),
-                    nd->get_property ("style")))
+                   nd->get_property ("style")))
     merge_possible = false;
 
   int upball_type = Note_head::get_balltype (nu);
@@ -95,6 +76,11 @@ check_meshing_chords (Grob *me,
       && !to_boolean (me->get_property ("merge-differently-headed")))
     merge_possible = false;
 
+  merge_possible = merge_possible &&
+    !(nu->get_property ("style") == ly_symbol2scm ("fa")
+      && nd->get_property ("style") == ly_symbol2scm ("fa"));
+  
+  
   /* Should never merge quarter and half notes, as this would make
      them indistinguishable.  */
   if (merge_possible
@@ -211,9 +197,7 @@ check_meshing_chords (Grob *me,
              wipe_ball = nu;
            }
          else
-           {
-             dot_wipe_head = nu;
-           }
+           dot_wipe_head = nu;
        }
       else if (dnball_type > upball_type)
        {
@@ -235,7 +219,6 @@ check_meshing_chords (Grob *me,
       if (wipe_ball && wipe_ball->is_live ())
        {
          wipe_ball->set_property ("transparent", SCM_BOOL_T);
-         wipe_ball->set_property ("stencil", SCM_EOL);
        }
     }
   /* TODO: these numbers are magic; should devise a set of grob props
@@ -288,15 +271,30 @@ check_meshing_chords (Grob *me,
   while ((flip (&d)) != UP);
 }
 
-void
-Note_collision_interface::do_shifts (Grob *me)
+
+MAKE_SCHEME_CALLBACK(Note_collision_interface, calc_positioning_done, 1) 
+SCM
+Note_collision_interface::calc_positioning_done (SCM smob)
 {
+  Grob *me = unsmob_grob (smob);  
   Drul_array<Link_array<Grob> > cg = get_clash_groups (me);
 
+  Direction d = UP;
+  do
+    {
+      for (int i = cg[d].size(); i--; )
+       {
+         /*
+           Trigger positioning
+          */
+         cg[d][i]->extent (me, X_AXIS);
+       }
+    }
+  while (flip (&d) != UP);
+
   SCM autos (automatic_shift (me, cg));
   SCM hand (forced_shift (me));
 
-  Direction d = UP;
   Real wid = 0.0;
   do
     {
@@ -337,9 +335,9 @@ Note_collision_interface::do_shifts (Grob *me)
     }
 
   for (int i = 0; i < amounts.size (); i++)
-    {
-      done[i]->translate_axis (amounts[i] - left_most, X_AXIS);
-    }
+    done[i]->translate_axis (amounts[i] - left_most, X_AXIS);
+
+  return SCM_BOOL_T;
 }
 
 Drul_array < Link_array<Grob> >
@@ -470,7 +468,7 @@ Note_collision_interface::forced_shift (Grob *me)
   SCM tups = SCM_EOL;
 
   extract_grob_set (me, "elements", elements);
-  for (int i = 0;  i < elements.size (); i++)
+  for (int i = 0; i < elements.size (); i++)
     {
       Grob *se = elements[i];
 
@@ -487,9 +485,8 @@ Note_collision_interface::forced_shift (Grob *me)
 void
 Note_collision_interface::add_column (Grob *me, Grob *ncol)
 {
-  ncol->add_offset_callback (Note_collision_interface::force_shift_callback_proc, X_AXIS);
+  ncol->set_property ("X-offset", Grob::x_parent_positioning_proc);
   Axis_group_interface::add_element (me, ncol);
-  me->add_dependency (ncol);
 }
 
 ADD_INTERFACE (Note_collision_interface, "note-collision-interface",
@@ -498,4 +495,7 @@ ADD_INTERFACE (Note_collision_interface, "note-collision-interface",
               "are to be set in @ref{note-column-interface}: these are "
               "@code{force-hshift} and @code{horizontal-shift}.",
 
-              "merge-differently-dotted merge-differently-headed positioning-done");
+              /* properties */
+              "merge-differently-dotted "
+              "merge-differently-headed "
+              "positioning-done");