diff options
author | Adam Cohen <adamcohen@google.com> | 2011-04-15 12:06:01 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-15 12:06:01 -0700 |
commit | b1c8befb2fc25e1a3c08d07bcea300fd22ede4e3 (patch) | |
tree | fed430588bbcb98f73c831f39739cb3e2ea57f0b /src/com/android/launcher2/CellLayout.java | |
parent | 20ac28bacc93418f36563a563dc6a44cf014e840 (diff) | |
parent | df0353815c629fc678824b07a234b89a1ff94208 (diff) | |
download | android_packages_apps_Trebuchet-b1c8befb2fc25e1a3c08d07bcea300fd22ede4e3.tar.gz android_packages_apps_Trebuchet-b1c8befb2fc25e1a3c08d07bcea300fd22ede4e3.tar.bz2 android_packages_apps_Trebuchet-b1c8befb2fc25e1a3c08d07bcea300fd22ede4e3.zip |
Merge "Enabling user folder creation by dropping shortcut onto shortcut"
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index ef83f2736..dd0c58ad2 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -95,7 +95,7 @@ public class CellLayout extends ViewGroup { private float mGlowBackgroundScale; private float mGlowBackgroundAlpha; - private boolean mAcceptsDrops = false; + private boolean mAcceptsDrops = true; // If we're actively dragging something over this screen, mIsDragOverlapping is true private boolean mIsDragOverlapping = false; private boolean mIsDragOccuring = false; @@ -1010,13 +1010,14 @@ public class CellLayout extends ViewGroup { * @param pixelY The Y location at which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. - * @param ignoreView Considers space occupied by this view as unoccupied - * @param result Previously returned value to possibly recycle. + * @param ignoreOccupied If true, the result can be an occupied cell + * @param result Array in which to place the result, or null (in which case a new array will + * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ - int[] findNearestVacantArea( - int pixelX, int pixelY, int spanX, int spanY, View ignoreView, int[] result) { + int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, View ignoreView, + boolean ignoreOccupied, int[] result) { // mark space take by ignoreView as available (method checks if ignoreView is null) markCellsAsUnoccupiedForView(ignoreView); @@ -1031,13 +1032,15 @@ public class CellLayout extends ViewGroup { for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { - for (int i = 0; i < spanX; i++) { - for (int j = 0; j < spanY; j++) { - if (occupied[x + i][y + j]) { - // small optimization: we can skip to after the column we just found - // an occupied cell - x += i; - continue inner; + if (ignoreOccupied) { + for (int i = 0; i < spanX; i++) { + for (int j = 0; j < spanY; j++) { + if (occupied[x + i][y + j]) { + // small optimization: we can skip to after the column we + // just found an occupied cell + x += i; + continue inner; + } } } } @@ -1064,6 +1067,42 @@ public class CellLayout extends ViewGroup { } } + /** + * Find a vacant area that will fit the given bounds nearest the requested + * cell location. Uses Euclidean distance to score multiple vacant areas. + * + * @param pixelX The X location at which you want to search for a vacant area. + * @param pixelY The Y location at which you want to search for a vacant area. + * @param spanX Horizontal span of the object. + * @param spanY Vertical span of the object. + * @param ignoreView Considers space occupied by this view as unoccupied + * @param result Previously returned value to possibly recycle. + * @return The X, Y cell of a vacant area that can contain this object, + * nearest the requested location. + */ + int[] findNearestVacantArea( + int pixelX, int pixelY, int spanX, int spanY, View ignoreView, int[] result) { + return findNearestArea(pixelX, pixelY, spanX, spanY, ignoreView, true, result); + } + + /** + * Find a starting cell position that will fit the given bounds nearest the requested + * cell location. Uses Euclidean distance to score multiple vacant areas. + * + * @param pixelX The X location at which you want to search for a vacant area. + * @param pixelY The Y location at which you want to search for a vacant area. + * @param spanX Horizontal span of the object. + * @param spanY Vertical span of the object. + * @param ignoreView Considers space occupied by this view as unoccupied + * @param result Previously returned value to possibly recycle. + * @return The X, Y cell of a vacant area that can contain this object, + * nearest the requested location. + */ + int[] findNearestArea( + int pixelX, int pixelY, int spanX, int spanY, int[] result) { + return findNearestArea(pixelX, pixelY, spanX, spanY, null, false, result); + } + boolean existsEmptyCell() { return findCellForSpan(null, 1, 1); } |