]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/displaying-grob-ancestry.ly
Merge branch 'master' into lilypond/translation
[lilypond.git] / Documentation / snippets / displaying-grob-ancestry.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.14.2"
8
9 \header {
10   lsrtags = "devel, tweaks-and-overrides, scheme-language"
11
12 %% Translation of GIT committish: 6977ddc9a3b63ea810eaecb864269c7d847ccf98
13
14   texidoces = "
15 Al trabajar con los callbacks de un grob, puede ser de mucha ayuda
16 entender el @qq{árbol genealógico} de un grob.  La mayor parte de los
17 grobs tienen @qq{padres} que influyen en el posicionamiento del grob.
18 los padres X e Y influyen en las posiciones horizontal y vertical del
19 grob, respectivamente.  Además, cada pade puede tener padres a su vez.
20
21
22 Por desgracia, existen varios aspectos de la genealogía de un grob que
23 pueden llevar a confusión:
24
25
26 @itemize
27
28 @item Los tipos de padre que tiene un grob pueden depender del
29 contexto.
30
31 @item Para ciertos grobs, los padres X e Y son el mismo.
32
33 @item Un @qq{ancestro} concreto puede estar relacionado con un grob de
34 mas de una manera.
35
36 @item El concepto de @qq{generaciones} es engañoso.
37
38 @end itemize
39
40
41 Por ejemplo, el grob @code{System} puede ser tanto un padre (sobre el
42 lado Y) como un abuelo (dos veces en el lado X) de un grob
43 @code{VerticalAlignment}.
44
45
46 Este macro imprime, en la consola, una representación textual de la
47 genealogía de un grob.
48
49
50 Cuando se llama de esta forma
51
52 @example
53 @{
54    \\once \\override NoteHead #'before-line-breaking = #display-ancestry
55    c4
56 @}
57 @end example
58
59
60 Se genera la siguiente salida:
61
62
63 @example
64 ------------------------------------
65
66 NoteHead X,Y: NoteColumn
67     X: PaperColumn
68        X,Y: System
69     Y: VerticalAxisGroup
70        X: NonMusicalPaperColumn
71           X,Y: System
72        Y: VerticalAlignment
73           X: NonMusicalPaperColumn
74              X,Y: System
75           Y: System
76 @end example
77
78 "
79
80   doctitlees = "Imprimir el árbol genealógico de un grob"
81
82   texidoc = "
83 When working with grob callbacks, it can be helpful to understand a
84 grob's @qq{ancestry}. Most grobs have @qq{parents} which influence the
85 positioning of the grob. X- and Y-parents influence the horizontal and
86 vertical positions for the grob, respectively. Additionally, each
87 parent may have parents of its own.
88
89
90 Unfortunately, there are several aspects of a grob's ancestry that can
91 lead to confusion:
92
93 * The types of parents a grob has may depend on context. * For some
94 grobs, the X- and Y-parents are the same. * A particular @qq{ancestor}
95 may be related to a grob in multiple ways. * The concept of
96 @qq{generations} is misleading.
97
98
99 For example, the @code{System} grob can be both parent (on the Y-side)
100 and grandparent (twice on the X-side) to a @code{VerticalAlignment}
101 grob.
102
103
104 This macro prints (to the console) a textual representation of a grob's
105 ancestry.
106
107
108 When called this way
109
110
111 @{
112  \\once \\override NoteHead #'before-line-breaking = #display-ancestry
113  c @}
114
115
116 The following output is generated:
117
118
119 ------------------------------------
120
121 NoteHead X,Y: NoteColumn
122     X: PaperColumn
123        X,Y: System
124     Y: VerticalAxisGroup
125        X: NonMusicalPaperColumn
126           X,Y: System
127        Y: VerticalAlignment
128           X: NonMusicalPaperColumn
129              X,Y: System
130           Y: System
131
132
133
134 "
135   doctitle = "Displaying grob ancestry"
136 } % begin verbatim
137
138 #(define (grob-name grob)
139    (if (ly:grob? grob)
140        (assoc-ref (ly:grob-property grob 'meta) 'name)
141        #f))
142
143 #(define (get-ancestry grob)
144    (if (not (null? (ly:grob-parent grob X)))
145        (list (grob-name grob)
146              (get-ancestry (ly:grob-parent grob X))
147              (get-ancestry (ly:grob-parent grob Y)))
148        (grob-name grob)))
149
150 #(define (format-ancestry lst padding)
151    (string-append
152     (symbol->string (car lst))
153     "\n"
154     (let ((X-ancestry
155            (if (list? (cadr lst))
156                (format-ancestry (cadr lst) (+ padding 3))
157                (symbol->string (cadr lst))))
158           (Y-ancestry
159            (if (list? (caddr lst))
160                (format-ancestry (caddr lst) (+ padding 3))
161                (symbol->string (caddr lst)))))
162       (if (equal? X-ancestry Y-ancestry)
163           (string-append
164            (format #f "~&")
165            (make-string padding #\space)
166            "X,Y: "
167            (if (list? (cadr lst))
168                (format-ancestry (cadr lst) (+ padding 5))
169                (symbol->string (cadr lst))))
170           (string-append
171            (format #f "~&")
172            (make-string padding #\space)
173            "X: " X-ancestry
174            "\n"
175            (make-string padding #\space)
176            "Y: " Y-ancestry
177            (format #f "~&"))))
178     (format #f "~&")))
179
180 #(define (display-ancestry grob)
181    (format (current-error-port)
182       "~3&~a~2%~a~&"
183       (make-string 36 #\-)
184       (format-ancestry (get-ancestry grob) 0)))
185
186 \relative c' {
187   \once \override NoteHead #'before-line-breaking = #display-ancestry
188   f4
189   \once \override Accidental #'before-line-breaking = #display-ancestry
190   \once \override Arpeggio #'before-line-breaking = #display-ancestry
191   <f as c>4\arpeggio
192 }