On 20.11.2016 15:13, dtsmarin wrote:
I'm sorry, I thought it was easy to understand that I simply took Thomas's
code and inserted the \RemoveAllEmptyStaves command. (My file has nothing to
do with this error.)

Anyway I attached the problematic code.

It’s easily fixed by an extra line catering for the case that the SystemStartSquare collapses lacking staves to span. See attached.

Best, Simon
\version "2.19.50"

\version "2.19.49"

#(define (lists-map function ls)
   "Apply @var{function} to @var{ls} and all of it sublists. 
First it recurses over the children, then the function is applied to 
@var{ls}."
   (if (list? ls)
       (set! ls (map (lambda (y) (lists-map function y)) ls))
       ls)
   (function ls))

#(define (change-width x y)
   "Adds values @var{x} and @var{y} to certain elements of a list, which starts 
with @code{'draw-line}."
   (lambda (e)
     (if (and (list? e) (member 'draw-line e))
         `(,@(take e 3)
            ,((if (negative? (fourth e)) + -) (fourth e) y)
            ,(if (not (zero? (fifth e))) (+ x (fifth e)) (fifth e))
            ,((if (negative? (last e)) + -) (last e) y))
         e)))

#(define* (resize-square x #:optional (y #t))
   "Applies @code{change-width} to the stencil-expression of a grob, which is 
supposed to be SystemStartSquare. 

@var{x} will resize the length of the horizontal wings. 

The optional @var{y} affects the general size in Y-direction, it's default is 
@code{#t}: 
- SystemStartSquare is off by half staff-line-thickness compared to the staves, 
this default may or may not be intended. The default for @var{y} corrects it. 
- If set to a number the size is freely customizable. 
- If set to false, the size in Y-direction is not touched. 

Using this procedure causes the need to reset the padding of the 
SystemStartSquare. 
"
   (lambda (grob)
     (let* ((default-stil (ly:system-start-delimiter::print grob))
            (default-stil (if (ly:stencil? default-stil) default-stil empty-stencil))
            (staff-line-thick (ly:staff-symbol-line-thickness grob))
            (y-corr
             (cond ((number? y) (- y))
               ((eq? #t y) (/ staff-line-thick 2))
               (else 0))))
       ;; n.b.
       ;; the final stencil has the same x- and y-extent as the original
       (ly:make-stencil
        (lists-map (change-width x y-corr) (ly:stencil-expr default-stil))
        (ly:stencil-extent default-stil X)
        (ly:stencil-extent default-stil Y)))))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\new StaffGroup
\with {
  \override SystemStartBracket.padding = 0.5
  systemStartDelimiter = #'SystemStartBracket
}
<<
  \new Staff { c'4 }
  \new StaffGroup
  \with {
    %% next two commands for better visibility only
    %\override SystemStartSquare.color = #cyan
    %\override SystemStartSquare.layer = 2000
    \override SystemStartSquare.stencil = #(resize-square 0.8)
    \override SystemStartSquare.padding = -0.2
    systemStartDelimiter = #'SystemStartSquare
  }
  <<
    \new StaffGroup
    \with {
      %% next command for better visibility only
      %\override SystemStartSquare.color = #red
      \override SystemStartSquare.stencil = #(resize-square 1.6)
      \override SystemStartSquare.padding = -0.2
      systemStartDelimiter = #'SystemStartSquare
    }
    <<
      \new Staff { c'4 }
      \new Staff  \with {   \RemoveAllEmptyStaves } {  }
    >>

    \new Staff { c'4 }
  >>
  \new Staff { c'4 }
>>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to