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

ChangeLog
input/regression/tie-dots.ly [deleted file]
lily/tie.cc

index aa26e9e6d48737541b6c0c4eb3647aceb932709a..cf6323491bba52a0e4d745d4579333e1239fdb73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,17 @@
-2005-08-21  Graham Percival  <gpermus@gmail.com>
+2005-08-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
-       * ly/bagpipe.ly: fix compile problem.
+       * input/regression/tie-dots.ly (Module): remove.
 
-2005-08-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+       * lily/tie.cc (get_control_points): rewrite. Put short ties in
+       staff-spaces, make long ties cross staff lines. Avoid flags and dots.
 
        * input/regression/tie-single.ly: new file.
 
-       * scm/define-grobs.scm (all-grob-descriptions): height limit .75
+2005-08-21  Graham Percival  <gpermus@gmail.com>
+
+       * ly/bagpipe.ly: fix compile problem.
+
+2005-08-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * lily/midi-item.cc (name): new method.
 
diff --git a/input/regression/tie-dots.ly b/input/regression/tie-dots.ly
deleted file mode 100644 (file)
index f6ba9db..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-\version "2.6.0"
-\header {
-  texidoc = "Ties should not collide with dots."
-}
-
-{
-  \time 9/8 \key f \major\clef bass
-  g4 d8 bes4.  ~    bes4    a8    \bar "|"
-  a8    gis8    d8 f4.    gis,4.    \bar "|"
-  a,4.   ~    a,4    r8   r4   r8   \bar "|"
-  c4.   ~    c8    a8    g8    f8
-}
-
-
index 78caff41885fd3de965bc0941acc35b8de4c36fb..a0ac259c7b193a09f298df023e34cc081b70698c 100644 (file)
@@ -124,6 +124,162 @@ Tie::set_direction (Grob *me)
     }
 }
 
+
+SCM
+Tie::get_control_points (SCM smob)
+{
+  Spanner *me = unsmob_spanner (smob);
+  if (!head (me, LEFT) && !head (me, RIGHT))
+    {
+      programming_error ("tie without heads");
+      me->suicide ();
+      return SCM_EOL;
+    }
+
+  set_direction (me);
+
+  Direction dir = get_grob_direction (me);
+
+  Real staff_space = Staff_symbol_referencer::staff_space (me);
+  Real staff_position = Tie::get_position (me);
+
+  Grob *common[NO_AXES];
+  for (int a = X_AXIS; a < NO_AXES; a++)
+    {
+      Axis ax ((Axis) a); 
+      common[ax] = me->get_bound (LEFT)->common_refpoint (me, ax); 
+      common[ax] = me->get_bound (RIGHT)->common_refpoint (common[a], ax); 
+    }
+
+  Drul_array<Real> attachments;
+
+  Direction d = LEFT;
+  Real gap = robust_scm2double (me->get_property ("x-gap"), 0.2);
+  do
+    {
+      attachments[d]
+       = robust_relative_extent (me->get_bound (d),
+                                 common[X_AXIS],
+                                 X_AXIS)[-d]
+       - gap * d;
+    }
+  while (flip (&d) != LEFT);
+
+  SCM details = me->get_property ("details");
+
+  SCM limit
+    = scm_assq (ly_symbol2scm ("height-limit"), details);
+
+  Real h_inf = robust_scm2double (scm_cdr (limit), 0.75) * staff_space;
+  Real r_0 = robust_scm2double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details)),
+                               .333);
+
+  Bezier b = slur_shape (attachments[RIGHT] - attachments[LEFT],
+                        h_inf, r_0);
+  b.scale (1, dir);
+  
+  Offset middle = b.curve_point (0.5);
+  Offset edge = b.curve_point (0.0);
+
+  staff_position = rint (staff_position);
+  
+  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);
+
+  /*
+    Avoid dot
+   */
+  Grob *left_dot = unsmob_grob (me->get_bound (LEFT)->get_object ("dot"));
+  if (left_dot && in_space && fits_in_space)
+    {
+      if (staff_position == Staff_symbol_referencer::get_position (left_dot))
+       {
+         staff_position += dir;
+         in_space = false;
+       }
+    }
+
+  /*
+    Avoid flag.
+   */
+  Grob *left_stem = unsmob_grob (me->get_bound (LEFT)->get_object ("stem"));
+  if (left_stem)
+    {
+      Stencil flag = Stem::get_translated_flag (left_stem);
+      Real y = staff_position * staff_space * 0.5;
+      if (flag.extent (Y_AXIS).contains (y))
+       {
+         staff_position += dir;
+         in_space = !in_space;
+       }
+    }
+
+  /*
+    Putting larger in-space ties next to the notes forces
+    the edges to be opposite (Y-wise) to the tie direction.
+   */
+  if (staff_position == Tie::get_position (me)
+      && in_space
+      && dy > 0.3 * staff_space)
+    {
+      staff_position += 2 * dir; 
+    }
+  
+  if (in_space != fits_in_space)
+    {
+      if (in_space)
+       {
+         staff_position += dir;
+       }
+      else
+       {
+         in_space = true;
+         staff_position += dir;
+       }
+    }
+
+  if (in_space)
+    {
+      if (fabs (dy) < 0.4 * staff_space)
+       {
+         /*
+           vertically center in space.
+         */
+         Offset middle = b.curve_point (0.5);
+         Offset edge = b.curve_point (0.0);
+
+         Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
+         b.translate (Offset (0,
+                              staff_position * staff_space * 0.5
+                              - center));
+       }
+      else
+       {
+         b.translate (Offset (0,
+                              (staff_position - dir) * staff_space * 0.5
+                              + dir * 0.2 * staff_space));
+       }
+    }
+  else
+    {
+      Real rounding_dy = (1.5 * dir  - middle[Y_AXIS]);
+      
+      b.translate (Offset (0,
+                          0.5 * staff_position * staff_space + rounding_dy));
+    }
+  
+  b.translate (Offset (attachments[LEFT]
+                      - me->relative_coordinate (common[X_AXIS], X_AXIS), 0));
+  
+  SCM controls = SCM_EOL;
+  for (int i = 4; i--;)
+    controls = scm_cons (ly_offset2scm (b.control_[i]), controls);
+  return controls;
+}
+
+
+
 MAKE_SCHEME_CALLBACK (Tie, print, 1);
 SCM
 Tie::print (SCM smob)