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: Thomas Morley
Subject: Re: Code pointer from end-BarLine to previous NoteHead.?
Date: Sun, 17 Jul 2022 23:48:32 +0200

Am So., 17. Juli 2022 um 09:26 Uhr schrieb Jean Abou Samra <jean@abou-samra.fr>:
>
>
>
> Le 17/07/2022 à 01:25, Thomas Morley a écrit :
> > Thanks for your explanations, right now I had only a quick glance over
> > them.
> > I'll hopefully have some time soon to dive into it...
> > Nevertheless, before I posted the problem I searched for an
> > 'original'-BarLine-grob, as we have for broken spanners.
> > For (maybe broken) spanners I sometimes switch to that
> > 'original'-grob, would it improve the situation if we had some
> > 'original' for items as well?
>
>
>
> D'oh, why didn't think about that? It does solve the problem too
> (and more elegantly):
>
>
> \version "2.23.11"
>
> tst =
> #(lambda (ctx)
>    (let ((nhd #f)
>          (previous-nhd #f)
>          (bar #f))
>    (make-engraver
>      (acknowledgers
>        ((bar-line-interface engraver grob source-engraver)
>          (set! bar grob))
>        ((note-head-interface engraver grob source-engraver)
>          (set! nhd grob)))
>      ((stop-translation-timestep engraver)
>       (when (and bar previous-nhd)
>         ;; for debugging
>         (ly:grob-set-property! previous-nhd 'color red)
>         (ly:grob-set-object! bar 'element previous-nhd)
>         (set! (ly:grob-property bar 'details)
>               (acons 'previous-note-head
>                      previous-nhd
>                      (ly:grob-property bar 'details))))
>         (when nhd
>         ;; Move the next line out of (when ...) if you only want the
>         ;; note head from the time step right before, and not the last
>         ;; note head seen before the bar line.
>         (set! previous-nhd nhd)
>         (set! nhd #f))
>       (set! bar #f)))))
>
> moveBarLineToPrevHead = {
>    \override Staff.BarLine.Y-offset =
>      #(lambda (grob)
>        (let* ((prev-head (ly:grob-object (ly:grob-original grob)
>                                          'element
>                                          #f))
>               (staff-pos (and prev-head (ly:grob-property prev-head
> 'staff-position))))
>         (/ (or staff-pos 0) 2)))
> }
>
> \layout {
>    \context {
>        \Staff
>        \consists \tst
>        \moveBarLineToPrevHead
>    }
> }
>
> \new Staff { s4 s \bar "." b s c' d' e' f' g' a' b' c'' \bar "|." }
>
>
>
> Not sure why it didn't work when you tried?
>
>
>
> Jean

I tried to use ly.grob-original, though, in the real code it first
returned #<Grob Item >.
After some further hours of work, following a different idea, it now
displays #<Grob BarLine > (as it should).

I'm not able to say what happened, I'm not able to debug because of
that unhelpful (oh, I'm very polite this evening) guile messages, see
the other thread.

I'm overtired like hell, close to trashing the whole project, and
close to advertising everyone to not use LilyPond for huge custom
codings.



reply via email to

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