]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/tie.cc (get_control_points): rewrite. Put short ties in
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 13:11:51 +0000 (13:11 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Aug 2005 13:11:51 +0000 (13:11 +0000)
staff-spaces, make long ties cross staff lines. Avoid flags and dots.

* input/regression/tie-single.ly: new file.

input/regression/tie-single.ly
input/regression/tie.ly [deleted file]
lily/note-head.cc
lily/tie.cc
scm/define-grobs.scm

index e71b9b89a39166af568b645d1e7629deae0deea6..a33c67807e65c245669742b24a8169b3722c5af3 100644 (file)
@@ -1,7 +1,6 @@
 \header
 {
   texidoc = "Formatting for isolated ties.
- Things to note:
 
 @itemize @bullet
 @item short ties are in spaces
@@ -11,6 +10,8 @@
 
 @item short ties are vertically centered in the space, as well those
 that otherwise don't fit in a space
+
+@item extremely short ties are put over the noteheads, instead of inbetween.
  
 @end itemize
 "
diff --git a/input/regression/tie.ly b/input/regression/tie.ly
deleted file mode 100644 (file)
index bb19d52..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-\version "2.6.0"
-
-\header{
-texidoc="
-Ties are strictly horizontal.  They are placed in between note heads.
-The horizontal middle should not overlap with a staffline.
-"
-}
-\layout{
-    raggedright= ##t 
-}
-
-
-\relative c''{
-                               %b2~b4~b8~b16~b32~b64 r64\break
-                               %a2~a4~a8~a16~a32~a64 r64
-    \time 8/4
-    d1 ~ d2~d4~d8~d16~d32~d64 r64\break
-    a1~ a2~a4~a8~a16~a32~a64 r64
-                               %c2~c4~c8~c16~c32~c64 r64
-}
index 10707aeaa9b9621f77eb26a10455ef9c67e72ddd..b3faea2240a8b0cbafea92b00d6d7b32657112ce 100644 (file)
@@ -129,5 +129,9 @@ Note_head::get_balltype (Grob *me)
 
 ADD_INTERFACE (Note_head, "note-head-interface",
               "Note head",
-              "note-names glyph-name-procedure accidental-grob style stem-attachment-function");
+              "note-names "
+              "glyph-name-procedure "
+              "accidental-grob "
+              "style "
+              "stem-attachment-function");
 
index a0ac259c7b193a09f298df023e34cc081b70698c..408c0acfe3736a42f10ebdb095724c56c4508e39 100644 (file)
@@ -151,7 +151,7 @@ Tie::get_control_points (SCM smob)
       common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); 
     }
 
-  Drul_array<Real> attachments;
+  Interval attachments;
 
   Direction d = LEFT;
   Real gap = robust_scm2double (me->get_property ("x-gap"), 0.2);
@@ -165,6 +165,44 @@ Tie::get_control_points (SCM smob)
     }
   while (flip (&d) != LEFT);
 
+  bool in_between = true;
+  if (attachments.length () < 0.6 * staff_space)
+    {
+      /*
+       Let short ties start over note heads, instead of between.
+       */
+      Drul_array<bool> allow (true, true);
+
+      Direction d = LEFT;
+      do {
+       if (Note_head::has_interface (me->get_bound (d)))
+         {
+           Grob *stem = unsmob_grob (me->get_bound (d)->get_object ("stem"));
+           if (get_grob_direction (stem) == dir
+               && -d == dir)
+             allow[d] = false;
+         }
+      } while (flip (&d) != LEFT);
+
+      if (allow[LEFT] && allow[RIGHT])
+       {
+         staff_position += dir;
+         do
+           {
+             if (Note_head::has_interface (me->get_bound (d)))
+               {
+                 Interval extent
+                   = robust_relative_extent (me->get_bound (d),
+                                             common[X_AXIS], X_AXIS);
+
+                 attachments[d] = extent.linear_combination (- 0.5 * d);
+                 in_between = false;
+               }
+           }
+         while (flip (&d) != LEFT);
+       }
+    }
+
   SCM details = me->get_property ("details");
 
   SCM limit
@@ -174,7 +212,7 @@ Tie::get_control_points (SCM smob)
   Real r_0 = robust_scm2double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details)),
                                .333);
 
-  Bezier b = slur_shape (attachments[RIGHT] - attachments[LEFT],
+  Bezier b = slur_shape (attachments.length(),
                         h_inf, r_0);
   b.scale (1, dir);
   
@@ -185,8 +223,9 @@ Tie::get_control_points (SCM smob)
   
   Real dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]);
   bool in_space = !(Staff_symbol_referencer::on_staffline (me, (int) staff_position));
-  bool fits_in_space = (dy < 0.6 * staff_space);
-
+  bool fits_in_space =
+    (dy < 0.6 * staff_space);
+  
   /*
     Avoid dot
    */
@@ -225,7 +264,7 @@ Tie::get_control_points (SCM smob)
     {
       staff_position += 2 * dir; 
     }
-  
+
   if (in_space != fits_in_space)
     {
       if (in_space)
@@ -239,6 +278,12 @@ Tie::get_control_points (SCM smob)
        }
     }
 
+  if (!in_between
+      && in_space
+      && fabs (staff_position - Tie::get_position (me)) <= 1)
+    staff_position += 2*dir;
+  
+  
   if (in_space)
     {
       if (fabs (dy) < 0.4 * staff_space)
index 561c4d8832e5ae1bc0b418307f02471744b74666..517576aea665cd6b883c9781b3a0c4cf9fb242c2 100644 (file)
     (Tie
      . (
        (print-function . ,Tie::print)
-       (spacing-procedure . ,Spanner::set_spacing_rods)
+;      (spacing-procedure . ,Spanner::set_spacing_rods)
        (staffline-clearance . 0.35)
        (details . ((ratio . 0.333) (height-limit . 1.0)))
        (thickness . 1.0)