]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie.cc
Issue 4503 (2/4) Let Tie::get_default_dir take a Spanner
[lilypond.git] / lily / tie.cc
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