lilypond-user
[Top][All Lists]
Advanced

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

Re: Color one SystemStartBrace


From: Urs Liska
Subject: Re: Color one SystemStartBrace
Date: Thu, 14 Mar 2019 12:56:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Hi David,

thank you once again for your extremely valuable input!

Am 13.03.19 um 22:55 schrieb David Nalesnik:
On Wed, Mar 13, 2019 at 4:27 PM David Nalesnik <address@hidden> wrote:
On Wed, Mar 13, 2019 at 3:44 PM Urs Liska <address@hidden> wrote:
..
You're not going to be able to do it simply, any more than you can
introduce overrides of individual pieces of a broken slur once it's
begun.  The starting bars are all clones of the first object.

The only way I can suggest is to collect all the grobs on the system
in question using the 'all-elements property (you can do this through
a grob on the system in question), locate the target grob, and set its
'color property.

DN
Like this:

\version "2.19.82"

#(define drop-in-on-spanner
   (lambda (grob)
     (let* ((elts (ly:grob-array->list (ly:grob-object (ly:grob-system
grob) 'all-elements)))
            (ssb (filter (lambda (e) (grob::has-interface e
'system-start-delimiter-interface))
                         elts)))
       (set! (ly:grob-property (car ssb) 'color) red))))

\new StaffGroup <<
  \new Staff {
    c1 \break
    \once \override NoteHead.after-line-breaking = #drop-in-on-spanner
    c1 \break
    c1 \break
  }
  \new Staff {
    c1
    c1
    c1
  }


Thank you, this gave me enough input to find my solution. Since I actually needed to get to the SystemStartBar I modified the approach a little bit but succeeded. Then I additionally created a wrapper function that can now be used like this:

\version "2.19.82"

#(define color-system-start-bar
   (lambda (grob)
     (let*
      ((staff-elements
        (ly:grob-array->list
         (ly:grob-object (ly:grob-system grob) 'all-elements)))
       (ssb
        (filter
         (lambda (e)
           (eq? 'SystemStartBar (assq-ref (ly:grob-property e 'meta) 'name)))
         staff-elements)))
      (ly:grob-set-property! (car ssb) 'color red))))

annotateSystemStartBar =
#(define-music-function (comment)(string?)
  ; the string? argument is discarded and only used for the input file
   #{
     \once \override NoteHead.after-line-breaking = #color-system-start-bar
   #})

\score {
  \new PianoStaff <<
    \new Staff {
      c'1
      \break
      \annotateSystemStartBar "This is a comment that is now documented in the input"
      c'
    }
    \new Staff { c'1 c' }
  >>
}

Urs


reply via email to

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