|
After a small discussion with Bert, I realized that you normally do layouting *only* for your submorphs. This is fine for #rigid and #spaceFill behavior because you need your owner's data to layout. However, #shrinkWrap, as it is currently implemented in a similar way, has nothing to do with your owner.
I vote for being able to implement #shrinkWrap behavior in your own layout policy:
| shrinkWrappedMorph |
shrinkWrappedMorph := Morph new layoutPolicy: ShrinkWrapLayout new.
shrinkWrappedMorph addMorph: Morph new.
shrinkWrappedMorph addMorph: Morph new.
shrinkWrappedMorph addMorph: Morph new.
self assert: shrinkWrappedMorph fullBounds = shrinkWrappedMorph submorphBounds.
As for now, this would be against the concept of layout policies and how they are implemented in Morph. We should anticipate such behavior and thus allow policies to work -- even w/o any submorph present.
As I look through TableLayout >> #layoutTopToBottom:in:, this is already happening:
| shrinkWrappedMorph |
shrinkWrappedMorph := Morph new layoutPolicy: TableLayout new.
shrinkWrappedMorph vResizing: #shrinkWrap; hResizing: #shrinkWrap.
shrinkWrappedMorph addMorph: Morph new.
shrinkWrappedMorph addMorph: Morph new.
shrinkWrappedMorph addMorph: Morph new.
self assert: shrinkWrappedMorph fullBounds = shrinkWrappedMorph submorphBounds.
You don't need a parent with a layout policy that realizes your shrinkWrap-behavior. Thus, there is no reason for a morph to prevent a policy from working when there is no submorph present.
Best,
Marcel
|