Hello there
I am in for some ideas on how to implement shapes magnetism the Object
Handle way for rotation = 0 as a 'first' version.
The end result will look like this:
http://screenr.com/clB
Let's say you have S1 S2 S3 in objectHandleSelectionManager.
set gravity to 5
On mouse down you build two arrays for fast look up.
Left Vertical (x) Top Horizontal (y) edge:
xSnapPositionsLeftEdge x - 5 to x + 5 (10 items) for all shapes top
left point.
ySnapPositionsTopEdge y - 5 to y + 5 (10 items) for all shapes top left point.
Right Vertical (x) Bottom Horizontal (y) edge::
xSnapPositionsRightEdge x+ width - 5 to x + width + 5 (10 items)
for all shapes bottom right point.
ySnapPositionsBottomEdge y + height - 5 to y + height + 5 (10 items)
for all shapes bottom right point.
Center ...
When S1 is moved you check if its top left corner matches any of the
value in xSnapPositionsLeftEdge for x and ySnapPositionsTopEdge for
y.
If it does you update the shape position to the x,y value of
currentlySelected at postion int( match position /10)
draw a nice axe on the shape parent plan.
Things i could have forgotten:
- Is currentlySelected really usable for this purpose ?
- Is it out of the scope of object Handles where each shape handles
its own movement and have no idea of the of the system.
- negative width / height
Thank you for your feedbacks.
Greg