Execution order of callback functions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Execution order of callback functions

Urs Liska-3

Hi,

I am wondering about the execution order of the callback functions. I would have assumed that the 'stencil callback would *always* be executed before or after the 'after-line-breaking callback. However, when I tried to investigate this I found that in

\version "2.19.82"

{
  c' 
  -\tweak after-line-breaking
  #(lambda (grob) 
     (ly:message "Text after-line-breaking ~a" 
       (ly:stencil-extent
        (ly:text-interface::print grob) X) ))
  ^"Text"
  -\tweak stencil
  #(lambda (grob)
     (ly:message "Slur stencil ~a"
       (ly:stencil-extent
        (ly:slur::print grob) X)))
  _(
  d' )
}

the slur's callback function is *always* executed after the text's, regardless of which callback I override.

I came to the conclusion that this must be caused by the slur only being calculated when its *end* is processed, and this happens only after the text is fully processed (although I still don't fully understand why this happens). Is that correct?

What I wanted to do is save some information about the slur's stencil somewhere in a global variable or a closure and then use it to offset the text's stencil, but if my observations are correct then this doesn't seem possible, right?

Another approach would be to only override the text's callback, access the NoteColumn and find the slur from there. But this would suffer from the same lack of knowledge about the slur's stencil.

So is there a way to find a slur that is attached to the same note as a text and offset the text's stencil depending on the slur's stencil-extent?

  • I think I can't (easily) simply add the markup-stencil in the slur's callback because I wouldn't know how to reliably place the text at the opposite side of the slur (not knowing what else is going on in the staff at that point).
  • What I *could* do if it helps is to do the calculation at the *end* of the slur

Any suggestions?
Thanks
Urs


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user