]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/rest-collision.cc (force_shift_callback_rest): change to
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 2 Nov 2005 00:42:56 +0000 (00:42 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 2 Nov 2005 00:42:56 +0000 (00:42 +0000)
chained callback.

* lily/rest.cc (y_offset_callback): merge function of 3 callbacks.

* lily/rest.cc (polyphonic_offset_callback): remove.

ChangeLog
lily/include/rest-collision.hh
lily/rest-collision.cc
lily/rest.cc

index 2a1be0aa197dede7d2a28af51737826e6df3814e..5ebd40984635f351fe87e51624959b9b0620676c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2005-11-02  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/rest-collision.cc (force_shift_callback_rest): change to
+       chained callback.
+
        * lily/rest.cc (y_offset_callback): merge function of 3 callbacks. 
 
        * lily/grob.cc (y_parent_positioning): remove axis argument from
index 5295fd435bae2c125295507fe7b0c27936b40d94..ae5405d24f7f7b70b1ee019d457ef52f60835f0e 100644 (file)
@@ -20,7 +20,7 @@ public:
   static bool has_interface (Grob *);
   DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element));
   DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM element));
-  DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element));
+  DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element, SCM off));
   static SCM do_shift (Grob *);
 };
 #endif // REST_COLLISION_HH
index 272aba6f4157989c46f9ec340600350966e73e41..e1757de1a4efefba357a22f608d04908f1c5886b 100644 (file)
@@ -39,16 +39,23 @@ Rest_collision::force_shift_callback (SCM smob)
   return scm_from_double (0.0);
 }
 
-MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 1);
+MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2);
 SCM
-Rest_collision::force_shift_callback_rest (SCM rest)
+Rest_collision::force_shift_callback_rest (SCM rest, SCM offset)
 {
   Grob *rest_grob = unsmob_grob (rest);
   Grob *parent = rest_grob->get_parent (X_AXIS);
+
+  /*
+    translate REST; we need the result of this translation later on,
+    while the offset probably still is 0/calculation-in-progress.
+   */
+  rest_grob->translate_axis (scm_to_double (offset), Y_AXIS);
+  
   if (Note_column::has_interface (parent))
-    return force_shift_callback (parent->self_scm ());
-  else
-    return scm_from_double (0.0);
+    force_shift_callback (parent->self_scm ());
+
+  return scm_from_double (0.0);
 }
 
 void
@@ -68,8 +75,8 @@ Rest_collision::add_column (Grob *me, Grob *p)
   Grob *rest = unsmob_grob (p->get_object ("rest"));
   if (rest)
     {
-      rest->set_property ("Y-offset" ,
-                         Rest_collision::force_shift_callback_rest_proc);
+      chain_offset_callback (rest,
+                            Rest_collision::force_shift_callback_rest_proc, Y_AXIS);
     }
 }
 
index b362a5de03c16cff368704df259847da4e492a61..75b610d0d2fddeadb513ce0e1319c2e4fb618dde 100644 (file)
@@ -23,13 +23,13 @@ Rest::y_offset_callback (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   int duration_log = scm_to_int (me->get_property ("duration-log"));
-  int lc = Staff_symbol_referencer::line_count (me);
+  int line_count = Staff_symbol_referencer::line_count (me);
   Real ss = Staff_symbol_referencer::staff_space (me);
 
   Real amount = 0.0;
-  if (lc % 2)
+  if (line_count % 2)
     {
-      if (duration_log == 0 && lc > 1)
+      if (duration_log == 0 && line_count > 1)
        amount += ss;
     }
   else
@@ -58,7 +58,7 @@ Rest::y_offset_callback (SCM smob)
 String
 Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers)
 {
-  bool ledgered_b = false;
+  bool is_ledgered = false;
   if (try_ledgers && (balltype == 0 || balltype == 1))
     {
       Real rad = Staff_symbol_referencer::staff_radius (me) * 2.0;
@@ -69,8 +69,8 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers)
        could bemore generic, but hey, we understand this even after
        dinner.
       */
-      ledgered_b |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad);
-      ledgered_b |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad);
+      is_ledgered |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad);
+      is_ledgered |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad);
     }
 
   String actual_style (style.to_str0 ());
@@ -84,7 +84,7 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers)
        ledgered rests at all now that we can draw ledger lines with
        variable width, length and blotdiameter? -- jr
       */
-      ledgered_b = 0;
+      is_ledgered = 0;
 
       /*
        There are no 32th/64th/128th mensural/neomensural rests.  In
@@ -112,7 +112,7 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers)
       actual_style = "";
     }
 
-  return ("rests." + to_string (balltype) + (ledgered_b ? "o" : "")
+  return ("rests." + to_string (balltype) + (is_ledgered ? "o" : "")
          + actual_style);
 }