From 2ce49b0f44b390c7670c049c2dcdce8449d0521d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 6 Jan 2007 23:32:21 +0100 Subject: [PATCH] Fix #223. Set a callback for Dots #'staff-position, depending on duration-log of the rest. This fixes the longest standing regression in Lily as yet, as this did work in Lily 2.0. --- lily/dot-column-engraver.cc | 2 -- lily/dot-column.cc | 4 ++++ lily/dots.cc | 1 - lily/rest.cc | 12 ------------ scm/define-grobs.scm | 1 + scm/output-lib.scm | 15 +++++++++++++++ 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index ede002049f..620328ed33 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -16,7 +16,6 @@ class Dot_column_engraver : public Engraver { Grob *dotcol_; - vector heads_; public: TRANSLATOR_DECLARATIONS (Dot_column_engraver); @@ -36,7 +35,6 @@ void Dot_column_engraver::stop_translation_timestep () { dotcol_ = 0; - heads_.clear (); } void diff --git a/lily/dot-column.cc b/lily/dot-column.cc index a07dfcde11..6e967f3489 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -256,6 +256,10 @@ Dot_column::calc_positioning_done (SCM smob) } int p = Staff_symbol_referencer::get_rounded_position (dp.dot_); + + /* icky, since this should go via a Staff_symbol_referencer + offset callback but adding a dot overwrites Y-offset. */ + p += (int) robust_scm2double (dp.dot_->get_property ("staff-position"), 0.0); dp.pos_ = p; if (dp.extremal_head_) diff --git a/lily/dots.cc b/lily/dots.cc index afa82868a8..ed2d8d5636 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -13,7 +13,6 @@ #include "font-interface.hh" #include "lookup.hh" #include "staff-symbol-referencer.hh" -#include "directional-element-interface.hh" #include "international.hh" MAKE_SCHEME_CALLBACK (Dots, print, 1); diff --git a/lily/rest.cc b/lily/rest.cc index 64a3eb87cd..61dd18b6c7 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -40,18 +40,6 @@ Rest::y_offset_callback (SCM smob) else amount += ss / 2; - Grob *dot = unsmob_grob (me->get_object ("dot")); - if (dot && duration_log > 4) // UGH. - { - dot->set_property ("staff-position", - scm_from_int ((duration_log == 7) ? 4 : 3)); - } - if (dot && duration_log >= -1 && duration_log <= 1) // UGH again. - { - dot->set_property ("staff-position", - scm_from_int ((duration_log == 0) ? -1 : 1)); - } - if (!position_override) amount += 2 * ss * get_grob_direction (me);; diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 4d06aa3a03..35ed147712 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -548,6 +548,7 @@ . ( (stencil . ,ly:dots::print) (dot-count . ,dots::calc-dot-count) + (staff-position . ,dots::calc-staff-position) (meta . ((class . Item) (interfaces . (font-interface staff-symbol-referencer-interface diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 19f3c61345..f66a78bcbc 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -135,6 +135,21 @@ (ly:duration-dot-count (ly:event-property (event-cause grob) 'duration))) +(define-public (dots::calc-staff-position grob) + (let* + ((head (ly:grob-parent grob Y)) + (log (ly:grob-property head 'duration-log))) + + (cond + ((or (not (grob::has-interface head 'rest-interface)) + (not (integer? log))) 0) + ((= log 7) 4) + ((> log 4) 3) + ((= log 0) -1) + ((= log 1) 1) + ((= log -1) 1) + (else 0)))) + (define (note-head::calc-tablature-stem-attachment grob) (cons 0.0 1.35)) -- 2.39.5