Hey David,

this is terrific. Nice that something I've done comes back to me this way ...

When I'll have the time I'll look into integrating this into Frescobaldi's Layout Control Options.

Urs

Am 27.04.2015 um 23:14 schrieb David Nalesnik:


On Mon, Apr 27, 2015 at 12:16 PM, David Nalesnik <david.nales...@gmail.com <mailto:david.nales...@gmail.com>> wrote:



    On Mon, Apr 27, 2015 at 12:12 PM, David Nalesnik
    <david.nales...@gmail.com <mailto:david.nales...@gmail.com>> wrote:

        Here's a code snippet to show that it is possible to tell if a
        grob has been altered.  Right now you have to add the
        procedure for each grob you want to examine.



The following covers all changed grobs. Thanks, Urs, for your posting at http://lilypondblog.org/2014/04/music-functions-4-recursion/ -- I adapted one of your functions there to apply the override to all objects with a stencil property. (Rather than using a long string of laboriously typed overrides.)

--DN

%%%%%%%%%%%%


\version "2.19.17"

#(define (grobs-with-stencils)
   (let loop ((all all-grob-descriptions) (result '()))
     (if (null? all)
         result
         (if (assoc-get 'stencil (cdar all))
             (loop (cdr all) (cons (caar all) result))
             (loop (cdr all) result)))))

#(define (mark-tweak grob)
   (let* ((default (assoc-get (grob::name grob) all-grob-descriptions))
          (default-after-line (assoc-get 'after-line-breaking default))
          (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))
          (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))
                (tweaks (and cause
                             (ly:music-property
                              (ly:event-property cause 'music-cause)
                              'tweaks))))
           (if (pair? tweaks)
               (set! (ly:grob-property grob 'color) red)))
         (set! (ly:grob-property grob 'color) green))
     ;; Return any default setting of after-line-breaking.
     (or default-after-line '())))


markAllAlteredGrobs =
#(define-music-function (parser location) ()
   (let loop ((grobs (grobs-with-stencils)))
     (if (null? grobs)
         #{ #}
         #{
\override #(list 'Score (car grobs) 'after-line-breaking) = #mark-tweak
           #(loop (cdr grobs))
         #})))

{
  \markAllAlteredGrobs
  c'
  \once \override NoteHead.font-size = 3
  c'
  c'
  \tweak font-size 3 c'
  c'
  %\override Slur.after-line-breaking = #mark-tweak
  c'( e')
  \shape #'((0 . 0) (0 . -0.5) (0 . -0.5) (0 . 0)) Slur
  c'( e')
  c'( e')
  c'-\tweak Slur.positions #'(-5 . -5) ( e')
  \override Hairpin.color = #blue
  c'\< e'\!
  <c' e'>\arpeggio
  \once \override Staff.Arpeggio.positions = #'(-6 . 6)
  <c' e'>\arpeggio
}


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to