/*
- arpeggio.cc -- implement Arpeggio
+ This file is part of LilyPond, the GNU music typesetter.
- source file of the GNU LilyPond music typesetter
+ Copyright (C) 2000--2009 Jan Nieuwenhuizen <janneke@gnu.org>
- (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#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)
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)
{
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)
return mol.smobbed_copy ();
}
+MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_slur, 1);
+SCM
+Arpeggio::brew_chord_slur (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ SCM dash_definition = me->get_property ("dash-definition");
+ 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, dash_definition));
+ 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.
return ly_interval2scm (arpeggio.extent (X_AXIS));
}
-MAKE_SCHEME_CALLBACK (Arpeggio, height, 1);
-SCM
-Arpeggio::height (SCM smob)
-{
- return Grob::stencil_height (smob);
-}
-
MAKE_SCHEME_CALLBACK (Arpeggio, pure_height, 3);
SCM
Arpeggio::pure_height (SCM smob, SCM, SCM)
if (to_boolean (me->get_property ("cross-staff")))
return ly_interval2scm (Interval ());
- return height (smob);
+ return Grob::stencil_height (smob);
}
ADD_INTERFACE (Arpeggio,
- "Functions and settings for drawing an arpeggio symbol (a"
- " wavy line left to noteheads.",
+ "Functions and settings for drawing an arpeggio symbol.",
/* properties */
"arpeggio-direction "
"positions "
"script-priority " // TODO: make around-note-interface
"stems "
+ "dash-definition " // TODO: make apply to non-slur arpeggios
);