From: "Nick Payne"
I'm stuck on the last part of getting this working - the part that is
eluding me is getting a short vertical line drawn at the RH end of the
spanner. According the the Internals reference, UP = 1 and DOWN = -1, and
that works fine when I use the return value from the updown function to
set TextSpanner.direction in beginStringNum. But when I try to use the
value returned from updown in the section of code that is commented out in
beginStringNum, I get an error. If I hardcode 1 or -1 instead of updown
then the line is drawn as expected.
I also tried the righttext function below to draw the line: no error is
indicated but neither is the vertical line drawn.
\version "2.17.6"
#(define (updown grob)
(let ((dirn (ly:event-property (event-cause grob) 'direction)))
(if (eq? -1 dirn)
DOWN
UP)))
#(define (righttext grob)
(let ((dirn (ly:event-property (event-cause grob) 'direction)))
(if (eq? -1 dirn)
(markup #:draw-line (cons 0 0.5))
(markup #:draw-line (cons 0 -0.5)))))
beginStringNum = #(define-event-function (parser location strng)
(number?)
#{
\tweak bound-details.left.text \markup\bold\teeny\concat
{ \circle { \finger #(number->string strng) } \char ##x2006 }
\tweak font-shape #'upright
\tweak direction #updown
\tweak bound-details.left.stencil-align-dir-y #CENTER
\tweak dash-period #0.8
\tweak dash-fraction #0.6
\tweak thickness #0.8
\tweak bound-details.right.text #righttext
% \tweak bound-details.right.text \markup {
% \draw-line #(cons 0 (/ updown -2)) }
\tweak bound-details.left.padding #0.25
\tweak bound-details.right.padding #-1
\tweak bound-details.right-broken.padding #0.5
\tweak bound-details.left-broken.padding #2
\tweak bound-details.left-broken.text ##f
\tweak bound-details.right-broken.text ##f
\startTextSpan
#}
)
endStringNum = \stopTextSpan
\relative c {
\clef "treble_8"
c4_\beginStringNum 5 c c \times 2/3 { c8 c c\endStringNum }
}
Hi Nick,
Can't help you much with scheme, but this is the function I created for a
string number spanner...
% use: stringNumberSpanner #direction (UP/DOWN) #stringnumber #padding
stringNumberSpanner = #(define-music-function (parser location direction
string padding) (number? number? number?)
#{
\once \override Voice.TextSpanner.padding = #padding
\once \override Voice.TextSpanner.style = #'dashed-line
\once \override Voice.TextSpanner.dash-period = #0.6
\once \override Voice.TextSpanner.dash-fraction = #0.2
\once \override Voice.TextSpanner.bound-details.left.padding = #-0.1
\once \override Voice.TextSpanner.bound-details.right.padding = #-0.8
\once \override Voice.TextSpanner.bound-details.left.stencil-align-dir-y
= #CENTER
\once \override Voice.TextSpanner.font-encoding = #'latin1
\once \override Voice.TextSpanner.font-series = #'normal
\once \override Voice.TextSpanner.font-size = #-2.5
\once \override Voice.TextSpanner.bound-details.left.text = \markup {
\override #'(circle-padding . 0.55) \circle \upright $(number->string
string) }
\once \override Voice.TextSpanner.bound-details.left-broken.text =
\markup { \null }
\once \override Voice.TextSpanner.bound-details.left-broken.padding = #-3
\once \override Voice.TextSpanner.bound-details.right-broken.text =
\markup { \null }
\once \override Voice.TextSpanner.bound-details.right-broken.padding =
#0.5
\once \override Voice.TextSpanner.direction = #direction
\once \override Voice.TextSpanner.bound-details.right.text = \markup {
\draw-line $(cons 0 ( * -0.45 direction )) }
#})
As you say...according the the Internals reference, UP = 1 and DOWN = -1, so
I use that as a multiplier for the right hand end of the spanner to get an
upward or downward pointing end line. (last line of above code).
HTH.
Phil.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user