On Fri, May 1, 2015 at 11:15 AM, David Nalesnik <david.nales...@gmail.com>
wrote:

>
>
> On Fri, May 1, 2015 at 10:56 AM, David Nalesnik <david.nales...@gmail.com>
> wrote:
>>
>>
>> The code below will work much better.
>>
>>
> Drat.  Somehow we need to get the context name into the override.
> Otherwise
>
>
>       \override Staff.Clef.extra-offset = #'(0 . 5)
>       \clef alto
>
> will lose its extra-offset and not be marked in green.
>
>
OK, fixed.  Hoping this wouldn't get too convoluted...

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

 \version "2.19"

colorOverride =
#(define-music-function (parser location music) (ly:music?)
   (music-map
    (lambda (mus)
      (if (and (music-is-of-type? mus 'context-specification)
               (ly:music? (ly:music-property mus 'element)))

          (let* ((elt (ly:music-property mus 'element))
                 (context (ly:music-property mus 'context-type)))

            (cond
             ((music-is-of-type? elt 'override-property-event)
              (let* ((grob-name (ly:music-property elt 'symbol))
                     (prop-path (ly:music-property elt 'grob-property-path))
                     (once? (ly:music-property elt 'once)))
                (cond
                 ; non-user overrides don't set property path
                 ((null? prop-path) #{ #})
                 ((eq? #t once?)
                  (set! mus
                        #{
                          \once \override #(list context grob-name 'color)
= #green
                          #mus
                        #}))
                 (else
                  (set! mus
                        #{
                          \override #(list context grob-name 'color) =
#green
                          #mus
                        #})))))
             ((and (music-is-of-type? elt 'layout-instruction-event)
                   (eq? (ly:music-property elt 'name) 'RevertProperty))
              (let ((grob-name (ly:music-property elt 'symbol)))
                (set! mus
                      #{
                        \revert #(list context grob-name 'color)
                        #mus
                      #}))))))

      mus)
    music)

   music)

%\displayMusic
\colorOverride
\new PianoStaff <<
  \new Staff <<
    \new Voice {
      \voiceOne
      c''4
      \once \override NoteHead.after-line-breaking =
      #(lambda (grob)
         (let ((stil (ly:note-head::print grob)))
           (set! (ly:grob-property grob 'stencil)
                 (ly:stencil-scale stil 1.5 1.5))))
      d'' e''->
      \override Voice.Stem.padding = 2
      f''
      g''1
    }
    \new Voice {
      \voiceTwo
      c'4 d'
      \override Script.font-size = 3
      e'-> f'->
      \revert Script.font-size
      g'1->
      \override Staff.Clef.extra-offset = #'(0 . 5)
      \oneVoice
      \clef alto
      \shape #'((0 . 0) (0 . 3) (0 . 3) (0 . 0)) Tie % \shape is \once
      c'1~
      \revert Staff.Clef.extra-offset
      \clef treble
      c'1~
      c'1
    }
  >>
  \new Staff <<
    \clef bass
    \new Voice {
      \voiceOne
      c'4 d' e'->
      \override Voice.Stem.padding = 2
      f'
      g'1\fermata
      \oneVoice
      \clef treble
      c'
      \clef alto
    }
    \new Voice {
      \voiceTwo
      c4 d
      \override Script.font-size = 3
      e-> f->
      g1->
    }
  >>
>>
%}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to