Hi,

On Fri, Mar 20, 2015 at 7:14 AM, Paul Morris <p...@paulwmorris.com> wrote:

> There's a snippet in the lsr for accessing grobs "laterally" from another
> grob's callback:
> http://lsr.di.unimi.it/LSR/Item?id=621
>
> ...like accessing the stem grob from a note head grob.  There's also one
> on showing "grob ancestry" that's helpful for this kind of thing.
>
>
This is a helpful snippet.

If you look at the various interface pages, under "Internal Properties" in
the Internals Reference, you'll find other grobs (single grobs or multiple
grobs stored in a "grob-array") that your grob stores pointers to, meaning
that you have easy access to the other object(s).  The grob NoteHead has
"rhythmic-head-interface" (see bottom of page at
http://lilypond.org/doc/v2.19/Documentation/internals/notehead).  Under the
Internals page for that interface
http://lilypond.org/doc/v2.19/Documentation/internals/rhythmic_002dhead_002dinterface
we find:

Internal properties:

dot (graphical (layout) object)

A reference to a Dots object.
stem (graphical (layout) object)

A pointer to a Stem object.


With ly:grob-object, we can get at either a Dot or a Stem.

So, with your function you could write:


#(define alt-notehead
   (lambda (grob)
     (let ((stem (ly:grob-object grob 'stem)))
       (if (ly:grob? stem) ;; perhaps unnecessary, but let's be safe
           (if (eq? (ly:grob-property stem 'direction) DOWN)
               (grob-interpret-markup grob stil)
               (grob-interpret-markup grob newstil))))))


Finding the path from one object to another is usually just a matter of
trial-and-error, following this path, following that path, until you reach
the pot of gold.

HTH,
David
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to