Quoting Joe Neeman <joenee...@gmail.com>:
I'm getting a message "Weird stem", and I don't see how to avoid it.
Perhaps I should create a totally new grob with a unique name, such as
StemSpan. Is that possible? What would be needed?
It would be nice to do this eventually, because having a different grob
name would make it easier for the users to tweak it. I think it would
involve editing scm/define-grobs.scm, but there may be a way to do it from
an .ly file also
It turn out the message comes from ly:stem::offset-callback and can be
suppressed by redefining X-offset.
Don't use ly:axis-group-interface::add-element, because stems don't
implement the axis-group-interface. (Removing this will also remove the
axes warning.) Instead, use ly:grob-set-parent!. You'll probably want to
set both the X parent and the Y parent. Then the X and Y offsets of
new-stem will be measured relative to stem (instead of relative to the
whole system, which is the default).
That was it! I have a working solution now! It will need to be
improved to ignore rests and other invisible stems, check the
cross-staff property, avoid connecting incompatible stems and so on.
The old stems should be made transparent. But all that should be
simple. Once I have something easy to use, I plan to submit it to the
LSR.
Actually, it looks like System is a better Y-parent for the new stem.
Perhaps I'll try to use the common reference of the stems to be
connected.
Here's what I have now (attached).
Thank you for your help!
--
Regards,
Pavel Roskin
\version "2.14.2"
#(define (extent-combine extents)
(if (pair? (cdr extents))
(interval-union (car extents) (extent-combine (cdr extents)))
(car extents)))
#(define (stemSpanExtent grob)
(let* ((yref (ly:grob-parent grob Y))
(stems (ly:grob-object grob 'spanned-stems))
(extents (map (lambda (x) (ly:grob-extent x yref Y)) stems))
(maxextent (extent-combine extents)))
maxextent))
#(define (stemSpanStencil grob)
(let* ((stem (car (ly:grob-object grob 'spanned-stems)))
(xextent (ly:grob-extent stem stem X))
(yextent (stemSpanExtent grob)))
(make-filled-box-stencil xextent yextent)))
#(define (reparentStems ctx stems trans)
(if (and (pair? stems)
(pair? (cdr stems)))
(let* ((stem (car stems))
(new-stem (ly:engraver-make-grob trans 'Stem '())))
(ly:grob-set-parent! new-stem X stem)
(set! (ly:grob-object new-stem 'spanned-stems) stems)
(set! (ly:grob-property new-stem 'X-offset) 0)
(set! (ly:grob-property new-stem 'stencil) stemSpanStencil))))
#(define (Cross_staff_stem_engraver ctx)
(let ((stems '()))
`((acknowledgers
(stem-interface
. ,(lambda (trans grob source)
(set! stems (cons grob stems)))))
(process-acknowledged
. ,(lambda (trans)
(reparentStems ctx stems trans) (set! stems '()))))))
\layout {
\context {
\PianoStaff
\consists #Cross_staff_stem_engraver
}
}
\new PianoStaff <<
\new Staff { \stemUp g'4 a' <b' g'> \stemDown c' }
\new Staff { \stemUp f'4 e' <f' d'> \stemDown c''' }
>>
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel