summaryrefslogtreecommitdiff
path: root/src/com/android/launcher2/DragLayer.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-08-24 13:05:25 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-24 13:05:26 -0700
commit1dc3b9abd5ab0a39bab7694669d6784b89d362ef (patch)
tree130a48dc5c90c2bb9c780080e763570e316be8a0 /src/com/android/launcher2/DragLayer.java
parent05ee3cfffe4e5cf752e6072bcd2819faac121617 (diff)
parent307fe23f125cbbd5512ad8d4660025f2ab68f30b (diff)
downloadLauncher2-1dc3b9abd5ab0a39bab7694669d6784b89d362ef.tar.gz
Merge "Adding the ability to scale the hotseat or items in the hotseat" into jb-mr1-dev
Diffstat (limited to 'src/com/android/launcher2/DragLayer.java')
-rw-r--r--src/com/android/launcher2/DragLayer.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index a30e0912..fed0ad9e 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -274,10 +274,10 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
return scale;
}
- public void getLocationInDragLayer(View child, int[] loc) {
+ public float getLocationInDragLayer(View child, int[] loc) {
loc[0] = 0;
loc[1] = 0;
- getDescendantCoordRelativeToSelf(child, loc);
+ return getDescendantCoordRelativeToSelf(child, loc);
}
/**
@@ -286,7 +286,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
*
* @param descendant The descendant to which the passed coordinate is relative.
* @param coord The coordinate that we want mapped.
- * @return The factor by which this descendant is scaled relative to this DragLayer.
+ * @return The factor by which this descendant is scaled relative to this DragLayer. Caution
+ * this scale factor is assumed to be equal in X and Y, and so if at any point this
+ * assumption fails, we will need to return a pair of scale factors.
*/
public float getDescendantCoordRelativeToSelf(View descendant, int[] coord) {
float scale = 1.0f;
@@ -451,12 +453,16 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
getViewRectRelativeToSelf(dragView, r);
int coord[] = new int[2];
- coord[0] = lp.x;
- coord[1] = lp.y;
+ float childScale = child.getScaleX();
+ coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
+ coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
+ // We need to account for the scale of the child itself, as the above only accounts for
+ // for the scale in parents.
+ scale *= childScale;
int toX = coord[0];
int toY = coord[1];
if (child instanceof TextView) {
@@ -470,7 +476,8 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
- toY -= Workspace.DRAG_BITMAP_PADDING / 2;
+ toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
+ toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
// Center in the x coordinate about the target's drawable
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else {