lilypond-user
[Top][All Lists]
Advanced

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

Re: Override a StaffSymbol property outside \new Staff { ... } context


From: Aaron Hill
Subject: Re: Override a StaffSymbol property outside \new Staff { ... } context
Date: Wed, 15 Jan 2020 18:15:09 -0800
User-agent: Roundcube Webmail/1.3.8

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

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