summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CellLayout.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-03-03 17:26:50 -0800
committerAdam Cohen <adamcohen@google.com>2011-03-03 18:30:20 -0800
commit1b607ed454ed22c2fd855cb3e428376520fb2388 (patch)
tree09181f6a15782dbe721284b046601db5771588bc /src/com/android/launcher2/CellLayout.java
parent3c438bcbd3a0e40141117c5b68a82a8be5ddf140 (diff)
downloadandroid_packages_apps_Trebuchet-1b607ed454ed22c2fd855cb3e428376520fb2388.tar.gz
android_packages_apps_Trebuchet-1b607ed454ed22c2fd855cb3e428376520fb2388.tar.bz2
android_packages_apps_Trebuchet-1b607ed454ed22c2fd855cb3e428376520fb2388.zip
Cleaning up widget resizing code
Change-Id: Ib4c0de0080f0b69f873fd88016f23c319a13c6ff
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r--src/com/android/launcher2/CellLayout.java43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index a2a539e6b..0fb87bacc 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -589,7 +589,8 @@ public class CellLayout extends ViewGroup {
final View child = mChildren.getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) && lp.isLockedToGrid) {
+ if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
+ lp.isLockedToGrid) {
child.getHitRect(frame);
if (frame.contains(x, y)) {
cellInfo.cell = child;
@@ -1340,53 +1341,54 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
}
}
+ /**
+ * Given a view, determines how much that view can be expanded in all directions, in terms of
+ * whether or not there are other items occupying adjacent cells. Used by the
+ * AppWidgetResizeFrame to determine how the widget can be resized.
+ */
public void getExpandabilityArrayForView(View view, int[] expandability) {
- final LayoutParams lp = (LayoutParams) view.getLayoutParams();
+ final LayoutParams lp = (LayoutParams) view.getLayoutParams();
boolean flag;
- // Left
- expandability[0] = 0;
+ expandability[AppWidgetResizeFrame.LEFT] = 0;
for (int x = lp.cellX - 1; x >= 0; x--) {
flag = false;
for (int y = lp.cellY; y < lp.cellY + lp.cellVSpan; y++) {
if (mOccupied[x][y]) flag = true;
}
if (flag) break;
- expandability[0]++;
+ expandability[AppWidgetResizeFrame.LEFT]++;
}
- // Top
- expandability[1] = 0;
+ expandability[AppWidgetResizeFrame.TOP] = 0;
for (int y = lp.cellY - 1; y >= 0; y--) {
flag = false;
for (int x = lp.cellX; x < lp.cellX + lp.cellHSpan; x++) {
if (mOccupied[x][y]) flag = true;
}
if (flag) break;
- expandability[1]++;
- }
+ expandability[AppWidgetResizeFrame.TOP]++;
+ }
- // Right
- expandability[2] = 0;
+ expandability[AppWidgetResizeFrame.RIGHT] = 0;
for (int x = lp.cellX + lp.cellHSpan; x < mCountX; x++) {
flag = false;
for (int y = lp.cellY; y < lp.cellY + lp.cellVSpan; y++) {
if (mOccupied[x][y]) flag = true;
}
if (flag) break;
- expandability[2]++;
- }
+ expandability[AppWidgetResizeFrame.RIGHT]++;
+ }
- // Bottom
- expandability[3] = 0;
+ expandability[AppWidgetResizeFrame.BOTTOM] = 0;
for (int y = lp.cellY + lp.cellVSpan; y < mCountY; y++) {
flag = false;
for (int x = lp.cellX; x < lp.cellX + lp.cellHSpan; x++) {
if (mOccupied[x][y]) flag = true;
}
if (flag) break;
- expandability[3]++;
- }
+ expandability[AppWidgetResizeFrame.BOTTOM]++;
+ }
}
public void onMove(View view, int newCellX, int newCellY) {
@@ -1466,6 +1468,10 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
@ViewDebug.ExportedProperty
public int cellVSpan;
+ /**
+ * Indicates whether the item will set its x, y, width and height parameters freely,
+ * or whether these will be computed based on cellX, cellY, cellHSpan and cellVSpan.
+ */
public boolean isLockedToGrid = true;
/**
@@ -1531,12 +1537,11 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
final int myCellVSpan = cellVSpan;
final int myCellX = cellX;
final int myCellY = cellY;
-
+
width = myCellHSpan * cellWidth + ((myCellHSpan - 1) * widthGap) -
leftMargin - rightMargin;
height = myCellVSpan * cellHeight + ((myCellVSpan - 1) * heightGap) -
topMargin - bottomMargin;
-
x = hStartPadding + myCellX * (cellWidth + widthGap) + leftMargin;
y = vStartPadding + myCellY * (cellHeight + heightGap) + topMargin;
}