]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/using-ly-grob-object-to-access-grobs-with--tweak.ly
Docs: run convert-ly for 2.14.0.
[lilypond.git] / Documentation / snippets / using-ly-grob-object-to-access-grobs-with--tweak.ly
1 % DO NOT EDIT this file manually; it is automatically
2 % generated from Documentation/snippets/new
3 % Make any changes in Documentation/snippets/new/
4 % and then run scripts/auxiliar/makelsr.py
5 %
6 % This file is in the public domain.
7 %% Note: this file works from version 2.13.36
8 \version "2.14.0"
9
10 \header {
11 %% Translation of GIT committish: 59caa3adce63114ca7972d18f95d4aadc528ec3d
12
13   texidoces = "
14
15 Se puede acceder @qq{lateralmente} a algunos grobs desde dentro de la
16 función de callback de otro grob.  Éstos se encuentran relacionados
17 normalmente como @qq{layout objects} (objetos de presentación) en la
18 sección @qq{Internal properties} (propiedades internas) de un
19 interface de grob.  Se usa la función @code{ly:grob-object} para
20 acceder a estos grobs.
21
22
23 Se presentan más abajo como ejemplo algunas formas de addecer a grobs
24 desde dentro de una función de callback de NoteHead, pero la técnica
25 no se limita a las cabezas de nota.  Sin embargo, la función de
26 callback de NoteHead es especialmente importante, porque es la función
27 de callback implícita que utiliza la instrucción @code{\\tweak}.
28
29
30 La función de ejemplo que se define abajo (\"display-grobs\") no es
31 probablemente tan útil, pero muestra que se está accediendo
32 efectivamente a los grobs.
33
34
35 Salida de ejemplo de la consola:
36
37
38 @example
39 --------------------
40 #-Grob Accidental -
41 #-Grob Arpeggio -
42 #-Grob Stem -
43 @end example
44
45
46 "
47
48   doctitlees = "Utilizar ly:grob-object para acceder a los grobs con \\tweak"
49
50
51   lsrtags = "tweaks-and-overrides"
52
53   texidoc = "
54 Some grobs can be accessed @qq{laterally} from within another grob's
55 callback.  These are usually listed as @qq{layout objects} in the
56 @qq{Internal properties} section of a grob-interface.  The function
57 @code{ly:grob-object} is used to access these grobs.
58
59
60 Demonstrated below are some ways of accessing grobs from within a
61 NoteHead callback, but the technique is not limited to NoteHeads.
62 However, the NoteHead callback is particularly important, since it is
63 the implicit callback used by the @code{\\tweak} command.
64
65
66 The example function defined below (\"display-grobs\") is probably not
67 that useful, but it demonstrates that the grobs are indeed being
68 accessed.
69
70
71 Example console output:
72
73
74 @example
75 --------------------
76 #-Grob Accidental -
77 #-Grob Arpeggio -
78 #-Grob Stem -
79 @end example
80
81
82 "
83   doctitle = "Using ly:grob-object to access grobs with \\tweak"
84 } % begin verbatim
85
86
87 #(define (notehead-get-accidental notehead)
88    ;; notehead is grob
89    (ly:grob-object notehead 'accidental-grob))
90
91 #(define (notehead-get-arpeggio notehead)
92    ;; notehead is grob
93    (let ((notecolumn (notehead-get-notecolumn notehead)))
94      (ly:grob-object notecolumn 'arpeggio)))
95
96 #(define (notehead-get-notecolumn notehead)
97    ;; notehead is grob
98    (ly:grob-parent notehead X))
99
100 #(define (notehead-get-stem notehead)
101    ;; notehead is grob
102    (let ((notecolumn (notehead-get-notecolumn notehead)))
103      (ly:grob-object notecolumn 'stem)))
104
105 #(define (display-grobs notehead)
106    ;; notehead is grob
107    (let ((accidental (notehead-get-accidental notehead))
108          (arpeggio (notehead-get-arpeggio notehead))
109          (stem (notehead-get-stem notehead)))
110      (format #t "~2&~a\n" (make-string 20 #\-))
111      (for-each
112       (lambda (x) (format #t "~a\n" x))
113       (list accidental arpeggio stem))))
114
115 \relative c' {
116   %% display grobs for each note head:
117   %\override NoteHead #'before-line-breaking = #display-grobs
118   <c
119   %% or just for one:
120   \tweak #'before-line-breaking #display-grobs
121   es
122   g>1\arpeggio
123 }