lilypond-user
[Top][All Lists]
Advanced

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

Execution order of callback functions


From: Urs Liska
Subject: Execution order of callback functions
Date: Wed, 17 Oct 2018 10:59:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

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


reply via email to

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