lilypond-user
[Top][All Lists]
Advanced

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

Retrieve height of text spanner above stave in music function


From: Nick Payne
Subject: Retrieve height of text spanner above stave in music function
Date: Thu, 16 Dec 2010 14:25:35 +1100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

I have a music function I use for barring indications in guitar music. I'd like to be able to add some code to it to drop a vertical line from the start of the TextSpanner to the position on the staff indicating how many strings to cover (see attached png for an example), but to do that I need to know the distance in staff units between the staff and the TextSpanner, and I haven't been able to figure out how to retrieve this value. This is what I have so far - works fine for drawing the horizontal elements:

barre = #(define-music-function (parser location fretnum osp dirn shorten adjBreak adjEnd)
    (string? number? number? pair? number? number?)
#{
    % set osp to 999 if spanner is colliding with another element
    % this will position the spanner outside all other elements
    % can be normally be set to zero
    \once \override TextSpanner #'outside-staff-priority = #$osp
    \once \override TextSpanner #'bound-details #'left #'text =
    \markup { \concat { "C" $fretnum " " } }
    \once \override TextSpanner #'style = #'line
    \once \override TextSpanner #'font-shape = #'upright
    \once \override TextSpanner #'direction = #$dirn
    %draw a bracket edge on RHS
\once \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #(cons 0 (/ $dirn -1)) }
    % set alignment of line with reference to left text
\once \override TextSpanner #'bound-details #'left #'stencil-align-dir-y = #CENTER
    % change X pos of LH and RH end as desired
\once \override TextSpanner #'bound-details #'left #'padding = #(car $shorten) \once \override TextSpanner #'bound-details #'right #'padding = #(cdr $shorten)
    % allow adjustment of line end when it wraps to following stave
\once \override TextSpanner #'bound-details #'right-broken #'padding = #$adjEnd % adjust LH end of line when it wraps to following stave so that it doesn't
    % extend to the left of the notes on the stave
\once \override TextSpanner #'bound-details #'left-broken #'X = #$adjBreak
    % optional override to remove text and bracket edge at line breaks
    \once \override TextSpanner #'bound-details #'left-broken #'text = ##f
    \once \override TextSpanner #'bound-details #'right-broken #'text = ##f
#})

\relative c'' {
\barre "V" #0 #UP #'(-1 . -1) #10 #0.5 c4\startTextSpan \repeat unfold 18 { c } c\stopTextSpan
}

Attachment: barre.png
Description: PNG image


reply via email to

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