lilypond-user
[Top][All Lists]
Advanced

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

\applyContext, StaffSymbol, and \stopStaff \startStaff


From: Paul Morris
Subject: \applyContext, StaffSymbol, and \stopStaff \startStaff
Date: Sat, 17 Oct 2015 16:09:50 -0400

Greetings lilyponders,  

I’m trying to figure out how to use \applyContext to modify StaffSymbol grob 
properties.  The examples here

http://www.lilypond.org/doc/v2.19/Documentation/extending/context-evaluation

are very helpful, but I haven’t been able to get things working with 
StaffSymbol and \stopStaff \startStaff.  There’s probably some subtlety that 
I’m missing…  (Maybe it has to do with the difference between \temporary 
\override and \override ?)  Below is a tiny example (not my actual use case).

Thanks for any help with this,
-Paul


\version "2.19.22"

% These work as expected
{
  c'
  \stopStaff
  \startStaff
  \override Staff.StaffSymbol.color = #red
  c'
  \override Staff.StaffSymbol.color = #green
  \stopStaff
  \startStaff
  c’
}

{
  \applyContext
  #(lambda (context)
     ;; access context properties pick a property setting based on them...
     (ly:context-pushpop-property context 'StaffSymbol 'color blue))
  c’
}

% But so far these don’t...

myfunc =
#(define-music-function () ()
   (define mycolor red)
   #{
     \applyContext
     #(lambda (context)
        ;; access context properties and pick a property setting based on 
them...
        (set! mycolor green))
     \override Staff.StaffSymbol.color = #mycolor
   #})

{
  c’
  % the order of these commands does not seem to affect things
  \stopStaff \startStaff
  \applyContext
  #(lambda (context)
     ;; access context properties and pick a property setting based on them...
     (ly:context-pushpop-property context 'StaffSymbol 'color blue))
  c'
  \myfunc
  \stopStaff \startStaff
  c'
}








reply via email to

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