Utilizar ly:grob-object para acceder a los grobs con \tweak
Se puede acceder “lateralmente” a algunos grobs desde dentro de
la función de callback de otro grob. Éstos se encuentran
relacionados normalmente como “layout objects” (objetos de
presentación) en la sección “Internal properties” (propiedades
internas) de un interface de grob. Se usa la función
ly:grob-object para acceder a estos grobs.
Se presentan más abajo como ejemplo algunas formas de addecer a
grobs desde dentro de una función de callback de NoteHead,
pero la técnica no se limita a las cabezas de nota. Sin embargo,
la función de callback de NoteHead es especialmente
importante, porque es la función de callback implícita que utiliza
la instrucción \tweak.
La salida de consola de la función de ejemplo que se muestra abajo
(display-grobs) es como sigue.
-------------------- #<Grob Accidental > () #<Grob Stem >
Probablemente no es tan útil, pero muestra que efectivamente se puede acceder a los objetos gráficos.
#(define (notehead-get-accidental notehead) ;; notehead is grob (ly:grob-object notehead 'accidental-grob)) #(define (notehead-get-arpeggio notehead) ;; notehead is grob (let ((notecolumn (notehead-get-notecolumn notehead))) (ly:grob-object notecolumn 'arpeggio))) #(define (notehead-get-notecolumn notehead) ;; notehead is grob (ly:grob-parent notehead X)) #(define (notehead-get-stem notehead) ;; notehead is grob (let ((notecolumn (notehead-get-notecolumn notehead))) (ly:grob-object notecolumn 'stem))) #(define (display-grobs notehead) ;; notehead is grob (let ((accidental (notehead-get-accidental notehead)) (arpeggio (notehead-get-arpeggio notehead)) (stem (notehead-get-stem notehead))) (format (current-error-port) "~2&~a\n" (make-string 20 #\-)) (for-each (lambda (x) (format (current-error-port) "~a\n" x)) (list accidental arpeggio stem)))) \relative c' { %% display grobs for each note head: %\override NoteHead.before-line-breaking = #display-grobs <c %% or just for one: \tweak before-line-breaking #display-grobs es g>1\arpeggio }