Manual shrink-wrapping to submorphs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Manual shrink-wrapping to submorphs

marcel.taeumel (old)
Hi, there!

As this does not work because the quasi-global coordinate system interferes:

self bounds: self submorphBounds.

How about adding a new method #shrinkWrap to morphs:

shrinkWrap
        "Change bounds to match submorphBounds."

        self submorphBounds in: [:newBounds |
                | deltaPosition |
                deltaPosition := newBounds topLeft - self topLeft.
                self submorphsDo: [:morph |
                        morph topLeft: morph topLeft - deltaPosition].
                self
                        topLeft: self topLeft + deltaPosition;
                        extent: newBounds extent].

Best,
Marcel