lilypond-devel
[Top][All Lists]
Advanced

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

Re: Cross-staff stem engraver (was: New frog in an empty pond?)


From: Joe Neeman
Subject: Re: Cross-staff stem engraver (was: New frog in an empty pond?)
Date: Sat, 25 Feb 2012 13:59:26 -0800


On Sat, Feb 25, 2012 at 5:49 AM, Pavel Roskin <address@hidden> wrote:
Quoting Joe Neeman <address@hidden>:

On Fri, Feb 24, 2012 at 3:04 PM, Pavel Roskin <address@hidden> wrote:
I tried writing an engraver that could be added to the StaffGroup
context.  Collecting stems is not a problem.  The problem is that even
the finalize handler is called to early.  I'm getting a warning:

programming error: vertical alignment called before line breaking
continuing, cross fingers


It's a little hard to guess what's going wrong without knowing exactly what
you've tried. Are you trying to do layout logic in the engraver (ie. by
collecting stems, reading their properties, doing calculations and then
setting more properties)?

Yes, except that I'm not setting anything yet.  The current file is attached.

The problem is where you ask for the stem Y-extent relative to yref (the VerticalAlignment): in order to calculate the vertical distance between the various staves and the VerticalAlignment, line breaking needs to be done first. (And line breaking doesn't happen until after all the engravers are done.)



If you are, the first step is to move the layout
logic into grob callbacks.

I guess I'll need to redefine the stencil for stems.  Or maybe you mean some other callback?

You could redefine stencil, but I think redefining length would be easier.

I did a similar thing before.  I put all the logic into a function that was used to redefine the length property of the stem.  It worked for a simple case of two stems, but failed when three stems needed to be connected.  The Y-extent for at least one of the stems wasn't calculated yet.

Can you be more specific about the Y-extent not being calculated yet? When you ask for the Y-extent, the calculation should be triggered if it hasn't already happened.

As a general approach, setting length sounds like a reasonable way forward. In addition, I'd suggest creating a new stem in process-acknowledged, then doing

(set! (ly:grob-object new-stem 'spanned-stems) old-stems)
(set! (ly:grob-property new-stem 'length) your-length-callback)

In your length callback, you read back the spanned-stems object and do your calculations. Is this similar to what you tried?

Cheers,
Joe

reply via email to

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