]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4503 (2/4) Let Tie::get_default_dir take a Spanner
authorDan Eble <nine.fierce.ballads@gmail.com>
Sun, 12 Jul 2015 23:20:23 +0000 (19:20 -0400)
committerDan Eble <nine.fierce.ballads@gmail.com>
Tue, 21 Jul 2015 18:09:46 +0000 (14:09 -0400)
lily/include/semi-tie.hh
lily/include/tie.hh
lily/semi-tie.cc
lily/tie.cc

index 8c52dc64d6516284df0bcbd2dd04e262dc1ee827..d56caf7e32c578f31600c5a71c88b2d628a7ae82 100644 (file)
@@ -27,7 +27,6 @@ struct Semi_tie
 {
   DECLARE_GROB_INTERFACE ();
 
-  DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM));
   static bool less (Grob *s1, Grob *s2);
   static int get_column_rank (Item *);
index a6b3bf59a7d19804b3e80789c246f11e4b2d7305..f349ddd61207903548dd81bddb48193e9d429fc1 100644 (file)
@@ -33,7 +33,7 @@ public:
   static int get_column_rank (Spanner *, Direction);
   static int get_position (Spanner *);
   static int get_position_generic (Grob *);
-  static Direction get_default_dir (Grob *);
+  static Direction get_default_dir (Spanner *);
   static SCM get_control_points (Grob *, Grob *,
                                  Tie_configuration const &,
                                  Tie_details const &);
index 193008751433dcaf3f7a5f7d6827a0bec6e88669..17520daf7010caca7ec34aefe3094a5959b655ea 100644 (file)
@@ -68,6 +68,7 @@ Semi_tie::calc_control_points (SCM smob)
       me->suicide ();
     }
 
+  // TODO: Even if me->suicide() was called?
   return me->get_property_data ("control-points");
 }
 
index 72855687e362dff78ea66e864813b9bd0421d457..57cbf6e3f4587f73757600c6d7fcc46b3b7af8d8 100644 (file)
@@ -119,20 +119,14 @@ Tie::get_position_generic (Grob *me) // TODO: do away with this
   (what about linebreaks? )
 */
 Direction
-Tie::get_default_dir (Grob *me)
+Tie::get_default_dir (Spanner *me)
 {
   Drul_array<Grob *> stems;
   for (LEFT_and_RIGHT (d))
     {
-      Grob *one_head = 0;
-      if (Spanner *spanner = dynamic_cast<Spanner *> (me))
-        {
-          one_head = head (spanner, d);
-          if (!one_head)
-            one_head = head (spanner->broken_neighbor (d), d);
-        }
-      else if (Item *item = dynamic_cast<Item *> (me))
-        one_head = Semi_tie::head (item);
+      Grob *one_head = head (me, d);
+      if (!one_head)
+        one_head = head (me->broken_neighbor (d), d);
 
       Grob *stem = one_head ? Rhythmic_head::get_stem (one_head) : 0;
       stems[d] = (stem && !Stem::is_invisible (stem)) ? stem : 0;
@@ -153,7 +147,7 @@ Tie::get_default_dir (Grob *me)
     return -get_grob_direction (stems[LEFT]);
   else if (stems[RIGHT])
     return -get_grob_direction (stems[RIGHT]);
-  else if (int p = get_position_generic (me))
+  else if (int p = get_position (me))
     return Direction (sign (p));
 
   return to_dir (me->get_property ("neutral-direction"));
@@ -163,6 +157,8 @@ MAKE_SCHEME_CALLBACK (Tie, calc_direction, 1);
 SCM
 Tie::calc_direction (SCM smob)
 {
+  // In this method, Tie and Semi_tie require the same logic with different
+  // types.  It might be clearer to use a template.
   Grob *me = unsmob<Grob> (smob);
   Grob *yparent = me->get_parent (Y_AXIS);
   if ((Tie_column::has_interface (yparent)
@@ -176,8 +172,10 @@ Tie::calc_direction (SCM smob)
 
       return me->get_property_data ("direction");
     }
-  else
-    return scm_from_int (Tie::get_default_dir (me));
+
+  programming_error ("no Tie_column or Semi_tie_column.  Killing grob.");
+  me->suicide ();
+  return scm_from_int (CENTER);
 }
 
 SCM