request for critique

Ned Konz ned at bike-nomad.com
Mon Jun 2 14:26:53 UTC 2003


On Monday 02 June 2003 04:04 am, David Faden wrote:

> I'm interested in getting some comments on a bit of Smalltalk code.
> Am I missing or misapplying some of the common idioms? Comments on
> style (or correctness) would be very welcome too. My code is
> attached to the bottom of this message.
>
> The code is for a little Mandelbrot set explorer. It seems pretty
> slow (compared to similar implementations of the M. set in
> different environments and compared to other graphics objects
> within the Squeak image). Is the usual way to create an image
> pixel-by-pixel in Squeak to create a Form then set the pixels
> one-by-one using #colorAt: put: or #pixelValueAt: put:? What could
> I do to improve the performance?
>
> Is there a way to associate an hour glass cursor with a single
> Morph to allow it indicate that it's carrying out a noticeably time
> consuming process?

You can respond to mouseEnter and mouseLeave events if you wish, and 
change the cursor.

Best would be (as Bob said) to do the computation work on a separate 
Form in a background process and update the Morph's display from that 
Form in its step method.

> Is there a simple way to have a Morph just take over the handling
> of some MouseEvents but not all so that it will get the default
> handling for the events it's not interested in?

Yes. Instead of overriding #handlesMouseDown: and #mouseDown: , just 
use
	self on: #mouseDown send: #mousePressed: to: self.
in your #initialize method

and rename your #mouseDown: to #mousePressed:.

Also, the event you get in your event handlers is already in local 
coordinates (unlike, say, reading the Hand's position directly). 
However, that means that you need to offset it by your bounds' 
offset.

I've attached a version that:
* does its work in the background
* responds to mouseDown in the "usual" way
* allows shift-yellow button to zoom back out
* allows resizing

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MandelbrotSetMorph.1.cs
Type: text/x-squeak-changeset
Size: 4418 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030602/abf85e36/MandelbrotSetMorph.1.bin


More information about the Squeak-dev mailing list