]> git.donarmstrong.com Git - lilypond.git/commitdiff
Creates cross-staff callback for arpeggios (issue 3497)
authorMike Solomon <mike@mikesolomon.org>
Tue, 27 Aug 2013 05:44:23 +0000 (08:44 +0300)
committerMike Solomon <mike@mikesolomon.org>
Tue, 27 Aug 2013 05:44:23 +0000 (08:44 +0300)
This avoids setting cross-staff to #t at the engraver stage, which
results in the erroneous labelling certain span-arpeggios as cross-staff.

input/regression/arpeggio-span-one-staff-collision.ly [new file with mode: 0644]
lily/arpeggio.cc
lily/include/arpeggio.hh
lily/span-arpeggio-engraver.cc
scm/define-grobs.scm

diff --git a/input/regression/arpeggio-span-one-staff-collision.ly b/input/regression/arpeggio-span-one-staff-collision.ly
new file mode 100644 (file)
index 0000000..d5ba546
--- /dev/null
@@ -0,0 +1,23 @@
+\version "2.17.26"
+
+\header {
+  texidoc = "Span arpeggios that are not cross-staff do not have
+horizontal spacing problems.
+"
+}
+
+
+\new Staff
+\with
+{
+  \consists "Span_arpeggio_engraver"
+}
+\relative c''
+{
+  \set Staff.connectArpeggios = ##t
+  <<
+    {r2. <ges aes c ges'>4\arpeggio |}
+    \\
+    {\repeat unfold 12 aes,16 <ees aes c>4\arpeggio |}
+  >>
+}
index fa53ff261126b788d2a04a336fb0930d889e4053..018d9cd22df116282bbaff4ef63d62355ebeb195 100644 (file)
@@ -56,6 +56,29 @@ Arpeggio::get_common_y (Grob *me)
   return common;
 }
 
+MAKE_SCHEME_CALLBACK (Arpeggio, calc_cross_staff, 1);
+SCM
+Arpeggio::calc_cross_staff (SCM grob)
+{
+  Grob *me = unsmob_grob (grob);
+
+  extract_grob_set (me, "stems", stems);
+  Grob *vag = 0;
+
+  for (vsize i = 0; i < stems.size (); i++)
+    {
+      if (!i)
+        vag = Grob::get_vertical_axis_group (stems[i]);
+      else
+        {
+          if (vag != Grob::get_vertical_axis_group (stems[i]))
+            return SCM_BOOL_T;
+        }
+    }
+
+  return SCM_BOOL_F;
+}
+
 MAKE_SCHEME_CALLBACK (Arpeggio, calc_positions, 1);
 SCM
 Arpeggio::calc_positions (SCM grob)
index a03beaa7a815e1f776744f827829a55675b8d270..1347219812cef80a9cf5bdb7235d6e28909eec67 100644 (file)
@@ -29,6 +29,7 @@ public:
   static Grob *get_common_y (Grob *);
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
   DECLARE_SCHEME_CALLBACK (brew_chord_bracket, (SCM));
   DECLARE_SCHEME_CALLBACK (brew_chord_slur, (SCM));
   DECLARE_SCHEME_CALLBACK (width, (SCM));
index 049f4f2d65fbc13df23c9ace32b684c99537532c..f68f904d56746503c15e36f20ae5dd325f1d4d78 100644 (file)
@@ -78,10 +78,8 @@ Span_arpeggio_engraver::process_acknowledged ()
   */
   if (!span_arpeggio_ && arpeggios_.size () > 1
       && to_boolean (get_property ("connectArpeggios")))
-    {
-      span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
-      span_arpeggio_->set_property ("cross-staff", SCM_BOOL_T);
-    }
+    span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
+
   if (span_arpeggio_)
     {
       for (vsize i = 0; i < note_columns_.size (); i++)
index 86bf7c15a931d0b045cf088f3b8b8a015c99dc7f..d59ad586170aabfa222a26d47b0bbe93fbf363b8 100644 (file)
 
     (Arpeggio
      . (
+       (cross-staff . ,ly:arpeggio::calc-cross-staff)
         (direction . ,LEFT)
         (padding . 0.5)
         (positions . ,ly:arpeggio::calc-positions)