mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Switch all folder preview rendering to be programmatic (ie. no assets)
-> Refactored the preview background rendering to be much more self-contained. This cleans up a lot of code in the CellLayout, and keeps the logic in the right place. -> We switch to software rendering for performance and compatibility reasons. -> Removed all assets. -> FolderIcon accept animation includes animation of the clipped region. -> 1:1 hand-off of drawing of the FolderIcon background between the FolderIcon and the CellLayout. Unfortunately, CellLayout rendering is still required to work around clipping issues (due to use of software layer). We also need this to support folder creation feedback. Change-Id: Ib8f7fa6359dfedff8145f38dd50ba03849ca0d51
This commit is contained in:
@@ -15,6 +15,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
final float MIN_SCALE = 0.48f;
|
||||
final float MAX_SCALE = 0.58f;
|
||||
final float MAX_RADIUS_DILATION = 0.15f;
|
||||
final float ITEM_RADIUS_SCALE_FACTOR = 1.33f;
|
||||
|
||||
private float[] mTmpPoint = new float[2];
|
||||
|
||||
@@ -22,27 +23,19 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
private float mRadius;
|
||||
private float mIconSize;
|
||||
private boolean mIsRtl;
|
||||
private Path mClipPath = new Path();
|
||||
|
||||
@Override
|
||||
public void init(int availableSpace, int intrinsicIconSize, boolean rtl) {
|
||||
mAvailableSpace = availableSpace;
|
||||
mRadius = 0.66f * availableSpace;
|
||||
mRadius = ITEM_RADIUS_SCALE_FACTOR * availableSpace / 2f;
|
||||
mIconSize = intrinsicIconSize;
|
||||
mIsRtl = rtl;
|
||||
|
||||
// We make the clip radius just slightly smaller than the background drawable
|
||||
// TODO(adamcohen): this is hacky, needs cleanup (likely through programmatic drawing).
|
||||
int clipRadius = (int) mAvailableSpace / 2 - 1;
|
||||
|
||||
mClipPath.addCircle(mAvailableSpace / 2, mAvailableSpace / 2, clipRadius, Path.Direction.CW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderIcon.PreviewItemDrawingParams computePreviewItemDrawingParams(int index,
|
||||
int curNumItems, FolderIcon.PreviewItemDrawingParams params) {
|
||||
|
||||
|
||||
float totalScale = scaleForNumItems(curNumItems);
|
||||
float transX;
|
||||
float transY;
|
||||
@@ -55,7 +48,6 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
getPosition(index, curNumItems, mTmpPoint);
|
||||
transX = mTmpPoint[0];
|
||||
transY = mTmpPoint[1];
|
||||
totalScale = scaleForNumItems(curNumItems);
|
||||
}
|
||||
|
||||
if (params == null) {
|
||||
@@ -126,8 +118,8 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getClipPath() {
|
||||
return mClipPath;
|
||||
public boolean clipToBackground() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user