]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie.cc
release: 1.1.0
[lilypond.git] / lily / tie.cc
index 0d17f409ce08caa247a7f2d55c12ad7c629e45b1..002c5e969478b3a621020b89d283840d4b2e1709 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "paper-def.hh"
@@ -47,7 +47,7 @@ void
 Tie::do_add_processing()
 {
   if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT]))
-    warning (_("Lonely tie.. "));
+    warning (_ ("lonely tie"));
 
   Direction d = LEFT;
   Drul_array<Note_head *> new_head_drul = head_l_drul_;
@@ -61,11 +61,12 @@ Tie::do_add_processing()
 void
 Tie::do_post_processing()
 {
+  // URG: share code with slur!
   assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
 
   Real notewidth = paper ()->note_width ();
   Real interline_f = paper ()->interline_f ();
-  Real const TIE_MIN = 2.0 * interline_f;
+  Real tie_min = paper ()->get_var ("tie_x_minimum");
 
   /* 
    [OSU]: slur and tie placement
@@ -76,11 +77,9 @@ Tie::do_post_processing()
    * y = length < 5ss : horizontal raakpunt
      y = length >= 5ss : y next interline - d * 0.25 ss
      --> height <= 5 length ?? we use <= 3 length, now...
-
-   * suggested gap = ss / 5;
    */
-  // jcn: 1/5 seems so small?
-  Real gap_f = interline_f / 2; // 5;
+
+  Real gap_f = paper ()->get_var ("slur_x_gap");
 
   Direction d = LEFT;
   do
@@ -103,9 +102,9 @@ Tie::do_post_processing()
          dy_f_drul_[d] += dir_ * 0.25 * interline_f;
        }
       // tie attached to inner notehead
-      else if (head_l_drul_[d])
+      else if (head_l_drul_[d] && d == LEFT)
        {
-         dx_f_drul_[d] += d*0.5 * notewidth;
+         dx_f_drul_[d] += -d * notewidth;
        }
       // uhm? loose end of tie // tie attached to stem
       else
@@ -122,26 +121,40 @@ Tie::do_post_processing()
       // tie attached to outer notehead
       if (!head_l_drul_[d])
        {
-         if (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT] < TIE_MIN)
+         if (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT] < tie_min)
            {
-             dx_f_drul_[d] -= d * TIE_MIN 
+             dx_f_drul_[d] -= d * tie_min 
                - (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
-             dx_f_drul_[d] = dx_f_drul_[(Direction)-d] + d * TIE_MIN;
+             dx_f_drul_[d] = dx_f_drul_[(Direction)-d] + d * tie_min;
            }
 
          dy_f_drul_[d] = dy_f_drul_[(Direction) -d];
        }
     }
   while (flip(&d) != LEFT);
+
+  /*
+    Avoid too steep ties
+      * slur from notehead to stemend: c''()b''
+   */
+  Real damp_f = paper ()->get_var ("tie_slope_damping");
+  Offset d_off = Offset (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT],
+    dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]);
+  d_off.x () += width ().length ();
+
+  Real ratio_f = abs (d_off.y () / d_off.x ());
+  if (ratio_f > damp_f)
+    dy_f_drul_[(Direction)(- dir_ * sign (d_off.y ()))] -=
+      dir_ * (damp_f - ratio_f) * d_off.x ();
 }
 
 void
-Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
+Tie::do_substitute_dependency (Score_element*o, Score_element*n)
 {
-  Note_head *new_l =n?(Note_head*)n->item():0;
-  if (o->item() == head_l_drul_[LEFT])
+  Note_head *new_l =n?(Note_head*)dynamic_cast <Item *> (n):0;
+  if (dynamic_cast <Item *> (o) == head_l_drul_[LEFT])
     head_l_drul_[LEFT] = new_l;
-  else if (o->item() == head_l_drul_[RIGHT])
+  else if (dynamic_cast <Item *> (o) == head_l_drul_[RIGHT])
     head_l_drul_[RIGHT] = new_l;
 }