[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: visualizing grob ancestry

From: Mark Polesky
Subject: Re: visualizing grob ancestry
Date: Thu, 23 Jul 2009 22:01:12 -0700 (PDT)

Werner LEMBERG wrote:
> > Instead of documenting this in the IR, maybe it would be better to
> > write a section in the CG about how to find a grob's parent, the
> > parent's parent, etc. with GDB?
> Hmm.  Any chance to have this in Scheme?

Here's one way of doing it (from within a music block).
- Mark


\version "2.13.2"

#(define (grob-name grob)
  (if (ly:grob? grob)
      (assoc-ref (ly:grob-property grob 'meta) 'name)

#(define (get-ancestry grob)
    (if (not (null? (ly:grob-parent grob X)))
        (list (grob-name grob)
              (get-ancestry (ly:grob-parent grob X))
              (get-ancestry (ly:grob-parent grob Y)))
        (grob-name grob)))

#(define (format-ancestry lst generation)
    (symbol->string (car lst))
    (make-string (* generation 3) #\space)
    "X: "
    (if (list? (cadr lst))
        (format-ancestry (cadr lst) (1+ generation))
        (symbol->string (cadr lst)))
    (make-string (* generation 3) #\space)
    "Y: "
    (if (list? (caddr lst))
        (format-ancestry (caddr lst) (1+ generation))
        (symbol->string (caddr lst)))

#(define (display-ancestry grob)
      (make-string 36 #\-)
      (format-ancestry (get-ancestry grob) 0))))

\relative {
  \once \override NoteHead #'before-line-breaking = #display-ancestry
  %\once \override Accidental #'before-line-breaking = #display-ancestry
  %\once \override Arpeggio #'before-line-breaking = #display-ancestry
  <f as c>\arpeggio


reply via email to

[Prev in Thread] Current Thread [Next in Thread]