lilypond-user
[Top][All Lists]
Advanced

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

String number spanner


From: Nick Payne
Subject: String number spanner
Date: Fri, 28 Dec 2012 17:37:38 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

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 }
}



reply via email to

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