]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/snippets/new/defining-an-engraver-in-scheme--ambitus-engraver.ly
Imported Upstream version 2.19.45
[lilypond.git] / Documentation / snippets / new / defining-an-engraver-in-scheme--ambitus-engraver.ly
index 84642a20da45a56d535e4af283b7717711ad7061..cb19340ca91eca6fb4f729d24e60d17b74aaf11e 100644 (file)
@@ -1,20 +1,18 @@
-\version "2.16.0"
+\version "2.19.28"
 
 \header {
-
   lsrtags = "contexts-and-engravers"
 
+  texidoc = "
+This example demonstrates how the ambitus engraver may be defined on
+the user side, with a Scheme engraver.
 
-  texidoc = "This example demonstrates how the ambitus engraver may be
-  defined on the user side, with a Scheme engraver.
+This is basically a rewrite in Scheme of the code from
+@code{lily/ambitus-engraver.cc}.
 
-  This is basically a rewrite in Scheme of the code from
-  @file{lily/ambitus-engraver.cc}.
 "
-
   doctitle = "Defining an engraver in Scheme: ambitus engraver"
 }
-
 #(use-modules (oop goops))
 
 %%%
@@ -40,8 +38,6 @@ grob.
 Rewrite of @code{Accidental_placement::add_accidental} from @file{lily/accidental-placement.cc}."
    (let ((pitch (ly:accidental-placement::accidental-pitch accidental-grob)))
      (set! (ly:grob-parent accidental-grob X) grob)
-     (set! (ly:grob-property accidental-grob 'X-offset)
-           ly:grob::x-parent-positioning)
      (let* ((accidentals (ly:grob-object grob 'accidental-grobs))
             (handle (assq (ly:pitch-notename pitch) accidentals))
             (entry (if handle (cdr handle) '())))
@@ -176,7 +172,7 @@ position of middle C and key signature from @var{translator}'s context."
                                     0))
          (set! (ambitus-start-key-sig ambitus)
                (ly:context-property (ly:translator-context translator)
-                                    'keySignature)))))
+                                    'keyAlterations)))))
 
 #(define-method (update-ambitus-notes (ambitus <ambitus>) note-grob)
    "Update the upper and lower ambitus pithes of @var{ambitus}, using
@@ -289,23 +285,23 @@ position of middle C and key signature from @var{translator}'s context."
      (let ((ambitus #f))
        ;; when music is processed: make the ambitus object, if not already built
        (make-engraver
-       ((process-music translator)
-        (if (not ambitus)
-            (set! ambitus (make-ambitus translator))))
-       ;; set the ambitus clef and key signature state
-       ((stop-translation-timestep translator)
-        (if ambitus
-            (initialize-ambitus-state ambitus translator)))
-       ;; when a note-head grob is built, update the ambitus notes
-       (acknowledgers
+    ((process-music translator)
+     (if (not ambitus)
+         (set! ambitus (make-ambitus translator))))
+    ;; set the ambitus clef and key signature state
+    ((stop-translation-timestep translator)
+     (if ambitus
+         (initialize-ambitus-state ambitus translator)))
+    ;; when a note-head grob is built, update the ambitus notes
+    (acknowledgers
           ((note-head-interface engraver grob source-engraver)
-          (if ambitus
-              (update-ambitus-notes ambitus grob))))
-       ;; finally, typeset the ambitus according to its upper and lower notes
-       ;; (if any).
-       ((finalize translator)
-        (if ambitus
-            (typeset-ambitus ambitus translator)))))))
+       (if ambitus
+           (update-ambitus-notes ambitus grob))))
+    ;; finally, typeset the ambitus according to its upper and lower notes
+    ;; (if any).
+    ((finalize translator)
+     (if ambitus
+         (typeset-ambitus ambitus translator)))))))
 
 %%%
 %%% Example