[squeak-dev] Morphic - wrong extent after adding submorph?
Marcel Taeumel
marcel.taeumel at hpi.de
Mon Jul 19 07:20:49 UTC 2021
Hi Bernhard --
> I wonder if this is a bug? Or does one have to send a special message to a morph after adding submorphs to it?
For several reasons, layout computation is lazy, normally triggered by the drawing cycle via #fullBounds. You can verify that by calling #openInWorld on that rowMorph. It will look correct.
As a rule of thumb, you should not write such layout-specific code "manually" (e.g. override #extent:) but always use a (custom) LayoutPolicy. At best, you can compose your entire morph hierarchy with the existing layout policies, configured to your needs (e.g. #hResizing:, #listCentering:, ...).
If you want to debug your layout, try this:
rowMorph fullBounds.
{stringMorph extent. rowMorph extent}.
Or this:
rowMorph layoutComputed
ifFalse: [rowMorph doLayoutSafely].
{stringMorph extent. rowMorph extent}.
Hope this helps. :-)
Best,
Marcel
Am 17.07.2021 21:51:17 schrieb Bernhard Pieber <bernhard at pieber.com>:
Hi,
I would have expected that when I wrap a morph in another morph, which has resizing set to #shrinkWrap, that the wrapping morph should have the same extent as the wrapped morph. However, this seems not to be the case:
| stringMorph rowMorph |
stringMorph := 'Morphic is great' asMorph.
rowMorph := Morph new color: Color transparent;
layoutPolicy: TableLayout new;
listDirection: #leftToRight;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
yourself.
rowMorph addMorph: stringMorph.
{stringMorph extent. rowMorph extent}. {97 at 14 . 50 at 40}
I wonder if this is a bug? Or does one have to send a special message to a morph after adding submorphs to it?
Cheers,
Bernhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210719/4c3126a5/attachment.html>
More information about the Squeak-dev
mailing list
|