Hello Werner, hello Fennel,

> As far as I can see, LilyPond doesn't provide a 'container line' as
> you imagine.  I'm quite sure that this can be programmed in Scheme,
> but someone™ has to do that...  But maybe a different, simpler
> solution can be found; let's see what other guys come up with.

In fact we can do this with quite little effort:

%%%%%
#(define (outside-staff-collecting-engraver context)
   (let* ((span_up #f) (span_down #f))
   (make-engraver
    ((initialize engraver)
     (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '()))
     (ly:grob-set-property! span_up 'transparent #t)
     (ly:grob-set-property! span_up 'direction UP)
     (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '()))
     (ly:grob-set-property! span_down 'transparent #t)
     (ly:grob-set-property! span_down 'direction DOWN))
    (acknowledgers
     ((outside-staff-interface engraver grob source-engraver)
      (display grob)
      (if (assoc-get 'align (ly:grob-property grob 'details))
          (let* ((d (ly:grob-property grob 'direction))
                 (span (if (= d UP) span_up span_down)))
            (ly:grob-set-parent! grob Y span)
            (if (null? (ly:spanner-bound span LEFT))
                (ly:spanner-set-bound! span LEFT grob))
            (ly:spanner-set-bound! span RIGHT grob)
            (ly:grob-set-property! grob 'outside-staff-priority #f)
            (ly:grob-set-property! grob 'Y-offset 0))))))))

\layout {
  \context {
    \Staff
    \consists #outside-staff-collecting-engraver
  }
}

\relative c'' {
  \override TextScript.details.align = ##t
  c_"I"^"a" c'_"II"^^ c,,_"III"^+ c'_"IV"^"d"\break
  g_"A"^"e" g'_"B"^"f" g,,_"C"^"g" g'_"D"^"h"
}

\relative c'' {
  \override TextScript.details.align = ##t
  \override Script.details.align = ##t
  c_"I"^"a" c'_"II"^^ c,,_"III"^+ c'_"IV"^"d"\break
  g_"A"^"e" g'_"B"^"f" g,,_"C"^"g" g'_"D"^"h"
}
%%%%%

This will create an invisible TextSpanner above and below the staff and set Y 
parent of oos grobs with details.align set to #t to the spanner corresponding 
with it’s direction.

Cheers,
Valentin

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to