1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
6 %% This file is in the public domain.
10 lsrtags = "devel, scheme-language, tweaks-and-overrides"
13 Some grobs can be accessed “laterally” from within another grob’s
14 callback. These are usually listed as “layout objects” in the “Internal
15 properties” section of a grob-interface. The function ly:grob-object is
16 used to access these grobs.
19 Demonstrated below are some ways of accessing grobs from within a
20 NoteHead callback, but the technique is not limited to NoteHeads.
21 However, the NoteHead callback is particularly important, since it is
22 the implicit callback used by the @code{\\tweak} command.
25 The example function defined below (\"display-grobs\") is probably not
26 that useful, but it demonstrates that the grobs are indeed being
30 Example console output:
33 @code{ #Grob Accidental () #Grob Stem}
38 doctitle = "Using ly:grob-object to access grobs with \\tweak"
41 #(define (notehead-get-accidental notehead)
43 (ly:grob-object notehead 'accidental-grob))
45 #(define (notehead-get-arpeggio notehead)
47 (let ((notecolumn (notehead-get-notecolumn notehead)))
48 (ly:grob-object notecolumn 'arpeggio)))
50 #(define (notehead-get-notecolumn notehead)
52 (ly:grob-parent notehead X))
54 #(define (notehead-get-stem notehead)
56 (let ((notecolumn (notehead-get-notecolumn notehead)))
57 (ly:grob-object notecolumn 'stem)))
59 #(define (display-grobs notehead)
61 (let ((accidental (notehead-get-accidental notehead))
62 (arpeggio (notehead-get-arpeggio notehead))
63 (stem (notehead-get-stem notehead)))
64 (format (current-error-port) "~2&~a\n" (make-string 20 #\-))
66 (lambda (x) (format (current-error-port) "~a\n" x))
67 (list accidental arpeggio stem))))
70 %% display grobs for each note head:
71 %\override NoteHead.before-line-breaking = #display-grobs
74 \tweak before-line-breaking #display-grobs