Controlling Morphic Drawing Order

Ken Causey ken at kencausey.com
Tue Mar 16 21:06:01 UTC 2004


I'm exploring the possibility of game development with Squeak and while
wanting to leverage the power that Morphic provides I need some
additional leverage in the drawing order.  In particular I need to be
able to specify drawing before and after submorph drawing occurs.

My initial naive assumption was that I could do something like the
following:

MyMorph>>drawOn: aCanvas
	"Incorrect assumptions here"

	"Do before-submorphs drawing here"

	"Submorph drawing"
	super drawOn: aCanvas
	
	"Do after-submorphs drawing here"

Quick tests showed that I was wrong and that submorph drawing was
occurring after drawOn: was called and returned.  I wrestled with trying
to work out the actual drawing order until I realized that a debugging
stack would be helpful (duh) and I decided on this method which seems to
work:

MyMorph>>fullDrawOn: aCanvas
	"This works I think"

	"Do before-submorphs drawing here"

	"Draw submorphs"
	super fullDrawOn: aCanvas

	"Do after-submorphs drawing here"

In reality the "after-submorphs drawing" hook here is pointless as you
can just do that in your normal drawOn: which will be called by Morph
fullDrawOn:.

Just thought I would pass this on to others and solicit comments.  Also
with any luck when I forget this in 6 months the search terms I'm
inclined to use will find this email. ;)

Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040316/ee0f54b5/attachment.pgp


More information about the Squeak-dev mailing list