Hi Joe, Neil,

thanks a lot for your quick and helpful responses!

> The right place to look, therefore, is at the
> X-offset property of the Script grob, which is set in
> scm/define-grobs.scm to script-interface::calc-x-offset (which lives in
> scm/output-lib.scm).

OK, so I only need to adapt script-interface::calc-x-offset so that if
the stem and articulation have the same direction it calculates a
different horizontal shift, correct? Attached is a patch which
implements this (it took me a bit to figure out which scheme functions
yield the needed properties, but I hope I got it right - comments are
again welcome).

One Remark: I use (ly:grob-relative-coordinate stem-grob common-refp
X) to compute the relative offset of the articulation grob w.r.t. the
stem grob. I suppose that in principle this should read

  (- (ly:grob-relative-coordinate stem-grob common-refp X)
     (ly:grob-relative-coordinate grob common-refp X))

but the second number always seems to be 0 so I omitted it. Is this a
safe assumption?

> I'm fine with it applying to all articulations.

Just today I saw an example where a marcato over an up-stem half note
was _not_ shifted and I liked it better. So I'm wondering if for now
we should only implement the shifting for staccato marks until we have
better rules for other articulation types (e.g., should the shifting
depend on whether the notes are beamed or not, should it only apply to
certain note values?). I haven't included this in the patch because I
couldn't find a scheme equivalent for testing the 'articulation-type
property which Neil mentioned. Any hints?

Thanks again,
Max
From 8124af5050ceccc31c867af739d03ccc73fec4af Mon Sep 17 00:00:00 2001
From: Maximilian Albert <[EMAIL PROTECTED](none)>
Date: Tue, 2 Dec 2008 01:36:51 +0100
Subject: [PATCH] Fix for bug #218 (if articulation is over the stem, it should be centered on it)

---
 scm/output-lib.scm |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index dcb1129..5593e84 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -669,4 +669,14 @@ centered, X==1 is at the right, X == -1 is at the left."
 
 (define-public (script-interface::calc-x-offset grob)
   (ly:grob-property grob 'positioning-done)
-  (ly:self-alignment-interface::centered-on-x-parent grob))
+  (let*
+      ((note-head-grob (ly:grob-parent grob X))
+       (stem-grob (ly:grob-object note-head-grob 'stem))
+       (common-refp (ly:grob-common-refpoint grob stem-grob X))
+       (dir1 (ly:grob-property grob 'direction))
+       (dir2 (ly:grob-property stem-grob 'direction)))
+    ;; If articulation is over the stem, it should be
+    ;; centered on the latter instead of the note head
+    (if (equal? dir1 dir2)
+	(ly:grob-relative-coordinate stem-grob common-refp X)
+	(ly:self-alignment-interface::centered-on-x-parent grob))))
-- 
1.5.4.3

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to