More Attachment ideas...

Ned Konz ned at bike-nomad.com
Sun Oct 1 23:00:02 UTC 2000


"Pennell, David" wrote:
> 
> Why not make all AttachmentMorphs that are attached to a morph become
> visible when the mouse is over the attached morph?  Other graphic
> programs that I've used seem to use this approach.

I'm doing this, kinda.

The way it works is:

* a new AttachmentPointMorph (hereafter APM) can be dropped on
a Morph. It will attach itself to the nearest suitable point
(by default the 8 outer points of the bounding rectangle or
the center) on that Morph.

* When you move the Morph that an APM is attached to, the APM
stays stuck to the same point of that Morph (for instance, the upper
left corner).

* When you drag an APM that's attached to a Morph, it moves,
and displays a rubber-band line going back to its attachment point.

* When an attached APM is dragged over a Morph, all APM's attached
to that Morph become visible, if they weren't already.

* Dropping an attached APM on another attached APM connects the two.
A description of what _that_ does follows.

* Dropping an attached APM on a Morph (can) create a new APM attached
to the nearest attachment point and then connect to the dropped APM.
So you don't have to pre-attach APM's to Morphs that are the destination
of connections. However, APM's created in this way are of a default type
that doesn't affect (move, size, or stretch) their owners. If you want
different behavior (like for the APM at the end of a connection line),
you have to create one and tell it how to behave.

* You can detach an APM from its morph by using shift-drag on it.

* You can make all the APM's visible per-Morph, or per-pasteUp.
Or you can make them only appear when the mouse is over them (or
their owner, during attachment, as described above).

The behavior of attached APM's is pluggable. There can be multiple
APM's connected together (not just two at a time).

Some possibilities for the action of APM's on their attached morphs:

* do nothing (just sit there). Default for auto-created ones.
* move attached morph so that attached APM's are a fixed distance from each
other
(default: on top of each other)
* stretch attached morph so that attached APM's are a fixed distance from each
other
(default: on top of each other)
* move Polygon/Line vertex so that attached APM's are a fixed distance from each
other (default: on top of each other)

The destination point that they move towards (if they're moving) is the
center of the line segment (N=2) or polygon (N>2) that they define.
So if they're all moving, they'll end up in the center, if all but
one are moving, they'll end up on top of the immobile one, etc.

An attached APM can ask its attached morph for a reference point
(on a line, this would be the next-from-the end vertex for an APM
attached to an end).
I've been thinking about having a flavor of APM (or another pluggable
behavior) that moves its attachment point on its attached Morph so that
it's closest to its neighbor's reference point.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list