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 When working with grob callbacks, it can be helpful to understand a
14 grob’s ancestry. Most grobs have parents which influence the
15 positioning of the grob. X- and Y-parents influence the horizontal and
16 vertical positions for the grob, respectively. Additionally, each
17 parent may have parents of its own.
20 Unfortunately, there are several aspects of a grob’s ancestry that can
24 * The types of parents a grob has may depend on context.
26 * For some grobs, the X- and Y-parents are the same.
28 * A particular “ancestor” may be related to a grob in multiple ways.
30 * The concept of “generations” is misleading.
33 For example, the @code{System} grob can be both parent (on the Y-side)
34 and grandparent (twice on the X-side) to a @code{VerticalAlignment}
38 This macro prints (to the console) a textual representation of a grob’s
43 @code{@{ \\once \\override NoteHead.before-line-breaking =
44 #display-ancestry c @}}
46 The following output is generated:
49 @code{NoteHead X,Y: NoteColumn
53 X: NonMusicalPaperColumn
56 X: NonMusicalPaperColumn
61 doctitle = "Displaying grob ancestry"
64 %% http://lsr.di.unimi.it/LSR/Item?id=622
65 %% see also http://www.lilypond.org/doc/v2.18/Documentation/snippets/tweaks-and-overrides#tweaks-and-overrides-displaying-grob-ancestry
68 %% grob::name is in the source since 2.19.x could be deleted during next LSR-upgrade
69 #(define (grob::name grob)
70 (assq-ref (ly:grob-property grob 'meta) 'name))
72 #(define (get-ancestry grob)
73 (if (not (null? (ly:grob-parent grob X)))
74 (list (grob::name grob)
75 (get-ancestry (ly:grob-parent grob X))
76 (get-ancestry (ly:grob-parent grob Y)))
79 #(define (format-ancestry lst padding)
81 (symbol->string (car lst))
84 (if (list? (cadr lst))
85 (format-ancestry (cadr lst) (+ padding 3))
86 (symbol->string (cadr lst))))
88 (if (list? (caddr lst))
89 (format-ancestry (caddr lst) (+ padding 3))
90 (symbol->string (caddr lst)))))
91 (if (equal? X-ancestry Y-ancestry)
94 (make-string padding #\space)
96 (if (list? (cadr lst))
97 (format-ancestry (cadr lst) (+ padding 5))
98 (symbol->string (cadr lst))))
101 (make-string padding #\space)
104 (make-string padding #\space)
109 #(define (display-ancestry grob)
110 (format (current-error-port)
114 (format-ancestry (get-ancestry grob) 0)
115 (format #f "~a is not a grob" grob))))
118 \once \override NoteHead.before-line-breaking = #display-ancestry
120 \once \override Accidental.before-line-breaking = #display-ancestry
121 \once \override Arpeggio.before-line-breaking = #display-ancestry