lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting grob Y position (spacing error)


From: Jean Abou Samra
Subject: Re: Getting grob Y position (spacing error)
Date: Fri, 18 Nov 2022 11:22:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1

Le 18/11/2022 à 00:29, Gregory Evans a écrit :

Hi lilypond users,
I have a question about getting the Y position of a grob. I saw this question has been asked previously but I could not find if it had been answered. In the following example, an after-line-breaking function is defined such that no change on the output should occur. The grob is only queried with |(ly:grob-extent grob ... Y)| but this value is not used. There is a difference in the vertical spacing between the staves of the staff group based on whether this query is present or not. The intention is to be able to query a grob for its Y position relative to another grob in order to draw cross-staff spanners, where it is necessary to calculate the distance between grobs not only on the X axis but also on the Y axis. Here, the system is being used to accurately get the X position, but using the system to get the Y position triggers this spacing error but appears to return the correct position before the spacing shift.



Because you are requesting it in after-line-breaking, which is earlier
than LilyPond can provide it to you. At this point of the compilation,
line breaking has just happened and page spacing (vertical spacing
of systems and staves in each system) has not happened yet. The
next thing LilyPond will do is computing the skylines (outlines) of the
staves in order to be able to space them. If you ask for the offset of some
staff relative to the system, it triggers these things prematurely
while they're not ready.

If you are writing a stencil callback, it is usually not OK to ask
for the coordinate of a staff relative to the whole system, because
it is a cyclic dependency: the coordinate depends on the spacing,
which depends on the outline, which depends on the stencil of your
grob. However, for cross-staff grobs, it is necessary, so if you
are writing one, you need to \override YourGrob.cross-staff = ##t,
and then LilyPond will completely ignore it for vertical spacing
purposes, and the stencil callback will only be run at a later point
where vertical spacing is already done.


\version "2.23.81"

\language "english"

#(set-global-staff-size 12)

\score {
    <<
        \new Staff {
            %% See what weird things happen to the beam if it's not
            %% properly marked cross-staff.
            \override Beam.cross-staff = ##f
            c'8[
            \change Staff = down
            c''8]
        }
        \new Staff = down {
            s4
        }
    >>
}


Best,
Jean



Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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