lilypond-user
[Top][All Lists]
Advanced

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

Re: space the width of key signature


From: David Nalesnik
Subject: Re: space the width of key signature
Date: Sat, 2 Jul 2016 13:07:36 -0500

Hi,

On Sat, Jul 2, 2016 at 12:49 PM, David Nalesnik
<address@hidden> wrote:
> Hi Harm,
>
> On Sat, Jul 2, 2016 at 10:43 AM, Thomas Morley <address@hidden> wrote:
>> 2016-07-01 20:43 GMT+02:00 Br. Gabriel-Marie | SSPX <address@hidden>:
>>> Because stanza numbers only appear on the first line.  Using instrumentName
>>> to label verse numbers provides automatic numbering on every line.  It
>>> wasn't my idea, actually, credit for that goes to Thomas Morley  a few
>>> issues ago in Vol 163:issue 95.  It works quite well.
>>>
>>> On 7/1/2016 1:30 PM, address@hidden wrote:
>>>>
>>>> Why not use StanzaNumbers instead of instrumentName to label verse
>>>> numbers?
>>
>>
>> Meanwhile I tried to make StanzaNumber at every line-begin work, see 
>> attached.
>> Though, it's stacking workarounds, thus pretty expensive.
>> At least it _is_ possible, even now.
>> Maybe someone steps in futher improving it.
>
> It is possible to check the break status of the NonMusicalPaperColumn
> to the left of the StanzaNumber.  This eliminates the need to filter a
> list of all grobs on the line.
>
> First, you need the StanzaNumber's column.  Then you can get its left
> neighbor (which is needed b/c the stanza's column is a PaperColumn and
> won't carry useful break info.).  If the neighbor is non-musical and
> right-broken, we're at the start of the line.
>
> &=====================
>
> #(define (at-line-beginning? grob)
>    (let* ((col (ly:item-get-column grob))
>           (ln (ly:grob-object col 'left-neighbor)))
>      (not (and (eq? #t (ly:grob-property ln 'non-musical))
>                (= 1 (ly:item-break-dir ln))))))
>
> #(define (keep-stanza-number-at-line-begin grob)
>    (if (at-line-beginning? grob)
>        (ly:grob-suicide! grob)))
>
> &====================

Sorry, logic fail:

#(define (at-line-beginning? grob)
   (let* ((col (ly:item-get-column grob))
          (ln (ly:grob-object col 'left-neighbor))
          (col-to-check (if (ly:grob? ln) ln col)))
     (and (eq? #t (ly:grob-property col-to-check 'non-musical))
          (= 1 (ly:item-break-dir col-to-check)))))

#(define (keep-stanza-number-at-line-begin grob)
   (if (not (at-line-beginning? grob))
       (ly:grob-suicide! grob)))

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

This should work with grobs whose column is itself non-musical.  So
you could do this:

\new Staff {
  \override Staff.Clef.after-line-breaking =
  #(lambda (grob)
     (if (at-line-beginning? grob)
         (set! (ly:grob-property grob 'color) red)))

  c1
  \break
  c1 \clef bass c1
  \break
  \clef treble c1
}


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

Best,
DN



reply via email to

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