[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \parenthesize script on cross-staff-beamed note fails
From: |
Thomas Morley |
Subject: |
Re: \parenthesize script on cross-staff-beamed note fails |
Date: |
Sat, 15 Aug 2015 16:00:16 +0200 |
2015-08-15 15:45 GMT+02:00 Thomas Morley <address@hidden>:
> 2015-08-15 14:22 GMT+02:00 Malte Meyn <address@hidden>:
>> Am 15.08.2015 um 10:43 schrieb Malte Meyn:
>>>
>>> Hi list,
>>>
>>> in the following example, the \parenthesize command doesn’t respect the
>>> width of the parenthesized script (same problem for other scripts like
>>> fermata).
>>>
>>> %%%%%%%%%%%%%%%%%%%
>>> \version "2.19.25"
>>>
>>> <<
>>> \new Staff = "upper" {
>>> s4
>>> }
>>> \new Staff {
>>> b16-\parenthesize-> b b
>>> \change Staff = upper
>>> b
>>> }
>>> >>
>>> %%%%%%%%%%%%%%%%%%%
>>>
>>> Malte
>>>
>> Problem: \parenthesize uses ly:relative-group-extent to compute the X-extent
>> of the accent (see output-lib.scm). This function looks for the cross-staff
>> property and ignores all things that have this set to true
>> (axis-group-interface.cc).
>>
>> According to the internals reference 3.2.45 (grob-interface) the cross-staff
>> property is used for things that have a Y-extent that depends on inter-staff
>> spacing. So why are cross-staff things ignored in general and not only when
>> a == Y_AXIS in Axis_group_interface::relative_maybe_bound_group_extent?
>
>
> ly:relative-group-extent can't be the single problem.
> In the snippet below I redefined it.
>
> All instances of
> programming error: Improbable offset for stencil: inf staff space
> are fixed then and the visual output is ok, but
> programming error: Grob direction requested while calculation in progress.
> stil occurs - loads more of same kind, if I add other stuff.
>
> \version "2.19.25"
>
> #(define (ly:relative-group-extent elements common axis)
> "Determine the extent of elements relative to common in the axis direction."
> (let* ((elts
> (cond
> ((ly:grob? elements) (list elements))
> ((ly:grob-array? elements) (ly:grob-array->list elements))
> ((every ly:grob? elements) elements)
> (else '())))
> (exts
> (map
> (lambda (g) (ly:grob-extent g common axis))
> elts))
> (ext
> (reduce
> interval-union
> (car exts)
> (cdr exts))))
> ext))
>
> %% c/p from output-lib.scm to provide
> %% a compilable snippet
> #(define (parenthesize-elements grob . rest)
> (let* ((refp (if (null? rest)
> grob
> (car rest)))
> (elts (ly:grob-array->list (ly:grob-object grob 'elements)))
> (get-friends
> (lambda (g)
> (let ((syms (ly:grob-property g 'parenthesis-friends '()))
> (get-friend (lambda (s)
> (let ((f (ly:grob-object g s)))
> (cond
> ((ly:grob? f) (list f))
> ((ly:grob-array? f)
> (ly:grob-array->list f))
> (else '()))))))
> (apply append (map get-friend syms)))))
> (friends (apply append elts (map get-friends elts)))
> (x-ext (ly:relative-group-extent friends refp X))
> (stencils (ly:grob-property grob 'stencils))
> (lp (car stencils))
> (rp (cadr stencils))
> (padding (ly:grob-property grob 'padding 0.1)))
> (ly:stencil-add
> (ly:stencil-translate-axis lp (- (car x-ext) padding) X)
> (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X))))
>
> %% adding a color for indication purpose
> %% otherwise c/p from output-lib.scm
> #(define-public (parentheses-item::print me)
> (let* ((elts (ly:grob-object me 'elements))
> (y-ref (ly:grob-common-refpoint-of-array me elts Y))
> (x-ref (ly:grob-common-refpoint-of-array me elts X))
> (stencil (parenthesize-elements me x-ref))
> (elt-y-ext (ly:relative-group-extent elts y-ref Y))
> (y-center (interval-center elt-y-ext)))
> (ly:stencil-translate
> (stencil-with-color stencil red)
> (cons
> (- (ly:grob-relative-coordinate me x-ref X))
> (- y-center (ly:grob-relative-coordinate me y-ref Y))))))
>
> <<
> \new Staff = "upper" {
> s4
> }
> \new Staff {
> \override ParenthesesItem.stencil = #parentheses-item::print
> b16-\parenthesize->-3 b b
> \change Staff = upper
> b
> }
>>>
>
>
>
> Cheers,
> Harm
Only thing I've found to circumvent
programming error: Grob direction requested while calculation in progress.
is to use \voiceXxx and sometimes adding direction-indicators:
<<
\new Staff = "upper" {
s4
}
\new Staff {
\override ParenthesesItem.stencil = #parentheses-item::print
\voiceOne
b16-\parenthesize _> _- -3 b b
\change Staff = upper
\voiceTwo
b
}
>>