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 @qq{ancestry}. Most grobs have @qq{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
23 * The types of parents a grob has may depend on context. * For some
24 grobs, the X- and Y-parents are the same. * A particular @qq{ancestor}
25 may be related to a grob in multiple ways. * The concept of
26 @qq{generations} is misleading.
29 For example, the @code{System} grob can be both parent (on the Y-side)
30 and grandparent (twice on the X-side) to a @code{VerticalAlignment}
34 This macro prints (to the console) a textual representation of a grob's
42 \\once \\override NoteHead #'before-line-breaking = #display-ancestry
46 The following output is generated:
49 ------------------------------------
51 NoteHead X,Y: NoteColumn
55 X: NonMusicalPaperColumn
58 X: NonMusicalPaperColumn
65 doctitle = "Displaying grob ancestry"
68 %% http://lsr.di.unimi.it/LSR/Item?id=622
69 %% see also http://www.lilypond.org/doc/v2.18/Documentation/snippets/tweaks-and-overrides#tweaks-and-overrides-displaying-grob-ancestry
71 #(define (grob-name grob)
73 (assoc-ref (ly:grob-property grob 'meta) 'name)
76 #(define (get-ancestry grob)
77 (if (not (null? (ly:grob-parent grob X)))
78 (list (grob-name grob)
79 (get-ancestry (ly:grob-parent grob X))
80 (get-ancestry (ly:grob-parent grob Y)))
83 #(define (format-ancestry lst padding)
85 (symbol->string (car lst))
88 (if (list? (cadr lst))
89 (format-ancestry (cadr lst) (+ padding 3))
90 (symbol->string (cadr lst))))
92 (if (list? (caddr lst))
93 (format-ancestry (caddr lst) (+ padding 3))
94 (symbol->string (caddr lst)))))
95 (if (equal? X-ancestry Y-ancestry)
98 (make-string padding #\space)
100 (if (list? (cadr lst))
101 (format-ancestry (cadr lst) (+ padding 5))
102 (symbol->string (cadr lst))))
105 (make-string padding #\space)
108 (make-string padding #\space)
113 #(define (display-ancestry grob)
114 (format (current-error-port)
117 (format-ancestry (get-ancestry grob) 0)))
120 \once \override NoteHead.before-line-breaking = #display-ancestry
122 \once \override Accidental.before-line-breaking = #display-ancestry
123 \once \override Arpeggio.before-line-breaking = #display-ancestry