]> git.donarmstrong.com Git - lilypond.git/commitdiff
New grob-property 'shifted-towards-stem (allows scripts to be placed anywhere between...
authorMaximilian Albert <cilix@dike.(none)>
Fri, 12 Dec 2008 23:52:27 +0000 (00:52 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Thu, 18 Dec 2008 21:35:02 +0000 (21:35 +0000)
lily/script-interface.cc
scm/define-grob-properties.scm
scm/output-lib.scm
scm/script.scm

index a525500b2c39a76aae127fa89b6561fe04cba539..af2b8f934dbba0e6e4549537c8a3befc5df2ffbd 100644 (file)
@@ -129,6 +129,7 @@ ADD_INTERFACE (Script_interface,
               "positioning-done "
               "script-priority "
               "script-stencil "
+              "toward-stem-shift "
               "slur "
               "slur-padding "
               );
index 9d902ad713a0e6bf261cade7c9ceccc208c2bdef..00cb1ebcf6f1f472bc27d8b0342b4b86badbc4b5 100644 (file)
@@ -554,6 +554,10 @@ value @code{-1} means left aligned, @code{0}@tie{}centered, and
 values may also be specified.")
      (self-alignment-Y ,number? "Like @code{self-alignment-X} but for
 the Y@tie{}axis.")
+     (toward-stem-shift ,number? "Amount by which scripts are shifted
+toward the stem if their direction coincides with the stem direction.
+@code{0.0} means keep the default position (centered on the note head),
+@code{1.0} means centered on the stem.  Interpolated values are possible.")
      (shorten-pair ,number-pair? "The lengths to shorten a
 text-spanner on both sides, for example a pedal bracket.  Positive
 values shorten the text-spanner, while negative values lengthen it.")
index 9b813a55665a6507c855a89318290df1c0523597..6a547776b5ac6c394e42b7d0a389c06fab935bad 100644 (file)
@@ -670,4 +670,21 @@ 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* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
+        (note-head-location (ly:self-alignment-interface::centered-on-x-parent grob))
+        (note-head-grob (ly:grob-parent grob X))
+        (stem-grob (ly:grob-object note-head-grob 'stem)))
+    (+ note-head-location
+       ;; If the property 'toward-stem-shift is defined and the script has the
+       ;; same direction as the stem, move the script accordingly. Since scripts can
+       ;; also be over skips, we need to check whether the grob has a stem at all.
+       (if (ly:grob? stem-grob)
+          (let ((dir1 (ly:grob-property grob 'direction))
+                (dir2 (ly:grob-property stem-grob 'direction)))
+            (if (equal? dir1 dir2)
+                (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
+                       (stem-location (ly:grob-relative-coordinate stem-grob common-refp X)))
+                  (* shift (- stem-location
+                              note-head-location)))
+                0.0))
+          0.0))))
index eb2fad500a70b8f6763d57bf5125c0ffdc0c77a6..5e2a2a9ca066c34b56f21583aac99302334f7adb 100644 (file)
       (side-relative-direction .  -1)
       (quantize-position . #t)
       (avoid-slur . inside) 
+      (toward-stem-shift . 0.5)
       (padding . 0.20)    
       (script-priority . -100)))
     ("tenuto" .