summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Folder.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-07-17 14:47:18 -0700
committerAdam Cohen <adamcohen@google.com>2011-07-17 15:45:47 -0700
commit35e7e64d4b98e42c760e5e91489b7014a6ba9073 (patch)
tree66b9ed219b1dd518d32ac9e0e605fb46a05c6c51 /src/com/android/launcher2/Folder.java
parentff35bf81a24812cb7dc33bbaddcfed1e44d418d2 (diff)
downloadandroid_packages_apps_Trebuchet-35e7e64d4b98e42c760e5e91489b7014a6ba9073.tar.gz
android_packages_apps_Trebuchet-35e7e64d4b98e42c760e5e91489b7014a6ba9073.tar.bz2
android_packages_apps_Trebuchet-35e7e64d4b98e42c760e5e91489b7014a6ba9073.zip
Bounding folders into their associated cell layout area, excluding dock
Change-Id: I220ccf1d8b08f9962c63efc92265e3c7acc137f9
Diffstat (limited to 'src/com/android/launcher2/Folder.java')
-rw-r--r--src/com/android/launcher2/Folder.java32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index dd0bffda6..ef02de6bc 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -730,20 +730,24 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int centeredLeft = centerX - width / 2;
int centeredTop = centerY - height / 2;
- int parentWidth = 0;
- int parentHeight = 0;
- if (parent != null) {
- parentWidth = parent.getMeasuredWidth();
- parentHeight = parent.getMeasuredHeight();
- }
-
- int left = Math.min(Math.max(0, centeredLeft), parentWidth - width);
- int top = Math.min(Math.max(0, centeredTop), parentHeight - height);
- if (width >= parentWidth) {
- left = (parentWidth - width) / 2;
- }
- if (height >= parentHeight) {
- top = (parentHeight - height) / 2;
+ // We first fetch the currently visible CellLayoutChildren
+ int page = mLauncher.getWorkspace().getCurrentPage();
+ CellLayout currentPage = (CellLayout) mLauncher.getWorkspace().getChildAt(page);
+ CellLayoutChildren boundingLayout = currentPage.getChildrenLayout();
+ Rect bounds = new Rect();
+ parent.getDescendantRectRelativeToSelf(boundingLayout, bounds);
+
+ // We need to bound the folder to the currently visible CellLayoutChildren
+ int left = Math.min(Math.max(bounds.left, centeredLeft),
+ bounds.left + bounds.width() - width);
+ int top = Math.min(Math.max(bounds.top, centeredTop),
+ bounds.top + bounds.height() - height);
+ // If the folder doesn't fit within the bounds, center it about the desired bounds
+ if (width >= bounds.width()) {
+ left = bounds.left + (bounds.width() - width) / 2;
+ }
+ if (height >= bounds.height()) {
+ top = bounds.top + (bounds.height() - height) / 2;
}
int folderPivotX = width / 2 + (centeredLeft - left);