lilypond-user
[Top][All Lists]
Advanced

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

Code pointer from end-BarLine to previous NoteHead.?


From: Thomas Morley
Subject: Code pointer from end-BarLine to previous NoteHead.?
Date: Sat, 16 Jul 2022 13:00:16 +0200

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



reply via email to

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