lilypond-devel
[Top][All Lists]
Advanced

[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?

Werner,
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)
      #f))

#(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)
  (string-append
    (symbol->string (car lst))
    "\n"
    (make-string (* generation 3) #\space)
    "X: "
    (if (list? (cadr lst))
        (format-ancestry (cadr lst) (1+ generation))
        (symbol->string (cadr lst)))
    "\n"
    (make-string (* generation 3) #\space)
    "Y: "
    (if (list? (caddr lst))
        (format-ancestry (caddr lst) (1+ generation))
        (symbol->string (caddr lst)))
    "\n"))

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

\relative {
  \once \override NoteHead #'before-line-breaking = #display-ancestry
  f
  %\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]