]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix a cyclic dependency.
authorJoe Neeman <joeneeman@gmail.com>
Wed, 14 Jul 2010 23:38:56 +0000 (16:38 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Wed, 21 Jul 2010 22:10:22 +0000 (15:10 -0700)
Prevent Rest_collision::calc_positioning_done from querying
the extent of the Note_columns it is trying to position.

lily/include/note-column.hh
lily/include/rest.hh
lily/note-column.cc
lily/rest-collision.cc
lily/rest.cc

index 4069c4046be5c5a42670e76a0191f992fc272282..be673ec611fed08fa2b4a3ddd2b4c956f47d91c0 100644 (file)
@@ -37,7 +37,6 @@ public:
   static Grob *accidentals (Grob *me);
   static Grob *arpeggio (Grob *me);
   static Slice head_positions_interval (Grob *me);
-  static void translate_rests (Grob *me, int dy);
   static Grob *first_head (Grob *me);
   static Grob *get_rest (Grob *me);
   static void set_stem (Grob *me, Grob *);
index e7a78597e9d4248eb42e50e0c8578c96eca2145c..1d2c8f9aae7e779a8366d4d88e6884f6f9df1772 100644 (file)
@@ -33,6 +33,7 @@ public:
   static string glyph_name (Grob *, int, string, bool);
   static SCM brew_internal_stencil (Grob*, bool);
   static SCM generic_extent_callback (Grob*, Axis);
+  static void translate (Grob *me, int dy);
   DECLARE_SCHEME_CALLBACK (polyphonic_offset_callback, (SCM));
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (width, (SCM));
index 843f19158a699c99ba5dc9b25f495d55c7d6e3af..d756a9121b86c4008c2b4b7235564ea20e14a5e1 100644 (file)
@@ -137,22 +137,6 @@ Note_column::add_head (Grob *me, Grob *h)
     Axis_group_interface::add_element (me, h);
 }
 
-/**
-   translate the rest symbols vertically by amount DY, but only if
-   they have no staff-position set.
-*/
-void
-Note_column::translate_rests (Grob *me, int dy)
-{
-  Grob *r = unsmob_grob (me->get_object ("rest"));
-  if (r && !scm_is_number (r->get_property ("staff-position")))
-    {
-      r->translate_axis (dy * Staff_symbol_referencer::staff_space (r) / 2.0, Y_AXIS);
-      Grob *p = r->get_parent (Y_AXIS);
-      p->flush_extent_cache (Y_AXIS);
-    }
-}
-
 Grob *
 Note_column::first_head (Grob *me)
 {
index ee6935c7d8578526d0a31d13a20ad574831c3d30..a7f053b1401389ca925b7f4818de01a1dec49cbf 100644 (file)
@@ -76,6 +76,14 @@ Rest_collision::add_column (Grob *me, Grob *p)
     }
 }
 
+static bool
+rest_shift_less (Grob *const &r1, Grob *const &r2)
+{
+  Grob *col1 = r1->get_parent (X_AXIS);
+  Grob *col2 = r2->get_parent (X_AXIS);
+  return Note_column::shift_less (col1, col2);
+}
+
 /*
   TODO: look at horizontal-shift to determine ordering between rests
   for more than two voices.
@@ -133,14 +141,14 @@ Rest_collision::calc_positioning_done (SCM smob)
 
          Direction d = get_grob_direction (r);
          if (d)
-           ordered_rests[d].push_back (rests[i]);
+           ordered_rests[d].push_back (r);
          else
            rests[d]->warning (_ ("cannot resolve rest collision: rest direction not set"));
        }
 
       Direction d = LEFT;
       do
-       vector_sort (ordered_rests[d], Note_column::shift_less);
+       vector_sort (ordered_rests[d], rest_shift_less);
       while (flip (&d) != LEFT)
        ;
 
@@ -167,23 +175,23 @@ Rest_collision::calc_positioning_done (SCM smob)
        {
          int amount_down = (int) ceil (diff / 2);
          diff -= amount_down;
-         Note_column::translate_rests (ordered_rests[DOWN].back (),
-                                       -2 * amount_down);
+         Rest::translate (ordered_rests[DOWN].back (),
+                          -2 * amount_down);
          if (diff > 0)
-           Note_column::translate_rests (ordered_rests[UP].back (),
-                                         2 * int (ceil (diff)));
+           Rest::translate (ordered_rests[UP].back (),
+                            2 * int (ceil (diff)));
        }
 
       do
        {
-         for (vsize i = ordered_rests[d].size () -1; i-- > 0;)
+         for (vsize i = ordered_rests[d].size () - 1; i-- > 0;)
            {
              Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d];
              Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d];
 
              Real diff = d * ((last_y - y) / staff_space);
              if (diff > 0)
-               Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2);
+               Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2);
            }
        }
       while (flip (&d) != LEFT);
@@ -262,7 +270,7 @@ Rest_collision::calc_positioning_done (SCM smob)
          discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0);
        }
 
-      Note_column::translate_rests (rcol, discrete_y);
+      Rest::translate (rest, discrete_y);
     }
   return SCM_BOOL_T;
 }
index afa966993d0ba235cc2abda13c3402ceae2bfb97..53387664b5b33708393ba2b3d9f966b007e220ed 100644 (file)
@@ -161,6 +161,21 @@ Rest::brew_internal_stencil (Grob *me, bool ledgered)
   return out.smobbed_copy ();
 }
 
+/**
+   translate the rest vertically by amount DY, but only if
+   it doesn't have staff-position set.
+*/
+void
+Rest::translate (Grob *me, int dy)
+{
+  if (!scm_is_number (me->get_property ("staff-position")))
+    {
+      me->translate_axis (dy * Staff_symbol_referencer::staff_space (me) / 2.0, Y_AXIS);
+      Grob *p = me->get_parent (Y_AXIS);
+      p->flush_extent_cache (Y_AXIS);
+    }
+}
+
 SCM
 Rest::print (SCM smob)
 {