Bill,
Mostly right on in your interpretation.
On Mon, 30 Dec 2002 15:40:05 -0800 Bill Spight bspight@pacbell.net wrote:
Let me see if I understand what is going on.
You could override the #extent: method to do something like:
In resizing the morph is sent an #extent: message. We make sure the new extent has the correct proportions.
Yup.
extent: aPoint
x _ aPoint x. y _ aPoint y. (y * aspectRatio) > x ifTrue: [ x _ y * aspectRatio ] ifFalse: [ y _ x / aspectRatio ].
Doing it this way makes for the greater extent, which is faster when expanding.
I could easily have picked smaller rather than greater. Since it wasn't specified, I flipped a coin.
^super extent: (x@y) rounded
x@y is rounded because drawing requires an integral number of pixels.
I think the low-level stuff mostly handles non-integers, but there are at least a few places where fractional coordinates have caused problems for me before, so I tried to be sure the code would run without actually running it.
Sending this message to super avoids the extra processing if it were sent to self. (And also avoids an infinite loop when rounding).
Well, the infinite loop is "the" issue here. If the last line were
^self extent: (x@y) rounded
you would be in for a long wait (as in "How long does it take a proton to decay?").
Cheers, Bob
Dear Bob,
Thanks again. :-)
Best wishes for the new year!
Bill
Happy New Year!
Bob Arning:
extent: aPoint
x _ aPoint x. y _ aPoint y. (y * aspectRatio) > x ifTrue: [ x _ y * aspectRatio ] ifFalse: [ y _ x / aspectRatio ].
Bill:
Doing it this way makes for the greater extent, which is faster when expanding.
Bob:
I could easily have picked smaller rather than greater. Since it wasn't specified, I flipped a coin.
I used this approach to resizing a Constant Shape Rectangle Morph, and then put one in a window, with unexpected results. ;-) First, the Morph went transparent, and this seems to be true for Morphs in general when you open or put them in windows. Second, after I recolorized the Morph, it became apparent that resizing the window could easily put the Morph outside the window. It seems like the window tries to make the Morph fit the window exactly, which will rarely work with a Constant Shape Morph. Also, once the Morph went outside the window, it was difficult to resize the window to encompass the morph, although I think that in theory it should be possible. Anyway, I was never able to do so.
Question: Why do morphs go transparent in windows?
In using the Halo handle to resize a Constant Shape Morph, I found that the Morph tended to go outside the implicit boundaries implied by the handle. I figured that it would be better ergonomics to keep the Morph inside the implicit boundaries, and therefore switched to using the lesser extent for resizing. That kept the Morph in bounds, and also within windows.
Ciao,
Bill
squeak-dev@lists.squeakfoundation.org