On 2020-01-15 5:15 pm, Paolo Prete wrote:
Hello,

is it possible to override a property of StaffSymbol outside a
 \new Staff \with { ... }
context?

I would like to obtain something like:

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

#scheme-code-for-overriding-staffsymbol-for-all-the-staves-in-the-score
{
  c' c' c' c'
}

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

Without needing to mess with Scheme, you can do this using the \layout block providing you want to change all staves:

%%%%
\version "2.19.83"

\layout {
  \context {
    \Staff
    \override StaffSymbol.color = #red
  }
}

\new Staff { b'4 }
\new Staff { b'4 }
\new Staff { b'4 }
%%%%

(That is a top-level \layout block, but the same can be done within a \score to scope the effect.)

If you only need to affect specific staves but want to avoid duplicating the overrides, put them in a variable to reference as needed:

%%%%
\version "2.19.83"

redLines = \with { \override StaffSymbol.color = #red }

\new Staff { b'4 }
\new Staff \with { \redLines } { b'4 }
\new Staff \with { \redLines } { b'4 }
%%%%

Lastly, you could even define your own Staff-like context and embed the property changes within it:

%%%%
\version "2.19.83"

\layout {
  \context {
    \Staff
    \type Engraver_group
    \name RedStaff
    \alias Staff
    \override StaffSymbol.color = #red
  }
  \inherit-acceptability RedStaff Staff
}

\new Staff { b'4 }
\new RedStaff { b'4 }
\new RedStaff { b'4 }
%%%%


-- Aaron Hill

Reply via email to