From 0c849c547f242e3aa64032d15b9211a579b75faf Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Tue, 27 Aug 2013 08:44:23 +0300 Subject: [PATCH] Creates cross-staff callback for arpeggios (issue 3497) This avoids setting cross-staff to #t at the engraver stage, which results in the erroneous labelling certain span-arpeggios as cross-staff. --- .../arpeggio-span-one-staff-collision.ly | 23 +++++++++++++++++++ lily/arpeggio.cc | 23 +++++++++++++++++++ lily/include/arpeggio.hh | 1 + lily/span-arpeggio-engraver.cc | 6 ++--- scm/define-grobs.scm | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 input/regression/arpeggio-span-one-staff-collision.ly diff --git a/input/regression/arpeggio-span-one-staff-collision.ly b/input/regression/arpeggio-span-one-staff-collision.ly new file mode 100644 index 0000000000..d5ba546c56 --- /dev/null +++ b/input/regression/arpeggio-span-one-staff-collision.ly @@ -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. 4\arpeggio |} + \\ + {\repeat unfold 12 aes,16 4\arpeggio |} + >> +} diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index fa53ff2611..018d9cd22d 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -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) diff --git a/lily/include/arpeggio.hh b/lily/include/arpeggio.hh index a03beaa7a8..1347219812 100644 --- a/lily/include/arpeggio.hh +++ b/lily/include/arpeggio.hh @@ -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)); diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index 049f4f2d65..f68f904d56 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -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++) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 86bf7c15a9..d59ad58617 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -166,6 +166,7 @@ (Arpeggio . ( + (cross-staff . ,ly:arpeggio::calc-cross-staff) (direction . ,LEFT) (padding . 0.5) (positions . ,ly:arpeggio::calc-positions) -- 2.39.2