squeak-smalltalk / squeak-object-memory

Issues and assets related to the Squeak object memory.
https://bugs.squeak.org
MIT License
13 stars 1 forks source link

TableLayout Morph with `#shrinkWrap` property does not shrink when children are removed #74

Open LinqLover opened 1 year ago

LinqLover commented 1 year ago

Minimal example:

m := Morph new.
m changeTableLayout.
m vResizing: #shrinkWrap.

m openInHand.

m addMorph: (Morph new color: Color red; extent: 200 px asPoint).

m removeAllMorphs.
self assert: m height = 0.

Actually, I even wonder why the freshly initialized morph does not have the height 0 ... Is this a bug or expected behavior?

This behavior is probably caused by the "0) Quick return." check in Morph>>#doLayoutIn:.

LinqLover commented 1 year ago

This issue can be observed in vita in Morphic-ct.2051 (inbox) where I needed to add one "redundant" height: 0 send in KeyboardExerciser>>#clear.

marceltaeumel commented 1 year ago

That's expected. A shrink-wrapped morph without any submorphs will keep its size. It will not shrink to 0.

marceltaeumel commented 1 year ago

See comment in Morph >> #doLayoutIn:.

marceltaeumel commented 1 year ago

This behavior is probably caused by the "0) Quick return." check in Morph>>#doLayoutIn:.

There you have even found the commentary on the expected behavior ;-) ... so, why this issue?

LinqLover commented 1 year ago

Well, then I had (or still have) a different understanding of #shrinkWrap. :-) The comment in #hResizing: et al. says:

resize to fit children

And "shrink wrap" to me indicates "clearly "if there are n children, shrink to their (total) size, if there is 1 child, shrink to its size, if there are 0 children, shrink to 0". Why should I need to do this manually? :-)

marceltaeumel commented 1 year ago

Think of interactive, drag-and-drop interfaces. The user would not be able to re-insert a thing into a zero-width container.

LinqLover commented 1 year ago

Wouldn't that be a case for #minimumWidth or similar? If your dnd container had a tiny label/decoration at its top, dnd would still be very inconvenient ...

marceltaeumel commented 1 year ago

Please sketch the scenario you are actually working with. No toy example. :-)

LinqLover commented 1 year ago

Took me a while to find the motivating situation for this one-year-old issue from my change logs, but I finally found it:

KeyboardExerciser>>#clear ct 11/19/2022 20:12 (https://lists.squeakfoundation.org/archives/list/squeak-dev%40lists.squeakfoundation.org/message/GR7PHVTIVXGLXXWTYVX22JIK5E3LQWYP/#:~:text=keyboardexerciser%3E%3Eclear)

That height: 0 there should not be necessary (but if you comment it out, the tool does not shrink after changing the keyboard mode until you press the next key).