lilypond-user
[Top][All Lists]
Advanced

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

Re: Directional NoteHead Stencil Support


From: David Nalesnik
Subject: Re: Directional NoteHead Stencil Support
Date: Fri, 20 Mar 2015 09:21:16 -0500

Hi,

On Fri, Mar 20, 2015 at 7:14 AM, Paul Morris <address@hidden> wrote:
There's a snippet in the lsr for accessing grobs "laterally" from another grob's callback:

...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

reply via email to

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