]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/snippets/centering-markup-on-note-heads-automatically.ly
Local updates from LSR
[lilypond.git] / Documentation / snippets / centering-markup-on-note-heads-automatically.ly
index ce227d016e6e8db91ea27efda9f4283d922dfb65..ff1a10b22956a7c994da5951caefdefa693592ed 100644 (file)
@@ -4,10 +4,24 @@
 % and then run scripts/auxiliar/makelsr.py
 %
 % This file is in the public domain.
-%% Note: this file works from version 2.14.0
-\version "2.14.0"
+%% Note: this file works from version 2.15.31
+\version "2.15.31"
 
 \header {
+%% Translation of GIT committish: 1cda7b7b8219cb97399b8e7b56c1115aaf82c002
+  texidocfr = "
+Des raisons techniques sont à l'origine de la difficulté de centrer des
+scripts textuels attachés à des têtes de note, ce qui n'est pas le cas
+des articulations.
+
+Plutôt que de procéder par tâtonnement, voici comment élaborer un
+graveur en Scheme, chargé de redéfinir le parent horizontal de chaque
+@emph{markup} sur un empilement de notes (un @code{NoteColumn}).  Il
+permet aussi au texte de suivre les têtes ayant été décalées par un
+@code{force-hshift}.
+"
+  doctitlefr = "Centrage automatique d'un @emph{markup} sur la tête de note"
+
   lsrtags = "text, tweaks-and-overrides, contexts-and-engravers"
   texidoc = "
 For technical reasons, text scripts attached to note heads cannot
@@ -25,29 +39,23 @@ been shifted via @code{force-hshift}.
 #(define (Text_align_engraver ctx)
   (let ((scripts '())
         (note-column #f))
-
-    `((acknowledgers
-       (note-column-interface
-        . ,(lambda (trans grob source)
-             ;; cache NoteColumn in this Voice context
-             (set! note-column grob)))
-
-       (text-script-interface
-        . ,(lambda (trans grob source)
-             ;; whenever a TextScript is acknowledged,
-             ;; add it to `scripts' list
-             (set! scripts (cons grob scripts)))))
-
-      (stop-translation-timestep
-       . ,(lambda (trans)
-            ;; if any TextScript grobs exist,
-            ;; set NoteColumn as X-parent
-            (and (pair? scripts)
-                 (for-each (lambda (script)
-                             (set! (ly:grob-parent script X) note-column))
-                           scripts))
-            ;; clear scripts ready for next timestep
-            (set! scripts '()))))))
+    (make-engraver
+     (acknowledgers
+      ((note-column-interface trans grob source)
+       ;; cache NoteColumn in this Voice context
+       (set! note-column grob))
+      ((text-script-interface trans grob source)
+       ;; whenever a TextScript is acknowledged,
+       ;; add it to `scripts' list
+       (set! scripts (cons grob scripts))))
+     ((stop-translation-timestep trans)
+      ;; if any TextScript grobs exist,
+      ;; set NoteColumn as X-parent
+      (for-each (lambda (script)
+                 (set! (ly:grob-parent script X) note-column))
+               scripts)
+      ;; clear scripts ready for next timestep
+      (set! scripts '())))))
 
 \layout {
   \context {