lilypond-user
[Top][All Lists]
Advanced

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

Re: Color tweaks (edition engraver)


From: David Nalesnik
Subject: Re: Color tweaks (edition engraver)
Date: Tue, 5 May 2015 09:13:36 -0500

Hi Kieren,

On Tue, May 5, 2015 at 8:57 AM, Kieren MacMillan <address@hidden> wrote:
Hi David,

> And it works with that editionEngraver example.

It definitely works with a minimal EE example… Nice work!

However, I added it to my current (definitely non-minimal!) score, and it fails with:

  In procedure ly:music-property in _expression_ (ly:music-property (ly:event-property cause #) (quote tweaks)):
  [file-path here] Wrong type argument in position 1 (expecting Music): ()

That line is

#(define (mark-tweak grob)
     [%%%SNIP%%%]
     (if (null? diff)
         (let* ((cause (event-cause grob))
                (tweaks (and cause
                             (ly:music-property    %%%%%%  THIS ONE!!!!
                              (ly:event-property cause 'music-cause)
                              'tweaks))))

Can’t spend time tracking down the issue further now, but wanted you to know.

Thanks!

The fix here is no problem.  Quoting just mark-tweak:

 #(define (mark-tweak grob)
   "Color @var{grob} if it has been tweaked.  The color to use is stored
in the global variables @var{override-color} and @var{tweak-color}."
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions)) 
          (props (ly:grob-basic-properties grob))
          ;; Our procedure has been added to the head of grob's basic
          ;; properties.  Let's not count it as a tweak!
          (props
           (remove
            (lambda (p)
              (and (procedure? (cdr p))
                   (eq? (procedure-name (cdr p)) 'mark-tweak)))
            props))
          ;; We're using after-line-breaking to set color of stencil, but
          ;; let's preserve its last setting
          (after-line-return (assoc-get 'after-line-breaking props))
          ;; Clef.glyph doesn't appear in all-grob-descriptions, but it
          ;; is set at some point automatically.  Don't mark it unless
          ;; it genuinely is a user override.  There may be other
          ;; such grobs.
          (props
           (if (eq? (grob::name grob) 'Clef)
               (reverse (remove-first 'glyph (reverse props)))
               props))
          (diff (lset-difference eq? props default)))
     ;; Tweaks will not appear in the "basic properties" alist of our grob, but
     ;; we can find them through the music event which led to the grob.  This
     ;; is available through the stream-event which caused our grob.
     (if (null? diff)
         (let* ((cause (event-cause grob))
                (music-cause
                 (if (ly:stream-event? cause)
                     (ly:event-property cause 'music-cause)
                     #f))
                (tweaks (and (ly:music? music-cause)
                             (ly:music-property
                              music-cause
                              'tweaks))))
           (if (pair? tweaks)
               (set! (ly:grob-property grob 'color) tweak-color)))
         (set! (ly:grob-property grob 'color) override-color))
     
     ;; Return any default setting of after-line-breaking.
     after-line-return))

%%%

Thanks for pointing this out!

David

reply via email to

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