1 % Do not edit this file; it is automatically
2 % generated from Documentation/snippets/new
3 % This file is in the public domain.
4 %% Note: this file works from version 2.13.10
8 lsrtags = "tweaks-and-overrides"
11 Some grobs can be accessed @qq{laterally} from within another grob's
12 callback. These are usually listed as @qq{layout objects} in the
13 @qq{Internal properties} section of a grob-interface. The function
14 @code{ly:grob-object} is used to access these grobs.
17 Demonstrated below are some ways of accessing grobs from within a
18 NoteHead callback, but the technique is not limited to NoteHeads.
19 However, the NoteHead callback is particularly important, since it is
20 the implicit callback used by the @code{\\tweak} command.
23 The example function defined below (\"display-grobs\") is probably not
24 that useful, but it demonstrates that the grobs are indeed being
28 Example console output:
40 doctitle = "Using ly:grob-object to access grobs with \\tweak"
44 #(define (notehead-get-accidental notehead)
46 (ly:grob-object notehead 'accidental-grob))
48 #(define (notehead-get-arpeggio notehead)
50 (let ((notecolumn (notehead-get-notecolumn notehead)))
51 (ly:grob-object notecolumn 'arpeggio)))
53 #(define (notehead-get-notecolumn notehead)
55 (ly:grob-parent notehead X))
57 #(define (notehead-get-stem notehead)
59 (let ((notecolumn (notehead-get-notecolumn notehead)))
60 (ly:grob-object notecolumn 'stem)))
62 #(define (display-grobs notehead)
64 (let ((accidental (notehead-get-accidental notehead))
65 (arpeggio (notehead-get-arpeggio notehead))
66 (stem (notehead-get-stem notehead)))
67 (format #t "~2&~a\n" (make-string 20 #\-))
69 (lambda (x) (format #t "~a\n" x))
70 (list accidental arpeggio stem))))
73 %% display grobs for each note head:
74 %\override NoteHead #'before-line-breaking = #display-grobs
77 \tweak #'before-line-breaking #display-grobs