lilypond-user
[Top][All Lists]
Advanced

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

Re: Code pointer from end-BarLine to previous NoteHead.?


From: Jean Abou Samra
Subject: Re: Code pointer from end-BarLine to previous NoteHead.?
Date: Sat, 16 Jul 2022 14:04:58 +0200


> Le 16 juil. 2022 à 13:01, Thomas Morley <thomasmorley65@gmail.com> a écrit :
> 
> Hi,
> 
> I'm trying to code an engraver setting a pointer from BarLine to
> previous NoteHead and an override for BarLine.Y-offset acting upon
> that pointer.
> It does not work, if the BarLine is at end.
> 
> Here a stripped down example (every security is removed and all is
> heavily simplified):
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> \version "2.23.9"
> 
> tst =
> #(lambda (ctx)
>  (let ((nc #f)
>        (bar #f))
>  (make-engraver
>    (acknowledgers
>      ((bar-line-interface engraver grob source-engraver)
>        (set! bar grob))
>      ((note-head-interface engraver grob source-engraver)
>        (set! nc grob)))
>    ((stop-translation-timestep engraver)
>      (if (and nc bar)
>          (ly:grob-set-object! bar 'element nc))))))
> 
> moveBarLineToPrevHead =
>  \override Staff.BarLine.Y-offset =
>    #(lambda (grob)
>      (let* ((prev-head (ly:grob-object grob 'element))
>             (staff-pos
>               (if (ly:grob? prev-head)
>                   (ly:grob-property prev-head 'staff-position #f)
>                   #f)))
>       (pretty-print
>         (list
>           (cons 'prev-head prev-head)
>           (cons 'staff-pos staff-pos)))
>       (/ (or staff-pos 10) 2)))
> 
> \layout {
>  \context {
>      \Staff
>      \consists \tst
>      \moveBarLineToPrevHead
>  }
> }
> 
> \new Staff { b4 \bar "." b }
> \new Staff { b4 \bar "." }
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> I'm aware the (main) difference between the two staves is the
> break-direction of the BarLine.
> 
> Though, how to catch it ?
> Or how to do it different?
> 
> Thanks,
>  Harm


In a given timestep, the currentCommandColumn is at the _left_ of the 
currentMusicalColumn. You’re storing a pointer to the next note head, not the 
previous.

Jean





reply via email to

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