]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie.cc
release: 1.5.29
[lilypond.git] / lily / tie.cc
index 58ef8d549b64341352e8323323185f76e3a43633..2dea2b88467b2182386ab7ffd454fac25d372cf1 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include <math.h>
 
@@ -110,7 +110,7 @@ Tie::get_default_dir (Grob*me)
 SCM
 Tie::get_control_points (SCM smob)
 {  
-  Spanner*me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+  Spanner*me = unsmob_spanner (smob);
   Direction headdir = CENTER; 
   if (head (me,LEFT))
     headdir = LEFT;
@@ -146,15 +146,14 @@ Tie::get_control_points (SCM smob)
    */
   Real lambda = 0.5;           
   
-  if (Note_head::has_interface (me->get_bound (LEFT)))
+  if (Note_head::has_interface (l))
     left_x = l->extent (l, X_AXIS)[RIGHT] + x_gap_f;
   else
     left_x = l->extent (l, X_AXIS).linear_combination (lambda);
   
 
   Real width;
-  if (Note_head::has_interface (me->get_bound (LEFT))
-      && Note_head::has_interface (me->get_bound (RIGHT)))
+  if (Note_head::has_interface (l) && Note_head::has_interface (r))
     {
       width = 
        + r->extent (commonx,X_AXIS)[LEFT]
@@ -163,7 +162,7 @@ Tie::get_control_points (SCM smob)
     }
   else
     {
-      if (Note_head::has_interface (me->get_bound (LEFT)))
+      if (Note_head::has_interface (l))
        width = r->relative_coordinate (commonx, X_AXIS)
          - l->extent (commonx, X_AXIS)[RIGHT]
          - 2 * x_gap_f;
@@ -181,34 +180,36 @@ Tie::get_control_points (SCM smob)
   SCM lim // groetjes aan de chirurgendochter.
     = scm_assq (ly_symbol2scm ("height-limit"),details);
   
-  Real h_inf = gh_scm2double (gh_cdr (lim)) *  staff_space;
-  Real r_0 = gh_scm2double (gh_cdr (scm_assq (ly_symbol2scm ("ratio"),details)));
+  Real h_inf = gh_scm2double (ly_cdr (lim)) *  staff_space;
+  Real r_0 = gh_scm2double (ly_cdr (scm_assq (ly_symbol2scm ("ratio"),details)));
 
   Bezier b  = slur_shape (width, h_inf, r_0);
   
-  Offset leave_dir = b.control_[1] - b.control_[0];
-
-  Grob *hed =head (me, headdir);
-  Real dx = (hed->extent (hed, X_AXIS).length () + x_gap_f)/2.0;
-  Real max_gap = leave_dir[Y_AXIS] * dx / leave_dir[X_AXIS];
-
   /*
-    for small ties (t small) we want to start in the Y-center (so dy = 0), for
-    large ties, the tie should appear to come from the center of the
-    head, so dy = max_gap
-
-    maybe use a different formula?
+    I think this better, particularly for small ties. It always allows the user to move ties if
+    they seem in the wrong place
 
     TODO: what if 2 heads have different size.
 
-    TODO: for small ties, it is better to start over the heads
-    iso. next to the heads. 
   */
-  Real t = (width / staff_space - 5.0);        // ugh.
-  Real dy = t > 0 ? max_gap * sqr (t / (1 + t)) : 0.0;
 
-  Real ypos = Tie::position_f (me) * staff_space/2 + dir * dy;
+  Real ypos = Tie::position_f (me) * staff_space/2
+    + dir * gh_scm2double (me->get_grob_property ("y-offset"));;
 
+  /*
+    Make sure we don't start on a dots
+   */
+  if (Note_head::has_interface (l) && Rhythmic_head::dots_l (l))
+    {
+      Grob* dots = Rhythmic_head::dots_l(l);
+      if(fabs (staff_space * Staff_symbol_referencer::position_f (dots) /2
+              - ypos) < 0.5)
+       {
+         ypos += 0.5 * dir ;
+       }
+    }
+
+  
   /*
     todo: prevent ending / staffline collision.
 
@@ -243,7 +244,7 @@ Tie::get_control_points (SCM smob)
 
       Real clear = staff_space * gh_scm2double (me->get_grob_property ("staffline-clearance"));
 
-       if (fabs (y) <= Staff_symbol_referencer::staff_radius (me)
+      if (fabs (y) <= Staff_symbol_referencer::staff_radius (me)
          && fabs (diff) < clear)
        {
          Real y1 = ry + clear;
@@ -251,7 +252,7 @@ Tie::get_control_points (SCM smob)
          
          newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2;
          
-         //      newy = ry - 0.5 * staff_space * sign (diff) ;
+         // newy = ry - 0.5 * staff_space * sign (diff) ;
 
          /*
            we don't want horizontal ties
@@ -298,9 +299,9 @@ Tie::brew_molecule (SCM smob)
 
   Bezier b;
   int i = 0;
-  for (SCM s= cp; s != SCM_EOL; s = gh_cdr (s))
+  for (SCM s= cp; s != SCM_EOL; s = ly_cdr (s))
     {
-      b.control_[i] = ly_scm2offset (gh_car (s));
+      b.control_[i] = ly_scm2offset (ly_car (s));
       i++;
     }