lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Whiteout box function by Thomas Morley / need help


From: Karol Majewski
Subject: Re: Whiteout box function by Thomas Morley / need help
Date: Sun, 06 Mar 2016 10:55:32 +0100

OK, it seems that \override DynamicLineSpanner.vertical-skylines = #'() does the job.

 

There is an issue with DynamicText placed at the end of hairpin.

 

If DynamicText is placed after the end of hairpin and some extraWhiteout is added to the left of DynamicText then the whole DynamicText is shifted to the right.

 

I want DynamicText to stay centered below note. Any suggestions are appreciated.

 

Here's an example:

 

BEGIN====================================

 

moreWhiteout =
#(define-music-function (parser location adds item)(pair? symbol-list-or-music?)
  (define more-stencil-whiteout
    (lambda (grob)
      (let* ((function (assoc-get 'stencil
                            (reverse (ly:grob-basic-properties grob))))
             (stil
                   (if (and (procedure? function)
                            (not (eq? (procedure-name function)
                                      'more-stencil-whiteout)))
                       (function grob)
                       (begin
                         (ly:warning "~a has no stencil. Ignoring" grob)
                         #f))))
        (if stil
            (let*((x-ext (ly:stencil-extent stil X))
                  (y-ext (ly:stencil-extent stil Y))
                  (add-to-x-ext (if (pair? (car adds)) (car adds) adds))
                  (add-to-y-ext (if (pair? (cdr adds)) (cadr adds) '(0 . 0)))
                  ;(self-alignment-X (ly:grob-property grob 'self-alignment-X))
                  (new-stil
                    (ly:make-stencil
                       (ly:stencil-expr stil)
                       (offset-add x-ext add-to-x-ext)
                       (offset-add y-ext add-to-y-ext))))
              ;(display self-alignment-X)
              (if (grob::has-interface grob 'dynamic-text-interface)
                  (let* ((new-stencil-length
                           (interval-length (ly:stencil-extent new-stil X)))
                         (orig-stencil-length
                           (interval-length (ly:stencil-extent stil X))))
                    (ly:grob-set-property! grob 'self-alignment-X
                      (if (not (= 0 (- new-stencil-length orig-stencil-length)))
                          (/ (- (- new-stencil-length (cdr add-to-x-ext))
                                (+ orig-stencil-length (cdr add-to-x-ext)))
                             new-stencil-length)
                          0))))
              new-stil)
            #f))))
  #{
    \tweak layer #10
    \tweak whiteout ##t
    \tweak stencil #more-stencil-whiteout #item
  #})

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

\layout {
  \override DynamicText.extra-spacing-width = #'(+inf.0 . -inf.0)
}

musicI = { \time 2/4 \repeat unfold 16 b8 }

musicII = {
  r2
  b4 -\moreWhiteout #'((-2 . 0.5)(0 . 0)) ^"XXXXXX" -\moreWhiteout #'(0 . 4) ^"YYYYYY"
  b
  r ^\<
  r
  b4 -\moreWhiteout #'((-6 . 0) (-1 . 1)) ^\"pp" b
}

\new StaffGroup <<
  \new Staff \relative c'' \musicI
  \new Staff \relative c'' \musicII
>>

 

END==========================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]