lilypond-user
[Top][All Lists]
Advanced

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

Re: \applyContext, StaffSymbol, and \stopStaff \startStaff


From: David Kastrup
Subject: Re: \applyContext, StaffSymbol, and \stopStaff \startStaff
Date: Mon, 19 Oct 2015 17:48:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Paul Morris <address@hidden> writes:

>> On Oct 19, 2015, at 10:59 AM, David Kastrup <address@hidden> wrote:
>> 
>> Paul Morris <address@hidden> writes:
>>> 
>>> That did the trick and now it works, thanks!
>>> 
>>> \version “2.19.22” 
>>> 
>>> myfunc =
>>> #(define-music-function () ()
>>>   #{
>>>     \context Staff
>>>     \applyContext
>>>     #(lambda (context)
>>>        ;; access context properties and pick a property setting based on 
>>> them...
>>>        (ly:context-pushpop-property context 'StaffSymbol 'color green))
>>>     \stopStaff
>>>     \startStaff
>>>   #})
>> 
>> Frankly, anything wrong with
>> 
>>    \temporary \override Staff.StaffSymbol.color = #green
>> 
>> here?
>
> That would work except I want to be able to access Staff context
> properties and then, based on their values, decide what to set the
> StaffSymbol property to.  In this example, say color it either green
> or blue.  I just left these details out of my tiny example (as I tried
> to indicate with the comment "access context properties and pick a
> property setting based on them…”, which may not have been very clear).

Ok, that makes sense.  One can override grob properties with a callback
but they will be called (with the grob as argument) at the time the
property is actually needed, and at that time the only context
properties from the time of call will be the grob property defaults
stored in the grob, in this case the StaffSymbol settings.  And it does
not sound like that would help you.

So \applyContext indeed seems like the right call here.

-- 
David Kastrup



reply via email to

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