lilypond-user
[Top][All Lists]
Advanced

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

Re: how to change extents of a grob?


From: Jean Abou Samra
Subject: Re: how to change extents of a grob?
Date: Thu, 14 Apr 2022 18:05:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

Le 14/04/2022 à 11:41, Werner LEMBERG a écrit :
Or to ask in a different way: At the time when properties are
processed and you have to manipulate stencils, changing the stencil
of a grob doesn't change the extents of this grob, AFAICS.
You are not supposed to change stencils at all.  They are not
entities with identity.

Create a new stencil with different dimensions and use that.
OK, thanks.



I believe you are talking about different things. You shouldn't mutate
the internal expression contained in a stencil, sure. But a grob does
have identity. I understood Werner's question as "how to get grob's
extents recomputed when I do (ly:grob-set-property! grob 'stencil
some-new-stencil)?".

There is no general answer. If they have not been computed yet, no
problem. If they have, it is almost certainly too late to get them
recomputed. True, you can do
(ly:grob-set-property! grob '{X,Y}-extent (ly:stencil-extent the-stencil {X,Y})).
However, grob extents and coordinates are cached in C++ members as
soon as they have been computed once, to make their retrieval cheaper
because it's done often. Thus, modifying the {X,Y}-extent properties
will not affect code that gets them via ly:grob-extent or its C++
equivalent.

The solution is to try hard to write your code in a functional way,
with properties computed on-demand via callbacks rather than set
at a specific point of time. The grob-transformer often helps.

Best,
Jean




reply via email to

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