First pass at new FolderIcon visual treatment
-> Modeled as a set of items around a circle -> Modulate the radius and icon size as number of items grow -> Clip the icons by a circular clip aligned to the background drawable Remaining issues -> Probably want to move to a programmaticly drawn circle + shadow -> Anti-aliasing of the clipped region will need more attention -> Need to animate all items in the preview as it changes (this wasn't required before) Change-Id: I678ec605f6c8a34e9d7e4aec4e9583e36a9ef394
This commit is contained in:
@@ -16,11 +16,13 @@
|
||||
|
||||
package com.android.launcher3.folder;
|
||||
|
||||
import android.graphics.Path;
|
||||
|
||||
import com.android.launcher3.folder.FolderIcon.PreviewItemDrawingParams;
|
||||
|
||||
public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
|
||||
public static final int NUM_ITEMS_IN_PREVIEW = 3;
|
||||
static final int MAX_NUM_ITEMS_IN_PREVIEW = 3;
|
||||
|
||||
// The degree to which the item in the back of the stack is scaled [0...1]
|
||||
// (0 means it's not scaled at all, 1 means it's scaled to nothing)
|
||||
@@ -29,13 +31,13 @@ public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
// The amount of vertical spread between items in the stack [0...1]
|
||||
private static final float PERSPECTIVE_SHIFT_FACTOR = 0.18f;
|
||||
|
||||
//private int mIntrinsicIconSize;
|
||||
private float mBaselineIconScale;
|
||||
private int mBaselineIconSize;
|
||||
private int mAvailableSpaceInPreview;
|
||||
private float mMaxPerspectiveShift;
|
||||
|
||||
public void init(int availableSpace, int intrinsicIconSize) {
|
||||
@Override
|
||||
public void init(int availableSpace, int intrinsicIconSize, boolean rtl) {
|
||||
mAvailableSpaceInPreview = availableSpace;
|
||||
|
||||
// cos(45) = 0.707 + ~= 0.1) = 0.8f
|
||||
@@ -50,11 +52,11 @@ public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviewItemDrawingParams computePreviewItemDrawingParams(int index,
|
||||
public PreviewItemDrawingParams computePreviewItemDrawingParams(int index, int curNumItems,
|
||||
PreviewItemDrawingParams params) {
|
||||
|
||||
index = NUM_ITEMS_IN_PREVIEW - index - 1;
|
||||
float r = (index * 1.0f) / (NUM_ITEMS_IN_PREVIEW - 1);
|
||||
index = MAX_NUM_ITEMS_IN_PREVIEW - index - 1;
|
||||
float r = (index * 1.0f) / (MAX_NUM_ITEMS_IN_PREVIEW - 1);
|
||||
float scale = (1 - PERSPECTIVE_SCALE_FACTOR * (1 - r));
|
||||
|
||||
float offset = (1 - r) * mMaxPerspectiveShift;
|
||||
@@ -81,6 +83,11 @@ public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
|
||||
@Override
|
||||
public int numItems() {
|
||||
return NUM_ITEMS_IN_PREVIEW;
|
||||
return MAX_NUM_ITEMS_IN_PREVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getClipPath() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user