lilypond-user
[Top][All Lists]
Advanced

[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: Fri, 17 Mar 2017 11:36:52 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

Hi Harm,

thank you for your suggestions. I will definitely have a closer look but
I've realized that I have to postpone this task because it massively
interferes with a related one I'm currently at.

So I'll probably only comment after some more time.

Best
Urs


Am 17.03.2017 um 00:34 schrieb Thomas Morley:
> 2017-03-16 22:51 GMT+01:00 Thomas Morley <address@hidden>:
>> 2017-03-16 14:23 GMT+01:00 Urs Liska <address@hidden>:
>>> 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)
>>>
>>> Any ideas?
>>> TIA
>>> Urs
>>
>>
>> Hi Urs,
>>
>> here my thoughts about the topic so far.
>> Although I'm afraid it will not help, because it has to be done
>> before-line-breaking.
>>
>> wanted-value = 20
>>
>> {
>>     c'1( \break
>>   \override NoteColumn.before-line-breaking =
>>   #(lambda (nc)
>>   ;; TODOs
>>   ;; add fall-backs if certain grobs are not present, i.e
>>   ;; (DotColumn, Arpeggio, AccidentalPlacement)
>>     (let* ((dot-col (ly:note-column-dot-column nc))
>>            (acc-placement (ly:note-column-accidentals nc))
>>            (common-ref
>>              (ly:grob-common-refpoint nc acc-placement X))
>>            (x-length-of-accs
>>              (interval-length
>>                (ly:relative-group-extent
>>                  (map last (ly:grob-object acc-placement 'accidental-grobs))
>>                  common-ref
>>                  X))))
>>
>>        (for-each
>>          (lambda (el)
>>            (ly:grob-translate-axis!
>>              el
>>              (+ x-length-of-accs wanted-value)
>>              X))
>>          (filter
>>            (lambda (g) (ly:grob? g))
>>            (list
>>              acc-placement
>>              dot-col
>>              nc)))))
>>
>>
>>   <cis'' dis'' fis'' gis''-1\2>2)\arpeggio ^"foo"
>> }
>>
>> Cheers,
>>   Harm
> Probably:
>
> {
>     c'1( \break
>   \override NoteColumn.after-line-breaking =
>   #(lambda (nc)
>      (ly:grob-translate-axis! (ly:grob-parent nc X) 5 X)
>      ;; uncomment for viewing
>      ;(ly:grob-set-property!
>      ;  (ly:grob-parent nc X)
>      ;  'stencil
>      ;  ly:paper-column::print)
>        )
>
>
>   <cis'' dis'' fis'' gis''-1\2>2)\arpeggio ^"foo"
> }
>
> Not tested beyond the above example, though.
>
> Cheers,
>   Harm

-- 
address@hidden
https://openlilylib.org
http://lilypondblog.org




reply via email to

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