From e2b9e9143647431111ef8fa7262982d88b26830b Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Sat, 17 May 2008 18:40:08 +1000 Subject: [PATCH] Fix 622. Add a cross-staff property to rests. --- lily/include/rest.hh | 1 + lily/rest.cc | 16 ++++++++++++++++ scm/define-grobs.scm | 1 + 3 files changed, 18 insertions(+) diff --git a/lily/include/rest.hh b/lily/include/rest.hh index ed67c63107..96c2b44cc7 100644 --- a/lily/include/rest.hh +++ b/lily/include/rest.hh @@ -17,6 +17,7 @@ class Rest { public: DECLARE_SCHEME_CALLBACK (y_offset_callback, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); DECLARE_GROB_INTERFACE(); static string glyph_name (Grob *, int, string, bool); static SCM brew_internal_stencil (Grob*, bool); diff --git a/lily/rest.cc b/lily/rest.cc index 1abb770d7b..22420f54f4 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -46,6 +46,22 @@ Rest::y_offset_callback (SCM smob) return scm_from_double (amount); } +/* A rest might lie under a beam, in which case it should be cross-staff if + the beam is cross-staff because the rest's position depends on the + formatting of the beam. */ +MAKE_SCHEME_CALLBACK (Rest, calc_cross_staff, 1); +SCM +Rest::calc_cross_staff (SCM smob) +{ + Grob *me = unsmob_grob (smob); + Grob *stem = unsmob_grob (me->get_object ("stem")); + + if (!stem) + return SCM_BOOL_F; + + return stem->get_property ("cross-staff"); +} + /* make this function easily usable in C++ */ diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 94e30465e9..956a8e0045 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1416,6 +1416,7 @@ (Y-extent . ,ly:rest::height) (Y-offset . ,ly:rest::y-offset-callback) (minimum-distance . 0.25) + (cross-staff . ,ly:rest::calc-cross-staff) (meta . ((class . Item) (interfaces . (font-interface rhythmic-head-interface -- 2.39.2