]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur.cc
plug memleak in case of failed files.
[lilypond.git] / lily / slur.cc
index c78a066d065cc5069995adea3c86de5ae7c81cd1..0128e8cdfda6f3d4ca3004c429d290fe169b691b 100644 (file)
@@ -185,8 +185,27 @@ Slur::add_extra_encompass (Grob *me, Grob *n)
   Pointer_group_interface::add_grob (me, ly_symbol2scm ("encompass-objects"), n);
 }
 
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, pure_outside_slur_callback, 4, 1);
+SCM
+Slur::pure_outside_slur_callback (SCM grob, SCM start_scm, SCM end_scm, SCM offset_scm)
+{
+  int start = robust_scm2int (start_scm, 0);
+  int end = robust_scm2int (end_scm, 0);
+  Grob *script = unsmob_grob (grob);
+  Grob *slur = unsmob_grob (script->get_object ("slur"));
+  if (!slur)
+    return offset_scm;
+
+  SCM avoid = script->get_property ("avoid-slur");
+  if (avoid != ly_symbol2scm ("outside") && avoid != ly_symbol2scm ("around"))
+    return offset_scm;
+
+  Real offset = robust_scm2double (offset_scm, 0.0);
+  Direction dir = get_grob_direction (script);
+  return scm_from_double (offset + dir * slur->pure_height (slur, start, end).length () / 4);
+}
 
-MAKE_SCHEME_CALLBACK (Slur, outside_slur_callback, 2);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, outside_slur_callback, 2, 1);
 SCM
 Slur::outside_slur_callback (SCM grob, SCM offset_scm)
 {
@@ -216,8 +235,8 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm)
   Interval yext = robust_relative_extent (script, cy, Y_AXIS);
   Interval xext = robust_relative_extent (script, cx, X_AXIS);
 
-  yext.translate (robust_scm2double (offset_scm, 0));
-  
+  Real offset = robust_scm2double (offset_scm, 0);
+  yext.translate (offset);
   
   /* FIXME: slur property, script property?  */
   Real slur_padding = robust_scm2double (script->get_property ("slur-padding"),
@@ -258,7 +277,7 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm)
       avoidance_offset = dir * (max (dir * avoidance_offset,
                                     dir * (ys[k] - yext[-dir] + dir * slur_padding)));
   
-  return scm_from_double (scm_to_double (offset_scm) + avoidance_offset);
+  return scm_from_double (offset + avoidance_offset);
 }
 
 /*