Mark Polesky wrote:
> So the command 
>   \override Fingering #'avoid-slur = ##f
> will trigger the warning only if there's actually a
> fingering in the score following the command.
> 
> Does anyone know an easier way to find which grobs 
> trigger this warning? Then I can incorporate it into
> the macro and save a little frustration for future
> users.

I just realized that for the macro to work properly, 
'avoid-slur really should be set to #f for all slur-hiding
grobs. Better yet would be a value like 'ignore (which
doesn't exist yet). Although I proposed it on -devel:

http://lists.gnu.org/archive/html/lilypond-devel/2009-04/msg00129.html

Anyway, the mess that looks like this:

  \override $context . $top-grob
   #(if (or ;; append to this list if you get the warning:
            ;; "Ignoring grob for slur: <grob>. avoid-slur not set?"
            (equal? $top-grob "Fingering")
            (equal? $top-grob "Accidental")
            )
        'stencil
        'avoid-slur) = ##f

...should really just be:

  \override $context . $top-grob #'avoid-slur = ##f

One compromise is to set 'avoid-slur to 'around:

  \override $context . $top-grob #'avoid-slur = #'around

This has the same effect of setting it to #f in many 
grobs, but not all, so it's not the ideal solution. The 
real problem then, is suppressing the warning messages
you get when setting 'avoid-slur to #f, which could easily
happen dozens of times during a single compile.

Off hand, I don't know how to do that, and if you do, you
may want to reply to the thread linked above. But the 
functionality of the macro comes first, so I'm attaching 
it, in what may be the final form for now, warning
messages and all.

Cheers.
- Mark



      
\version "2.13.0"

#(define (parse-grob-sym grob-sym)
     (let* ((grob-str  (symbol->string grob-sym))
            (dot-index (string-index grob-str #\.))
            (context   (if dot-index
                           (string-take grob-str dot-index)
                           "Voice"))
            (grob      (if dot-index
                           (substring grob-str (+ dot-index 1))
                           grob-str)))
       (cons context grob)))
       
hideCurvesFrom =
#(define-music-function
   (parser location grob-sym
                    x-padding
                    y-padding)
   (symbol? pair? pair?)
   (let* ((context  (car (parse-grob-sym grob-sym)))
          (top-grob (cdr (parse-grob-sym grob-sym))))
#{
  \override Tie #'layer = #-2
  \override Slur #'layer = #-2
  \override PhrasingSlur #'layer = #-2
  
  \override $context . $top-grob #'avoid-slur = ##f    
  \override $context . $top-grob #'layer = #-1
  \override $context . $top-grob #'stencil =
    #(lambda (grob)
    
       ;; get-stil-proc is a workaround because there may
       ;; be more than one 'stencil entry in basic-props
       (define (get-stil-proc alist)
         (let ((stil-proc (ly:assoc-get 'stencil alist)))
           (if (procedure-name stil-proc)
               stil-proc
               (begin (set! alist (assoc-remove! alist 'stencil))
                      (get-stil-proc alist)))))
                      
       (let* ((basic-props (ly:grob-basic-properties grob))
              (stil-proc (get-stil-proc basic-props))
              (this-stil (stil-proc grob))
              (stil-x-ext (ly:stencil-extent this-stil 0))
              (stil-y-ext (ly:stencil-extent this-stil 1))
              (box-x-ext (cons (- (car stil-x-ext) (car $x-padding))
                               (+ (cdr stil-x-ext) (cdr $x-padding))))
              (box-y-ext (cons (- (car stil-y-ext) (car $y-padding))
                               (+ (cdr stil-y-ext) (cdr $y-padding))))
              (box-w (- (cdr box-x-ext) (car box-x-ext)))
              (box-h (- (cdr box-y-ext) (car box-y-ext))))
      (ly:stencil-add
       (ly:make-stencil
        (list 'embedded-ps
         (ly:format
          (string-append "gsave\n"
                         "currentpoint translate\n"
                         "1 setgray\n"
                         "~a ~a ~a ~a rectfill\n"
                         "grestore\n")
          (car box-x-ext)
          (car box-y-ext)
          box-w
          box-h))
        stil-x-ext
        stil-y-ext)
       this-stil)))
#}))

revertHideCurvesFrom =
#(define-music-function
   (parser location grob-sym)
   (symbol?)
   (let* ((context  (car (parse-grob-sym grob-sym)))
          (top-grob (cdr (parse-grob-sym grob-sym))))
#{
  \revert Tie #'layer
  \revert Slur #'layer
  \revert PhrasingSlur #'layer
  \revert $context . $top-grob #'avoid-slur
  \revert $context . $top-grob #'layer
  \revert $context . $top-grob #'stencil
#}))

%%%%%%%%%%%%%%%%%% EXAMPLE %%%%%%%%%%%%%%%%%%
% {
\version "2.13.0"

\pointAndClickOff

\relative {
  \repeat volta 2 {
    
    %% syntax: \hideCurvesFrom [grob] [x-padding] [y-padding]
        
    % always call \hideCurvesFrom before the curve starts:
    \hideCurvesFrom #'Fingering           #'(0.3 . 0.3) #'(0 . 0)
    \hideCurvesFrom #'Staff.KeySignature  #'(0.3 . 0.3) #'(0 . 0)
    \hideCurvesFrom #'Staff.TimeSignature #'(0.3 . 0.3) #'(0 . 0)
    
    % a negative padding value can prevent whiteout near an edge:
    \hideCurvesFrom #'Staff.Clef          #'(0.3 . 0.3) #'(0 . -0.5)
    
    \clef bass
      \once \override TextScript #'extra-offset = #'(-8 . 0)
      e,2.\(^\markup \fontsize #-1 \italic
               {tacet la \concat {1 \super \lower #0.5 ma} volta:}
      d4( |
    
    \clef treble \key g \major
      c''4)^2 c2 b4~ |
    
    \time 3/4
      b2\) 
      % updating a previously entered command:
      \hideCurvesFrom #'Staff.Clef #'(0.3 . 0.3) #'(0 . 0)
      fis4( |
    
    \clef bass \time 2/4
      d,4)
      % always call \hideCurvesFrom before the curve starts:
      \hideCurvesFrom #'Score.VoltaBracket #'(0.3 . 0.8) #'(3 . 0)
      e4( |
  }
  
  \alternative {
    { r2 | }
    {
      % revert commands independently as needed:
      \revertHideCurvesFrom #'Score.VoltaBracket
      d2)
    }    
  }
    % revert commands when no longer needed:
    \revertHideCurvesFrom #'Fingering
    \revertHideCurvesFrom #'Staff.Clef
    \revertHideCurvesFrom #'Staff.KeySignature
    \revertHideCurvesFrom #'Staff.TimeSignature
}
%}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to