]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/arpeggio.cc
Run `make grand-replace'.
[lilypond.git] / lily / arpeggio.cc
index fe7b116821778f883f5b028d9a3717d50dbdf35f..fcb32debcbdd6107ee5987b2427d49839f63135c 100644 (file)
@@ -3,20 +3,21 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2008 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "arpeggio.hh"
 
+#include "bezier.hh"
+#include "font-interface.hh"
 #include "grob.hh"
+#include "lookup.hh"
 #include "output-def.hh"
-#include "stem.hh"
+#include "pointer-group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "staff-symbol.hh"
+#include "stem.hh"
 #include "warn.hh"
-#include "font-interface.hh"
-#include "lookup.hh"
-#include "pointer-group-interface.hh"
 
 Grob *
 Arpeggio::get_common_y (Grob *me)
@@ -96,6 +97,16 @@ Arpeggio::print (SCM smob)
   Font_metric *fm = Font_interface::get_default_font (me);
   Stencil squiggle = fm->find_by_name ("scripts.arpeggio");
 
+  /*
+    Compensate for rounding error which may occur when a chord
+    reaches the center line, resulting in an extra squiggle
+    being added to the arpeggio stencil.  This value is appreciably
+    larger than the rounding error, which is in the region of 1e-16
+    for a global-staff-size of 20, but small enough that it does not
+    interfere with smaller staff sizes.
+  */
+  const Real epsilon = 1e-3;
+
   Stencil arrow;
   if (dir)
     {
@@ -103,9 +114,10 @@ Arpeggio::print (SCM smob)
       heads[dir] -= dir * arrow.extent (Y_AXIS).length ();
     }
 
-  for (Real y = heads[LEFT]; y < heads[RIGHT];
-       y += squiggle.extent (Y_AXIS).length ())
-    mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0);
+  while (mol.extent (Y_AXIS).length () + epsilon < heads.length ())
+    {
+      mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0);
+    }
 
   mol.translate_axis (heads[LEFT], Y_AXIS);
   if (dir)
@@ -136,6 +148,28 @@ Arpeggio::brew_chord_bracket (SCM smob)
   return mol.smobbed_copy ();
 }
 
+MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_slur, 1);
+SCM
+Arpeggio::brew_chord_slur (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  Interval heads = robust_scm2interval (me->get_property ("positions"),
+                                       Interval())
+    * Staff_symbol_referencer::staff_space (me);
+
+  Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
+  Real dy = heads.length ();
+
+  Real height_limit = 1.5;
+  Real ratio = .33;
+  Bezier curve = slur_shape (dy, height_limit, ratio);
+  curve.rotate (M_PI / 2);
+
+  Stencil mol (Lookup::slur (curve, lt, lt));
+  mol.translate_axis (heads[LEFT], Y_AXIS);
+  return mol.smobbed_copy ();
+}
+
 /*
   We have to do a callback, because print () triggers a
   vertical alignment if it is cross-staff.