[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Whiteout box function by Thomas Morley / need help
From: |
Thomas Morley |
Subject: |
Re: Whiteout box function by Thomas Morley / need help |
Date: |
Thu, 24 Apr 2014 23:01:40 +0200 |
2014-04-21 16:40 GMT+02:00 Karol Majewski <address@hidden>:
> Harm,
>
> this change is related to issue 621:
> http://code.google.com/p/lilypond/issues/detail?id=621
>
> Now, I do not accept this solution. It is simply against the rules.
> DynamicText shouldn't have influence on spacaing. Therefore I prefer whiteout.
>
> So I use:
>
> \context {
> \Staff
> \override DynamicText.extra-spacing-width = #'(+inf.0 . -inf.0)
> }
>
> Note that your previous function (the one that contains
> flexible-stencil-whiteout) works well with DynamiText. But the drawback is
> that it doesn't allow to set left and right X-extent.
>
> -- Karol
Hi Karol,
below the newest version.
DynamicText is special-cased and it always returns a visual output for
DynamicText like
'self-alignment -X = CENTER
Please test:
\version "2.19.4"
moreWhiteout =
#(define-music-function (parser location grob-name adds)(string? pair?)
"
Increases the grob-stencil for 'whiteout, setting the 'layer to 10.
DynamicText is special-cased:
It's 'self-alignment-X is calculated to ensure same visual output as if
'self-alignment-X = CENTER
TODO: Make it work for other values of 'self-alignment-X
"
(define more-stencil-whiteout
(lambda (grob)
(let* ((function (assoc-get 'stencil
(reverse (ly:grob-basic-properties grob))))
(stil ;; Ugh, is there no better way to test that a grob has no
;; 'stencil and that no other previous procedure assigned
;; a stencil-value to said grob?
(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)
;(and (not (null? self-alignment-X)) (= 0 self-alignment-X))
(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))))
#{
\once \override $grob-name . layer = #10
\once \override $grob-name . whiteout = ##t
\once \override $grob-name . stencil = #more-stencil-whiteout
#})
%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%
\layout {
\override DynamicText.extra-spacing-width = #'(+inf.0 . -inf.0)
}
musicI = { \time 2/4 \repeat unfold 16 b8 }
musicII = {
r2
%% apply to X- and Y-axis
\moreWhiteout TextScript #'((-2 . 0.5)(0 . 2))
b4^"XXXXXX"
b
r
\moreWhiteout DynamicText #'((-3.2 . 4.12)(0 . 0))
r^\pppp
%% apply to X-axis only
\moreWhiteout TextScript #'(-2 . 10.5)
b4^"XXXXXX" b
}
\new StaffGroup <<
\new Staff \relative c'' \musicI
\new Staff \relative c'' \musicII
>>
Cheers,
Harm
- Re: Whiteout box function by Thomas Morley / need help, (continued)
- Re: Whiteout box function by Thomas Morley / need help, David Kastrup, 2014/04/07
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/07
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/09
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/09
- Re: Whiteout box function by Thomas Morley / need help, Thomas Morley, 2014/04/09
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/21
- Re: Whiteout box function by Thomas Morley / need help, Thomas Morley, 2014/04/21
- Re: Whiteout box function by Thomas Morley / need help, Thomas Morley, 2014/04/21
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/21
- Re: Whiteout box function by Thomas Morley / need help, Thomas Morley, 2014/04/21
- Re: Whiteout box function by Thomas Morley / need help,
Thomas Morley <=
- Re: Whiteout box function by Thomas Morley / need help, Karol Majewski, 2014/04/25
- Re: Whiteout box function by Thomas Morley / need help, David Kastrup, 2014/04/22