[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accessing a grob from within a music function
From: |
Urs Liska |
Subject: |
Re: Accessing a grob from within a music function |
Date: |
Thu, 16 Mar 2017 14:47:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
Hi David,
Am 16.03.2017 um 14:40 schrieb David Nalesnik:
> Hi Urs,
>
> On Thu, Mar 16, 2017 at 8:23 AM, Urs Liska <address@hidden> wrote:
>> Hi,
>>
>> I'm trying to write a function to push a note column like this:
>>
>> pushLeftBroken =
>> #(define-music-function ()()
>> #{
>> \once \override NoteColumn.X-offset = 3
>> #})
>>
>> But I need to make that "3" depend on some characteristics of the actual
>> note column. Basically I need the width of the note column, including
>> attached accidentals.
>>
>> I know how to get to the accidental(s) within a note column, but if I'm
>> not mistaken there's no actual grob inside that.
>>
>> Probably music-function isn't the right approach?
>>
>> What I need is a way to say something like
>>
>> \once \override NoteColumn.X-offset = #(+ 3
>> extent-of-all-accidentals-in-the-note-column)
>>
> In the majority of cases you can follow a trail of pointers. From the
> NoteColumn, you can get noteheads or AccidentalPlacement, from
> noteheads you can get to accidentals.
> \version "2.19.56"
>
> {
> \override NoteColumn.X-offset =
> #(lambda (nc)
> (let ((notes (ly:grob-array->list (ly:grob-object nc 'note-heads))))
> (pretty-print (grob::all-objects nc))
> (pretty-print (grob::all-objects (car notes)))))
> <cis'' dis'' fis'' gis''>1
> }
>
> I presume that travelling up the chain of parentage -- to a
> PaperColumn -- would get you more grobs ('elements object property).
>
> -David
Thank you, this will give me all I need.
But could you please clarify (in more general terms):
Usually (as in my example) I'd override X-offset with a literal number.
You override it with a function.
Does that mean that whenever I override a property of a grob with a
callback function it will be the grob that is passed to that function?
Well, now that I think of it this is what I'm doing with the stencil
override all along. Where can I read more about this?
Best
Urs
--
address@hidden
https://openlilylib.org
http://lilypondblog.org
Re: Accessing a grob from within a music function, Thomas Morley, 2017/03/16