LSR: Redo local update.
[lilypond/mpolesky.git] / Documentation / snippets / new / using-ly-grob-object-to-access-grobs-with--tweak.ly
blob2fcb3602725184b3393192f9380c906d377009cb
1 \version "2.13.10"
3 \header {
4 lsrtags = "tweaks-and-overrides"
6 texidoc = "
7 Some grobs can be accessed @qq{laterally} from within another grob's
8 callback. These are usually listed as @qq{layout objects} in the
9 @qq{Internal properties} section of a grob-interface. The function
10 @code{ly:grob-object} is used to access these grobs.
13 Demonstrated below are some ways of accessing grobs from within a
14 NoteHead callback, but the technique is not limited to NoteHeads.
15 However, the NoteHead callback is particularly important, since it is
16 the implicit callback used by the @code{\\tweak} command.
19 The example function defined below (\"display-grobs\") is probably not
20 that useful, but it demonstrates that the grobs are indeed being
21 accessed.
24 Example console output:
27 @example
28 --------------------
29 #-Grob Accidental -
30 #-Grob Arpeggio -
31 #-Grob Stem -
32 @end example
36 doctitle = "Using ly:grob-object to access grobs with \\tweak"
39 #(define (notehead-get-accidental notehead)
40 ;; notehead is grob
41 (ly:grob-object notehead 'accidental-grob))
43 #(define (notehead-get-arpeggio notehead)
44 ;; notehead is grob
45 (let ((notecolumn (notehead-get-notecolumn notehead)))
46 (ly:grob-object notecolumn 'arpeggio)))
48 #(define (notehead-get-notecolumn notehead)
49 ;; notehead is grob
50 (ly:grob-parent notehead X))
52 #(define (notehead-get-stem notehead)
53 ;; notehead is grob
54 (let ((notecolumn (notehead-get-notecolumn notehead)))
55 (ly:grob-object notecolumn 'stem)))
57 #(define (display-grobs notehead)
58 ;; notehead is grob
59 (let ((accidental (notehead-get-accidental notehead))
60 (arpeggio (notehead-get-arpeggio notehead))
61 (stem (notehead-get-stem notehead)))
62 (format #t "~2&~a\n" (make-string 20 #\-))
63 (for-each
64 (lambda (x) (format #t "~a\n" x))
65 (list accidental arpeggio stem))))
67 \relative c' {
68 %% display grobs for each note head:
69 %\override NoteHead #'before-line-breaking = #display-grobs
71 %% or just for one:
72 \tweak #'before-line-breaking #display-grobs
74 g>1\arpeggio