| [ << Tweaks and overrides ] | [Top][Contents] | [ Workaround >> ] |
| [ < Crochets de style alternatif ] | [ Up: Tweaks and overrides ] | [ Utilisation de \tweak pour retoucher des objets particuliers > ] |
Utilisation de ly:grob-object pour accéder aux grobs avec \tweak
Certains objets graphiques ne sont accessibles que par le biais d’un
callback à partir d’un autre grob. Ils sont normalement
listés dans les « layout objects » au sein de la section
« Propriétés internes » d’une grob interface. La fonction
ly:grob-object permet d’accéder à ces objets.
Voici plusieurs moyens d’accéder aux objets par un callback sur
NoteHead. D’autres biais sont naturellement possibles ;
NoteHead a cependant l’avantage incontestable d’être utilisé
implicitement par la commande \tweak.
Voici ce qui sera émis dans la console suite à la fonction
display-grobs ici construite.
-------------------- #<Grob Accidental > () #<Grob Stem >
Cette fonction n’est probablement pas très utile. Elle indique toutefois qu’il est tout à fait possible d’accéder aux objets.
#(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 }
| [ << Tweaks and overrides ] | [Top][Contents] | [ Workaround >> ] |
| [ < Crochets de style alternatif ] | [ Up: Tweaks and overrides ] | [ Utilisation de \tweak pour retoucher des objets particuliers > ] |