Am 08.11.18 um 16:00 schrieb pablocordal:
Hi everyone!
I really have a special need with this function we have been talking about:
<code>
annotatedSlur =
#(define-music-function (parser location padding text) (number? markup?)
#{
\once \override Slur.after-line-breaking =
#(lambda (grob)
(let*
((stencil (ly:slur::print grob))
(dir (ly:grob-property grob 'direction))
(markup-stencil (grob-interpret-markup grob text))
(shift (- (interval-center (ly:stencil-extent stencil X))
(interval-center (ly:stencil-extent markup-stencil X))))
(new-stencil
(ly:stencil-combine-at-edge
stencil
Y dir
(ly:stencil-translate-axis markup-stencil shift X)
padding)))
(ly:grob-set-property! grob 'stencil new-stencil)))
#})
</code>
The funcion works fine, but I think it would be even better if it could
receive another number. This number should move the text horizontally in the
slur- sometimes, the text collides with another element, and it would be
great to move it forward or backward a little.
Any master coder out there can help me with this please?
annotatedSlur =
#(define-music-function (parser location padding hor-offset text)
(number? number? markup?)
#{
\once \override Slur.after-line-breaking =
#(lambda (grob)
(let*
((stencil (ly:slur::print grob))
(dir (ly:grob-property grob 'direction))
(markup-stencil (grob-interpret-markup grob text))
(shift (+ hor-offset
(- (interval-center (ly:stencil-extent stencil X))
(interval-center (ly:stencil-extent markup-stencil
X)))))
(new-stencil
(ly:stencil-combine-at-edge
stencil
Y dir
(ly:stencil-translate-axis markup-stencil shift X)
padding)))
(ly:grob-set-property! grob 'stencil new-stencil)))
#})
{
\annotatedSlur 2 1 "Here"
c'1 ( d' )
}
But of course this means you have to use "0" everytime you do *not* need
the horizontal offset.
Best
Urs
Thank you. Best regards
--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user