From 4ed1fc73b3949bceb6d6cfb973d6f9e6ab0bb9ba Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 4 Jul 2008 09:50:48 +0300 Subject: [PATCH] Fix beaming problems with cross-staff beams and slurs. Mark as cross-staff any grob that is outside or around a cross-staff slur. --- lily/grob-closure.cc | 12 +++++++++--- lily/include/grob.hh | 1 + lily/include/slur.hh | 1 + lily/slur.cc | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lily/grob-closure.cc b/lily/grob-closure.cc index b2d0160ada..124d143793 100644 --- a/lily/grob-closure.cc +++ b/lily/grob-closure.cc @@ -67,9 +67,9 @@ add_offset_callback (Grob *g, SCM proc, Axis a) */ void -chain_offset_callback (Grob *g, SCM proc, Axis a) +chain_callback (Grob *g, SCM proc, SCM sym) { - SCM data = g->get_property_data (axis_offset_symbol (a)); + SCM data = g->get_property_data (sym); if (ly_is_procedure (data)) data = ly_make_simple_closure (scm_list_1 (data)); @@ -84,9 +84,15 @@ chain_offset_callback (Grob *g, SCM proc, Axis a) data = SCM_UNDEFINED; SCM expr = scm_list_2 (proc, data); - g->set_property (axis_offset_symbol (a), + g->set_property (sym, // twice: one as a wrapper for grob property routines, // once for the actual delayed binding. ly_make_simple_closure (ly_make_simple_closure (expr))); } + +void +chain_offset_callback (Grob *g, SCM proc, Axis a) +{ + chain_callback (g, proc, axis_offset_symbol (a)); +} diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 82591eb7c3..f0191e3e44 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -146,6 +146,7 @@ Interval robust_relative_extent (Grob *, Grob *, Axis); /* offset/extent callbacks. */ void add_offset_callback (Grob *g, SCM proc, Axis a); void chain_offset_callback (Grob *g, SCM proc, Axis a); +void chain_callback (Grob *g, SCM proc, SCM sym); SCM axis_offset_symbol (Axis a); SCM axis_parent_positioning (Axis a); diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 3680c73749..5059bdff96 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -27,6 +27,7 @@ public: DECLARE_SCHEME_CALLBACK (height, (SCM)); DECLARE_SCHEME_CALLBACK (outside_slur_callback, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (pure_outside_slur_callback, (SCM, SCM, SCM, SCM)); + DECLARE_SCHEME_CALLBACK (outside_slur_cross_staff, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); DECLARE_GROB_INTERFACE(); static Bezier get_curve (Grob *me); diff --git a/lily/slur.cc b/lily/slur.cc index 3d47e876fc..faa40725ad 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -349,6 +349,7 @@ Slur::auxiliary_acknowledge_extra_object (Grob_info const &info, if (slur) { chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS); + chain_callback (e, outside_slur_cross_staff_proc, ly_symbol2scm("cross-staff")); e->set_object ("slur", slur->self_scm ()); } } @@ -357,6 +358,27 @@ Slur::auxiliary_acknowledge_extra_object (Grob_info const &info, e->name().c_str ())); } +/* + A callback that will be chained together with the original cross-staff + value of a grob that is placed 'outside or 'around a slur. This just says + that any grob becomes cross-staff if it is placed 'outside or 'around a + cross-staff slur. +*/ +MAKE_SCHEME_CALLBACK (Slur, outside_slur_cross_staff, 2) +SCM +Slur::outside_slur_cross_staff (SCM smob, SCM previous) +{ + if (previous == SCM_BOOL_T) + return previous; + + Grob *me = unsmob_grob (smob); + Grob *slur = unsmob_grob (me->get_object ("slur")); + + if (!slur) + return SCM_BOOL_F; + return slur->get_property ("cross-staff"); +} + MAKE_SCHEME_CALLBACK (Slur, calc_cross_staff, 1) SCM Slur::calc_cross_staff (SCM smob) -- 2.39.2