]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest-collision.cc
* lily/midi-item.cc (name): new method.
[lilypond.git] / lily / rest-collision.cc
index 7bfc3385f1624d173791b949b82b4e4e7f296ec6..8ad587e88bd91a4b1a205821e38091b43780cec7 100644 (file)
@@ -16,7 +16,7 @@
 #include "rhythmic-head.hh"
 #include "output-def.hh"
 #include "rest.hh"
-#include "group-interface.hh"
+#include "pointer-group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "duration.hh"
 #include "directional-element-interface.hh"
@@ -26,12 +26,12 @@ SCM
 Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
 {
   Grob *them = unsmob_grob (element_smob);
-  Axis a = (Axis) scm_to_int (axis);
-  assert (a == Y_AXIS);
+  (void) axis;
+  assert (scm_to_int (axis) == Y_AXIS);
 
   if (Note_column::has_rests (them))
     {
-      Grob *rc = unsmob_grob (them->get_property ("rest-collision"));
+      Grob *rc = unsmob_grob (them->get_object ("rest-collision"));
 
       if (rc && !to_boolean (rc->get_property ("positioning-done")))
        {
@@ -39,7 +39,7 @@ Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
          do_shift (rc);
        }
     }
-  return scm_make_real (0.0);
+  return scm_from_double (0.0);
 }
 
 MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2);
@@ -53,7 +53,7 @@ Rest_collision::force_shift_callback_rest (SCM rest, SCM axis)
   if (Note_column::has_interface (parent))
     return force_shift_callback (parent->self_scm (), axis);
   else
-    return scm_make_real (0.0);
+    return scm_from_double (0.0);
 }
 
 void
@@ -69,9 +69,9 @@ Rest_collision::add_column (Grob *me, Grob *p)
     (not?)
   */
   p->add_offset_callback (Rest_collision::force_shift_callback_proc, Y_AXIS);
-  p->set_property ("rest-collision", me->self_scm ());
+  p->set_object ("rest-collision", me->self_scm ());
 
-  Grob *rest = unsmob_grob (p->get_property ("rest"));
+  Grob *rest = unsmob_grob (p->get_object ("rest"));
   if (rest)
     {
       rest->add_offset_callback (Rest_collision::force_shift_callback_rest_proc,
@@ -86,21 +86,21 @@ Rest_collision::add_column (Grob *me, Grob *p)
 SCM
 Rest_collision::do_shift (Grob *me)
 {
-  SCM elts = me->get_property ("elements");
+  extract_grob_set (me, "elements", elts);
 
   Link_array<Grob> rests;
   Link_array<Grob> notes;
 
-  for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
+  for (int i = 0; i < elts.size (); i++)
     {
-      Grob *e = unsmob_grob (scm_car (s));
-      if (unsmob_grob (e->get_property ("rest")))
+      Grob *e = elts[i];
+      if (unsmob_grob (e->get_object ("rest")))
        {
          /*
            Ignore rests under beam.
          */
-         Grob *st = unsmob_grob (e->get_property ("stem"));
-         if (st && unsmob_grob (st->get_property ("beam")))
+         Grob *st = unsmob_grob (e->get_object ("stem"));
+         if (st && unsmob_grob (st->get_object ("beam")))
            continue;
 
          rests.push (e);
@@ -142,15 +142,14 @@ Rest_collision::do_shift (Grob *me)
          if (d)
            ordered_rests[d].push (rests[i]);
          else
-           rests[d]->warning (_ ("can't resolve rest collission: rest direction not set"));
+           rests[d]->warning (_ ("can't resolve rest collision: rest direction not set"));
        }
 
       Direction d = LEFT;
       do
-       {
-         ordered_rests[d].sort (Note_column::shift_compare);
-       }
-      while (flip (&d) != LEFT);
+       ordered_rests[d].sort (Note_column::shift_compare);
+      while (flip (&d) != LEFT)
+       ;
 
       do
        {
@@ -202,9 +201,7 @@ Rest_collision::do_shift (Grob *me)
        Rests and notes.
       */
       if (rests.size () > 1)
-       {
-         warning (_ ("too many colliding rests"));
-       }
+       warning (_ ("too many colliding rests"));
       Grob *rcol = 0;
       Direction dir = CENTER;
 
@@ -229,12 +226,10 @@ Rest_collision::do_shift (Grob *me)
 
       Interval notedim;
       for (int i = 0; i < notes.size (); i++)
-       {
-         notedim.unite (notes[i]->extent (common, Y_AXIS));
-       }
+       notedim.unite (notes[i]->extent (common, Y_AXIS));
 
       Real dist
-       = minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
+       = minimum_dist + dir * max (notedim[dir] - restdim[-dir], 0.0);
 
       int stafflines = Staff_symbol_referencer::line_count (me);
       if (!stafflines)