2012/11/6 David Kastrup <d...@gnu.org>: > Thomas Morley <thomasmorle...@googlemail.com> writes: [...] >> Sorry, that I can't work on it. As soon as C++ is in the game, I'm not >> able to play it. > > We still have the whitespace under meter thing. One can manually set a > length for the staff lines, but that seems like cheating. > > -- > David Kastrup
Hi David, I tried to set StaffSymbol 'width to the sum of the x-length of all occurring items at line-begin plus the spacing between them. But I doesn't work as expected. I still need a factor, which diversifies from case to case. What am I missing? %%%%%%% start snippet \version "2.17.6" #(define (read-out l1 l2) (define (helper ls1 ls2 ls3) "Filters all elements of ls1 from ls2 by their grob-name and appends it to ls3" (let ((grob-name-proc (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))) (if (null? ls1) ls3 (helper (cdr ls1) ls2 (append ls3 (filter (lambda (x) (eq? (car ls1) (grob-name-proc x))) ls2)))))) (helper l1 l2 '())) #(define (list-sum lst) (if (null? lst) 0 (+ (car lst) (list-sum (cdr lst))))) #(define (read-spacing-to-next-item l1) (let* ((grob-name-proc (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))) (grob-name-lst (map grob-name-proc l1))) (define (helper ls1 ls2 ls3) "ls1 - grob-list ls2 - grob-name-list) ls3 - empty list" (let* ((space-alist-proc (lambda (x) (ly:grob-property x 'space-alist)))) (if (null? (cdr ls2)) ls3 (helper (cdr ls1) (cdr ls2) (let ((value (assoc-ref (space-alist-proc (car ls1)) (ly:camel-case->lisp-identifier (if (eq? (cadr ls2) 'BarLine) 'StaffBar (cadr ls2)))))) (cons (if (pair? value) (cdr value) 0) ls3)))))) (helper l1 grob-name-lst '()))) #(define (lisp-identifier->camel-case symbol) (string-concatenate (map (lambda (x) (string-capitalize x)) (string-split (symbol->string symbol) #\- )))) #(define (grobs-to-consider-at-line-begin l) (let* ((break-alignment (car (read-out (list 'BreakAlignment) l))) (break-align-orders (vector->list (ly:grob-property break-alignment 'break-align-orders))) (break-align-orders-at-linebegin (car (last-pair break-align-orders)))) (map (lambda (x) (string->symbol (if (eq? x 'staff-bar) "BarLine" (lisp-identifier->camel-case x)))) break-align-orders-at-linebegin))) #(define (delete-adjacent-equal-named-grobs lst) (let* ((grob-name-proc (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))) (fold-right (lambda (elem ret) (if (equal? (grob-name-proc elem) (grob-name-proc (first ret))) ret (cons elem ret))) (list (last lst)) lst))) newStaffSymbolWidth = \override Staff.StaffSymbol #'after-line-breaking = #(lambda (grob) (let* ((sys (ly:grob-system grob)) (all-elts (ly:grob-array->list (ly:grob-object sys 'all-elements))) (grobs-to-consider (grobs-to-consider-at-line-begin all-elts)) (grob-list (delete-adjacent-equal-named-grobs (read-out grobs-to-consider all-elts))) ;(grob-list (read-out grobs-to-consider all-elts)) (grobs-x-length-proc (lambda (x) (interval-length (ly:grob-extent x sys X)))) (grobs-x-length-list (map grobs-x-length-proc grob-list)) (summed-grobs-x-length (list-sum grobs-x-length-list)) (spacing-lengths-lst (read-spacing-to-next-item grob-list)) (summed-spacing-lengths (list-sum spacing-lengths-lst)) (new-width (* 1.66 (+ summed-grobs-x-length summed-spacing-lengths)))) ; (write all-elts) ; (newline)(write grob-list) (ly:grob-set-property! grob 'width new-width))) % --- test { \newStaffSymbolWidth \clef "bass" \time 2/2 \key cis\major s4 } \new GrandStaff << $@(make-list 6 #{\new Staff { \newStaffSymbolWidth s4 } #}) >> %%%%%% end snippet BTW, is there any reason BarLine is called staff-bar in 'space-alist and 'break-align-orders? Regards, Harm P.S:Same code as above attached as a file.
white-space-under-meter.ly
Description: Binary data
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user