Scale widgets in multi-window mode.

To keep this CL small and focused, I'm going to create
a separate CL that handles the scaling for the widget in
drag and drop mode.

Bug: 32176631
Change-Id: Id6557d070edb664aa1f4851de7abf494cf8a0677
This commit is contained in:
Jon Miranda
2016-11-23 10:32:42 -08:00
parent feba90fe80
commit 7ae64ffbe1
4 changed files with 52 additions and 13 deletions
+14 -2
View File
@@ -2690,6 +2690,18 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
}
public void setup(int cellWidth, int cellHeight, boolean invertHorizontally, int colCount) {
setup(cellWidth, cellHeight, invertHorizontally, colCount, 1.0f, 1.0f);
}
/**
* Use this method, as opposed to {@link #setup(int, int, boolean, int)}, if the view needs
* to be scaled.
*
* ie. In multi-window mode, we setup widgets so that they are measured and laid out
* using their full/invariant device profile sizes.
*/
public void setup(int cellWidth, int cellHeight, boolean invertHorizontally, int colCount,
float cellScaleX, float cellScaleY) {
if (isLockedToGrid) {
final int myCellHSpan = cellHSpan;
final int myCellVSpan = cellVSpan;
@@ -2700,8 +2712,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
myCellX = colCount - myCellX - cellHSpan;
}
width = myCellHSpan * cellWidth - leftMargin - rightMargin;
height = myCellVSpan * cellHeight - topMargin - bottomMargin;
width = (int) (myCellHSpan * cellWidth / cellScaleX - leftMargin - rightMargin);
height = (int) (myCellVSpan * cellHeight / cellScaleY - topMargin - bottomMargin);
x = (myCellX * cellWidth + leftMargin);
y = (myCellY * cellHeight + topMargin);
}