]> git.donarmstrong.com Git - lilypond.git/commitdiff
(outside_slur_callback): try three sample points
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Oct 2004 23:28:39 +0000 (23:28 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Oct 2004 23:28:39 +0000 (23:28 +0000)
for determining collisions. This fixes: slur-script.ly.

ChangeLog
lily/script-interface.cc
lily/slur.cc
scm/define-grob-properties.scm
scm/framework-tex.scm
tex/lilyponddefs.tex

index b37b94049dbc521e8ab23dbb6096fb8bda0d6241..092d579c69c8c2e5b0249ac307a3414af06de1ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-02  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/slur.cc (outside_slur_callback): try three sample points
+       for determining collisions. This fixes: slur-script.ly.
+
 2004-09-30  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * scripts/lilypond-book.py (ext2format): Add latex as Latex.
index c13ddf876429b5856c0afe8f73b182b02229c695..59672c7e2fcda86abf913b8e90531e1c8f376ccb 100644 (file)
@@ -100,5 +100,5 @@ ADD_INTERFACE (Text_script,"text-script-interface",
  */
 ADD_INTERFACE (Script_interface, "script-interface",
   "An object that is put above or below a note",
-  "add-stem-support slur script-priority script-stencil inside-slur");
+  "add-stem-support slur-padding slur script-priority script-stencil inside-slur");
 
index 2f83d045a3a07db6e8a69140886508c49db7f583..a115f5303c93333c284182fa902dd4bf93ea7650 100644 (file)
@@ -151,38 +151,47 @@ Slur::outside_slur_callback (SCM grob, SCM axis)
   Interval xext = robust_relative_extent (script, cx, X_AXIS);
 
 
-  Real slur_padding = robust_scm2double (script->get_property ("padding"),
-                                        0.2);  // todo: slur property, script property?
+  Real slur_padding = robust_scm2double (script->get_property ("slur-padding"),
+                                        0.0);  // todo: slur property, script property?
   yext.widen (slur_padding);
   
   Interval bezext (curve.control_[0][X_AXIS],
                   curve.control_[3][X_AXIS]);
 
-  Real x = xext.center ();
-  if (bezext.contains (x))
-    ;
-  else if (!bezext.contains (xext[RIGHT]))
-    x = xext[LEFT];
-  else if (!bezext.contains (xext[LEFT]))
-    x = xext[RIGHT];
+  bool consider[] = { false, false, false };
+  Real ys[] = {0, 0, 0};
+  int k = 0;
+  bool do_shift = false;
 
-  
-  if (!bezext.contains (x))
-    return scm_make_real (0);
-  Real dist = fabs (x - bezext[LEFT]) <? fabs (x - bezext[RIGHT]);
-  
-  Real y = (dist >  1e-3)
-    ? curve.get_other_coordinate (X_AXIS, x)
-    : ((x < bezext.center())
-       ? curve.control_[0][Y_AXIS]
-       : curve.control_[3][Y_AXIS]);
-       
-  if (yext.contains (y)) 
+  for (Direction d = LEFT ;  d <= RIGHT; d = Direction (d + 1))
     {
-      Direction dir = get_grob_direction (script); 
-      return scm_make_real (y - yext[-dir] + dir * slur_padding);
+      Real x = xext.linear_combination (d);
+      consider[k] = bezext.contains (x);
+
+      if (consider[k])
+       {
+         ys[k] = curve.get_other_coordinate (X_AXIS, x);
+         consider[k] = true;
+
+         if (yext.contains (ys[k]))
+           do_shift = true;
+       }
     }
-  return scm_make_real (0.0);
+  Real offset = 0.0;
+  if (do_shift)
+    {
+      k = 0;
+      Direction dir = get_grob_direction (script);
+      for (Direction d = LEFT ;  d <= RIGHT; d = Direction (d + 1))
+       {
+         offset = 
+           dir * (dir * offset >? dir * (ys[k]
+                                         - yext[-dir] + dir * slur_padding));
+         k++;
+       }
+    }
+  
+  return scm_make_real (offset);
 }
 
 
index d40a9b50fcb3e2b843ff8fcb6dcb687f7b32bbc2..168944dec2c86e40f05bf5c78c5544f2e7ac0c7f 100644 (file)
@@ -391,6 +391,7 @@ note that starts here.")
 object.")
      (size ,number? "Size of object, relative to standard size.")
      (slope ,number? "The slope of this object.")
+     (slur-padding ,number? "Extra distance between slur and script.")
      (slur-details ,list?
                   "An alist of scoring parameters for slur formatting")
      (space-alist ,list? "A table that specifies distances between
index c400bbc883f33dbbb14ac6960addf028c2e51991..b7ec9a9093b11972fea32a2062946c01655c66eb 100644 (file)
       (header bookpaper (length pages) #f)
       (define-fonts bookpaper)
       (header-end)))
-    (ly:outputter-dump-string outputter "\\nopagebreak")
+    (ly:outputter-dump-string outputter "\\lilypondnopagebreak")
     (for-each
      (lambda (page) (dump-page outputter page (eq? last-page page) with-extents))
      pages)
index 9d7f7196c0c699783c6d7b8e081d831b49afb6f2..ff2fa55deccf5de0346cc2f12f07f6cec757bb59 100644 (file)
      {\gdef\lilypondpagebreak{\newpage}}}
   {}
       
+%% Allow overriding of pagebreak
+\lilypondifundefined{lilypondnopagebreak}
+{\lilypondifundefined{@nodocument}
+   {\gdef\lilypondnopagebreak{}}
+   {\gdef\lilypondnopagebreak{\nopagebreak}}}
+{}
 %% Include \special only once.
 \gdef\lilypondspecial{
   \special{header=music-drawing-routines.ps}