lilypond-user
[Top][All Lists]
Advanced

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

Re: Conditionally color all tweaked objects


From: David Kastrup
Subject: Re: Conditionally color all tweaked objects
Date: Tue, 23 Apr 2013 10:37:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Urs Liska <address@hidden> writes:

> Am Montag, den 22.04.2013, 19:03 +0200 schrieb David Kastrup:
>> 
>> You could redefine \tweak but it is probably more reliable to use
>> internals:
>> 
>> > So would such a thing be possible, maybe in Scheme?
>> > Or if that's not possible in Scheme would that be an interesting feature
>> > request?
>> 
>> 
>> \version "2.16.2"
>> 
>> { c d e f \tweak #'font-size 3 g a b c }
>> 
>> \layout
>> {
>>   \context {
>>     \Score
>>     \consists #(make-engraver
>>              (acknowledgers
>>               ((grob-interface engraver grob source)
>>                (let ((ev (event-cause grob)))
>>                  (if (and (ly:stream-event? ev)
>>                           (pair? (ly:event-property ev 'tweaks)))
>>                      (set! (ly:grob-property grob 'color) red))))))
>>   }
>> }
>> 
>> This does not try to differentiate events into several grobs, so in this
>> case, the whole note with stem and notehead will get colored even though
>> just the notehead was tweaked.  It is more cumbersome to pick out
>> further details, so this is left as an exercise to the reader.
>> 
> Thank you very much.
> I hope to get somewhere from that and will take the exercise ;-)

Three notes:

a) this does not catch \override or \once\override since those are,
   well, not tweaks
b) a lot more has become tweakable with

    commit 77d99c047772da8e897af75c49b00523556da01e
    Author: David Kastrup <address@hidden>
    Date:   Thu Apr 4 11:12:38 2013 +0200

        Issue 3296: Move Tweak_engraver to Score level

        This makes it possible to tweak items announced at Score level, like
        MetronomeMark and RehearsalMark.
    [...]

   but that's only available with version 2.17.16
c) a "direct tweak" in the tweaks list of an event has the form
   (property . value) or ((#t property subproperty ...) . value)
   and affects all grobs for which (grob-property grob 'cause) is the
   respective stream event.

   An "indirect tweak" has the form ((GrobName property ...) . value)
   and affects all grobs for which (event-cause grob) is the respective
   stream event (event-cause follows a chain of causes until hitting a
   stream event) _and_ for which the grob name is GrobName.

Some things, like footnotes, may make use of the tweak mechanism as
well, so you might want to weed them out before marking them.

Hope this gets you on track.

-- 
David Kastrup



reply via email to

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