lilypond-devel
[Top][All Lists]
Advanced

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

Re: Scheme Tweak Help: Highlighting a Staff in a StaffGroup


From: Neil Puttock
Subject: Re: Scheme Tweak Help: Highlighting a Staff in a StaffGroup
Date: Tue, 8 Mar 2011 21:48:25 +0000

On 7 March 2011 21:11, emw <address@hidden> wrote:

> If anyone can help me write a Scheme tweak for this, I'd appreciate it. Even
> pointing me to a tweak that does some of the same things would be helpful
> (i.e. tweaking output across an entire Staff in a StaffGroup, etc).

Each Staff context contains a grouping object (a VerticalAxisGroup)
which carries all the elements on the stave.  You can extract the
bounding box for this and print a solid coloured box as its stencil
(which is usually unset):

\version "2.12.3"

highlight = {
  \override Staff.VerticalAxisGroup #'layer = #-1
  \override Staff.VerticalAxisGroup #'stencil =
  #(lambda (grob)
     (let ((x-ext (ly:grob-property grob 'X-extent))
           (y-ext (ly:grob-property grob 'Y-extent)))
       (grob-interpret-markup grob
                              (markup #:with-color yellow
                                      #:filled-box x-ext y-ext 0))))
}

\new StaffGroup <<
  \new Staff \relative c' {
    c1
  }
  \new Staff \relative c' {
    \highlight
    c1
  }
>>

If you're running 2.13, defining \highlight as a context modification
makes it easier to add to other contexts such as Lyrics:

\version "2.13.53"

highlight = \with {
  \override VerticalAxisGroup #'layer = #-1
  \override VerticalAxisGroup #'stencil =
  #(lambda (grob)
     (let ((x-ext (ly:grob-property grob 'X-extent))
           (y-ext (ly:grob-property grob 'Y-extent)))
       (grob-interpret-markup grob
                              (markup #:with-color yellow
                                      #:filled-box x-ext y-ext 0))))
}

\new StaffGroup <<
  \new Staff \new Voice = "melody" \relative c' {
    c1
  }
  \new Lyrics \highlight \lyricsto "melody" {
    foo
  }
  \new Staff  \relative c' {
    c1
  }
  \new Staff \highlight \relative c' {
    c1
  }
>>

Cheers,
Neil

Attachment: highlight.png
Description: PNG image


reply via email to

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