Finding open space?

Andreas.Raab at gmx.de Andreas.Raab at gmx.de
Mon Nov 25 17:42:02 UTC 2002


David,

Try this as a starting point:

Morph>>visiblePointOnScreen
	"Find a point within the receiver's bounding box where it's visible on the
screen."
	"World visiblePointOnScreen"
	| areas newList |
	areas _ Array with: self bounds.
	self morphsInFrontOf: nil overlapping: self bounds do:[:m |
		newList _ Array streamContents:[:s|
			areas do:[:a| s nextPutAll: (a areasOutside: m fullBounds)]].
		areas _ newList contents.
	].
	areas isEmpty ifTrue:[^self error:'No part of me is visible!!!'].
	areas _ areas sortBy:[:a1 :a2| a1 area > a2 area].
	^areas first center.

This may not be exactly what you need (and strictly speaking it's quite
inefficient) but I just had it handy and might get you started.

Cheers,
  - Andreas


> Is there as a simple way to find an open area of the
> world to position a new Morph in, so that it doesn't
> block anything else?  I have a Connectors-based
> free-form drawing on the screen that I don't want to
> disturb, but would like to popup a TextMorph (what I'm
> using now anyway) with some status information in it
> somewhere without blocking the drawing, if possible. 
> I see possibilities with alignment and layouts, but
> they seem to imply a structure to what's already on
> the screen, which I can't do.
> 
> I liked the refrigerator magnet project on Bob's Super
> Swiki, but the code seems overly complex for what I
> want to do.  It also conflicts with the more current
> version of Connectors that I'm using.
> 
> Any ideas?
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!




More information about the Squeak-dev mailing list