Re: slurs anchored at bar lines

"C. Stroppel" <[email protected]>
Newsgroups gmane.comp.gnu.lilypond.devel
Message-ID <[email protected]>
Hi Werner,

I'm not entirely sure if I understood the problem perfectly, and I hope 
I'm not missing the mark here. However, I have been experimenting with 
layout geometry callbacks, and the attached snippet might offer a 
solution to the issue you described.

Best regards
Christian
Slur-to-bar.ly (text/lilypond-source, 2 KB)
\version "2.24.0"

#(define (slur-over-bar rightOffset)
   (lambda (slur-grob)
     (let* ((system (ly:grob-system slur-grob))
            
            (cps (ly:grob-property slur-grob 'control-points))
            (end-cp (cadddr cps)) 
            (end-y (cdr end-cp))
            
            
            (slur-start-x (ly:grob-relative-coordinate slur-grob system X))
            (abs-end-x (+ slur-start-x (car end-cp)))
            
            
            (all-elts (ly:grob-array->list (ly:grob-object system 'all-elements)))
            (all-bars (filter
                       (lambda (g) (grob::has-interface g 'bar-line-interface))
                       all-elts))
            (all-next-bars (filter
                                      (lambda (b) (> (ly:grob-relative-coordinate b system X) abs-end-x))
                                      all-bars)))
       
       (if (not (null? all-next-bars))
           (let* ((sorted-bars (sort all-next-bars
                                               (lambda (b1 b2) 
                                                 (< (ly:grob-relative-coordinate b1 system X) 
                                                    (ly:grob-relative-coordinate b2 system X)))))
                  (next-bar (car sorted-bars))
                  (bar-x (ly:grob-relative-coordinate next-bar system X))
                  
                  
                  (new-relative-x (- (+ bar-x rightOffset) slur-start-x))
                  
                  
                  (new-end-cp (cons new-relative-x (- end-y 0.2)))
                  
                  (new-cps (list (car cps) (cadr cps) (caddr cps) new-end-cp)))
             
             (ly:grob-set-property! slur-grob 'control-points new-cps))))))


slurToBar = \once \override Slur.after-line-breaking = #(slur-over-bar 0)

\relative c'' {
    \slurToBar c4( d e f) |   
}

slurOverBar = \once \override Slur.after-line-breaking = #(slur-over-bar 1.8)

\relative c'' { 
  \slurOverBar c4( d e f) | 

}
Slur-to-bar.pdf (application/pdf, 29.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.