Adapting my previous code to work with spanners:

%%%%%
#(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)
      (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
                                       (if (ly:spanner? grob)
                                           (ly:spanner-bound grob LEFT)
                                           grob)))
            (ly:spanner-set-bound! span RIGHT
                                   (if (ly:spanner? grob)
                                       (ly:spanner-bound grob LEFT)
                                       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
  }
  \context {
    \Voice
    \consists Horizontal_bracket_engraver
    \override HorizontalBracket.direction = #UP

  }
}

\new Voice \relative c'' {
  <<
    { \repeat unfold 4 {c4} \repeat unfold 4 {c'4} }
    { s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s }
  >>
}

\new Voice \relative c'' {
  \override HorizontalBracket.details.align = ##t
  <<
    { \repeat unfold 4 {c4} \repeat unfold 4 {c'4} }
    { s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s }
  >>
}
%%%%%

Cheers,
Valentin

Am Montag, 15. Juli 2024, 06:34:18 MESZ schrieb Fennel:
> Per-system vertical alignment of all horizontal brackets is the goal. This
> can almost be achieved by adjusting the staff padding property (to a value
> large enough that no other objects will interfere with the brackets), but
> then we have the problem of the brackets being too far off of the staff for
> almost every system.
> 
> I’ll take a look at what you suggested, Valentin. Hopefully it works for
> what I need!
> 
> -Fennel
> 
> ​

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

Reply via email to