]> git.donarmstrong.com Git - lilypond.git/commitdiff
Correctly determines if glissandi are cross-staff
authorMike Solomon <mike@apollinemike.com>
Wed, 15 Feb 2012 07:12:03 +0000 (08:12 +0100)
committerMike Solomon <mike@apollinemike.com>
Wed, 15 Feb 2012 07:12:03 +0000 (08:12 +0100)
input/regression/glissando-cross-staff.ly [new file with mode: 0644]
lily/line-spanner.cc
scm/define-grobs.scm

diff --git a/input/regression/glissando-cross-staff.ly b/input/regression/glissando-cross-staff.ly
new file mode 100644 (file)
index 0000000..2e687e6
--- /dev/null
@@ -0,0 +1,20 @@
+\version "2.15.29"
+\header {
+  texidoc = "Cross staff glissandi reach their endpoints correctly.
+"
+}
+
+\new PianoStaff <<
+\new Staff = "right" {
+  e'''2\glissando
+  \change Staff = "left"
+
+  a,,\glissando
+  \change Staff = "right"
+  b''8
+}
+\new Staff = "left" {
+  \clef bass
+  s1 s8
+}
+>>
index 63970467268b6432948ef2c0fdaded5401e3675b..028fe20e155d5db5ad46ec5624fa6baab3a2f406 100644 (file)
@@ -38,6 +38,7 @@ class Line_spanner
 {
 public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_left_bound_info, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_left_bound_info_and_text, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_right_bound_info, (SCM));
@@ -200,6 +201,22 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir)
   return details;
 }
 
+MAKE_SCHEME_CALLBACK (Line_spanner, calc_cross_staff, 1);
+SCM
+Line_spanner::calc_cross_staff (SCM smob)
+{
+  Spanner *me = unsmob_spanner (smob);
+  if (!me)
+    return SCM_BOOL_F;
+
+  if (to_boolean (me->get_bound (LEFT)->get_property ("non-musical"))
+      || to_boolean (me->get_bound (RIGHT)->get_property ("non-musical")))
+    return SCM_BOOL_F;
+
+  return scm_from_bool (Staff_symbol_referencer::get_staff_symbol (me->get_bound (LEFT))
+                        != Staff_symbol_referencer::get_staff_symbol (me->get_bound (RIGHT)));
+}
+
 MAKE_SCHEME_CALLBACK (Line_spanner, calc_right_bound_info, 1);
 SCM
 Line_spanner::calc_right_bound_info (SCM smob)
index 1b9507a0b882bf84a6ab0a90a79b2a6d714cd80c..44130334346af5416004a06ac39d5a5d7afce624 100644 (file)
                                   (padding . 0.5)
                                      ))
                          ))
+       (cross-staff . ,ly:line-spanner::calc-cross-staff)
        (gap . 0.5)
        (left-bound-info . ,ly:line-spanner::calc-left-bound-info)
        (normalized-endpoints . ,ly:spanner::calc-normalized-endpoints)