LookEnhancements enhancement

Jesse Welton jwelton at pacific.mps.ohio-state.edu
Wed Aug 10 21:51:41 UTC 2005


On Wed, Aug 10, 2005 at 05:30:08PM -0400, John Pierce wrote:
> 
> Sounds nice and seems like something that should be easy to implement, but 
> the more I think about it I think it is non-trivial (unless I am thinking 
> about it the wrong way). You'd have to know direction the user is moving the 
> window and snap to windows in that general direction once you got near them 
> (say 10 - 20 pixels). Then you'd have to let the user pass over that window 
> if they wanted to keep trucking by. Also, the user should be able to unstick 
> the window with ease and go in the opposite direction.

It does seem like it could be tricky to do live snapping in a smooth
way.  In particular, without fastDragWindowsForMorphic, the window
picked up by the hand becomes a submorph of the hand; you might
therefore have to override some very basic morph movement methods.
(Or maybe not.  I don't know.)  However, it would not be difficult at
all to simply snap the window into place at the end of the drag, which
should provide a usable approximation of the same behavior.  Only use
would tell.

If you want to try live snapping, you basically have to track two
positions for the window: its normal drag position, where it would be
now in an unsnapped drag, and its actual current snapped position.  On
each mouseMove, you check to see if the normal drag position is within
N pixels of a snap point.  (Actually, this can be a snap line; the
check is made for x and y coordinates almost independently.)  If so,
set its current position to the snap point.  If not, set it to the
drag point.  Thus, unsticking the window is as simple as continuing to
drag it in the direction you want it to move.  N should not be as
large as 10 to 20 pixels, though.  5 would be ample.

-Jesse



More information about the Squeak-dev mailing list