OSDN Git Service

Fix drag and drop handler to handle reentry
authorTor Norbye <tnorbye@google.com>
Tue, 12 Oct 2010 16:41:22 +0000 (09:41 -0700)
committerTor Norbye <tnorbye@google.com>
Tue, 12 Oct 2010 16:41:22 +0000 (09:41 -0700)
commit2f10ef8e59c3407af5f32d1f427e5141b39740af
treeb77681a80aa012a6e3c4271cf84849853726b50e
parent3401833490233265bbe96791c341a3ee06ce97ff
Fix drag and drop handler to handle reentry

If you drag from the palette over a linear layout view, you get drop
feedback. However, if you drag outside the linear layout and then back
in, you often don't get any more feedback. This happens pretty easily
with nested layouts.

The problem is that the feedback object is initialized and reset in
onDropEnter, but the actual guideline computation happens in
onDropMove (since only drop move is handed the mouse coordinates). The
bug happens because when you leave and return to the drop zone, the
feedback object is reset, and then the drop feedback is painted - all
before the onDropMove code has been called again.

The fix is simple: On drop enter, also call onDropMove immediately
such that the layout helpers are given a chance to initialize
themselves with the entry mouse position, before they are consulted
for drop feedback data.

This changeset also contains a fix for LinearLayouts: When there are
no children, place the guideline at x=0 or y=0 (depending on whether
the layout is horizontal or vertical). Without this fix, the line is
placed in the center of the view, which is misleading since that is
not where the view will be placed upon drop.

Change-Id: Ib5e17a2d9d3818677e4209126233bbde527207c8
eclipse/plugins/com.android.ide.eclipse.adt/gscripts/android.widget.LinearLayout.groovy
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/CanvasDropListener.java