Finding open space?
Ned Konz
ned at bike-nomad.com
Mon Nov 25 17:26:24 UTC 2002
On Monday 25 November 2002 09:05 am, David Faught wrote:
> 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.
If you look at NCSmartLabelMorph (or whatever it's called), you'll see
that it tries to re-position itself in its step method to avoid
whatever it's attached to, and whatever that's attached to. Which
means that sometimes it overlaps other things. I'm not too fond of
the squirmy little things, but they save me some time re-positioning
labels.
They can oscillate sometimes, too, when they can't find enough space
nearby.
And it's hard to find a big enough space to put something, especially
if you want to keep the something near something else.
Some possibilities come to mind:
* you could pop your morph up, and then (in the step method) make sure
that your morph is not overlapping any other top-level morph (i.e.
submorph of the World). If it is, you could move it (incrementally so
as not to be jarring), err, in some other direction (note: finding
the "other direction" is hard). I've tried using a localized
force-based positioning method, but it suffers from the same
oscillation problems.
* you could search the World for a "big enough" space. I don't know of
any algorithms for this, but it sounds like something that must be
well-covered in CS research.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|