From 304ce4dcebcef97a6cf443730265e5588a3fd365 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 2 Nov 2005 00:42:56 +0000 Subject: [PATCH] * lily/rest-collision.cc (force_shift_callback_rest): change to chained callback. * lily/rest.cc (y_offset_callback): merge function of 3 callbacks. * lily/rest.cc (polyphonic_offset_callback): remove. --- ChangeLog | 3 +++ lily/include/rest-collision.hh | 2 +- lily/rest-collision.cc | 21 ++++++++++++++------- lily/rest.cc | 16 ++++++++-------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a1be0aa19..5ebd409846 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-11-02 Han-Wen Nienhuys + * lily/rest-collision.cc (force_shift_callback_rest): change to + chained callback. + * lily/rest.cc (y_offset_callback): merge function of 3 callbacks. * lily/grob.cc (y_parent_positioning): remove axis argument from diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index 5295fd435b..ae5405d24f 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -20,7 +20,7 @@ public: static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element)); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM element)); - DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element)); + DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element, SCM off)); static SCM do_shift (Grob *); }; #endif // REST_COLLISION_HH diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 272aba6f41..e1757de1a4 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -39,16 +39,23 @@ Rest_collision::force_shift_callback (SCM smob) return scm_from_double (0.0); } -MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 1); +MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2); SCM -Rest_collision::force_shift_callback_rest (SCM rest) +Rest_collision::force_shift_callback_rest (SCM rest, SCM offset) { Grob *rest_grob = unsmob_grob (rest); Grob *parent = rest_grob->get_parent (X_AXIS); + + /* + translate REST; we need the result of this translation later on, + while the offset probably still is 0/calculation-in-progress. + */ + rest_grob->translate_axis (scm_to_double (offset), Y_AXIS); + if (Note_column::has_interface (parent)) - return force_shift_callback (parent->self_scm ()); - else - return scm_from_double (0.0); + force_shift_callback (parent->self_scm ()); + + return scm_from_double (0.0); } void @@ -68,8 +75,8 @@ Rest_collision::add_column (Grob *me, Grob *p) Grob *rest = unsmob_grob (p->get_object ("rest")); if (rest) { - rest->set_property ("Y-offset" , - Rest_collision::force_shift_callback_rest_proc); + chain_offset_callback (rest, + Rest_collision::force_shift_callback_rest_proc, Y_AXIS); } } diff --git a/lily/rest.cc b/lily/rest.cc index b362a5de03..75b610d0d2 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -23,13 +23,13 @@ Rest::y_offset_callback (SCM smob) { Grob *me = unsmob_grob (smob); int duration_log = scm_to_int (me->get_property ("duration-log")); - int lc = Staff_symbol_referencer::line_count (me); + int line_count = Staff_symbol_referencer::line_count (me); Real ss = Staff_symbol_referencer::staff_space (me); Real amount = 0.0; - if (lc % 2) + if (line_count % 2) { - if (duration_log == 0 && lc > 1) + if (duration_log == 0 && line_count > 1) amount += ss; } else @@ -58,7 +58,7 @@ Rest::y_offset_callback (SCM smob) String Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) { - bool ledgered_b = false; + bool is_ledgered = false; if (try_ledgers && (balltype == 0 || balltype == 1)) { Real rad = Staff_symbol_referencer::staff_radius (me) * 2.0; @@ -69,8 +69,8 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) could bemore generic, but hey, we understand this even after dinner. */ - ledgered_b |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad); - ledgered_b |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad); + is_ledgered |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad); + is_ledgered |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad); } String actual_style (style.to_str0 ()); @@ -84,7 +84,7 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) ledgered rests at all now that we can draw ledger lines with variable width, length and blotdiameter? -- jr */ - ledgered_b = 0; + is_ledgered = 0; /* There are no 32th/64th/128th mensural/neomensural rests. In @@ -112,7 +112,7 @@ Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers) actual_style = ""; } - return ("rests." + to_string (balltype) + (ledgered_b ? "o" : "") + return ("rests." + to_string (balltype) + (is_ledgered ? "o" : "") + actual_style); } -- 2.39.2