diff options
author | Adam Cohen <adamcohen@google.com> | 2010-09-13 14:49:43 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2010-09-28 16:56:10 -0700 |
commit | 9415d87eda0cf28b8df1eccde39b0ca1646be3b9 (patch) | |
tree | 90af24bc558676ae26831eec04ca0cb392104aa0 /src/com/android/launcher2/CellLayout.java | |
parent | 163c9c0236b7824673d4ead9dbf664bf38ec047e (diff) | |
download | packages_apps_trebuchet-9415d87eda0cf28b8df1eccde39b0ca1646be3b9.zip packages_apps_trebuchet-9415d87eda0cf28b8df1eccde39b0ca1646be3b9.tar.gz packages_apps_trebuchet-9415d87eda0cf28b8df1eccde39b0ca1646be3b9.tar.bz2 |
-Added 3D effect to home screen scrolling
-Added background outline fade in / out
-Modified the feel of scrolling: now using quintic
interpolator and modified the influence of
scroll velocity
Change-Id: Ifddcab5223ac20be7d9f800ccf09442d9b4db781
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 585d1c3..0caaf2e 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -37,7 +37,7 @@ import android.view.animation.LayoutAnimationController; import java.util.Arrays; -public class CellLayout extends ViewGroup { +public class CellLayout extends ViewGroup implements Dimmable { static final String TAG = "CellLayout"; private int mCellWidth; @@ -68,8 +68,10 @@ public class CellLayout extends ViewGroup { private float mBackgroundAlpha; private final Rect mBackgroundLayoutRect = new Rect(); + private Drawable mBackground; - private Drawable mBackgroundHover; + private Drawable mBackgroundMini; + private Drawable mBackgroundMiniHover; // If we're actively dragging something over this screen and it's small, // mHover is true private boolean mHover = false; @@ -108,10 +110,12 @@ public class CellLayout extends ViewGroup { mOccupiedDrawable = getResources().getDrawable(R.drawable.rounded_rect_red); if (LauncherApplication.isScreenXLarge()) { - mBackground = getResources().getDrawable(R.drawable.mini_home_screen_bg); + mBackgroundMini = getResources().getDrawable(R.drawable.mini_home_screen_bg); + mBackgroundMini.setFilterBitmap(true); + mBackground = getResources().getDrawable(R.drawable.home_screen_bg); mBackground.setFilterBitmap(true); - mBackgroundHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover); - mBackgroundHover.setFilterBitmap(true); + mBackgroundMiniHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover); + mBackgroundMiniHover.setFilterBitmap(true); } TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0); @@ -149,7 +153,14 @@ public class CellLayout extends ViewGroup { @Override public void dispatchDraw(Canvas canvas) { if (mBackgroundAlpha > 0.0f) { - final Drawable bg = mHover ? mBackgroundHover : mBackground; + Drawable bg; + if (mHover && getScaleX() < 0.5f) { + bg = mBackgroundMiniHover; + } else if (getScaleX() < 0.5f) { + bg = mBackgroundMini; + } else { + bg = mBackground; + } bg.setAlpha((int) (mBackgroundAlpha * 255)); bg.draw(canvas); } @@ -169,6 +180,20 @@ public class CellLayout extends ViewGroup { super.onDraw(canvas); } + public void setDimmableProgress(float progress) { + for (int i = 0; i < getChildCount(); i++) { + Dimmable d = (Dimmable) getChildAt(i); + d.setDimmableProgress(progress); + } + } + + public float getDimmableProgress() { + if (getChildCount() > 0) { + return ((Dimmable) getChildAt(0)).getDimmableProgress(); + } + return 0.0f; + } + @Override public void cancelLongPress() { super.cancelLongPress(); @@ -523,8 +548,11 @@ public class CellLayout extends ViewGroup { if (mBackground != null) { mBackground.setBounds(mBackgroundLayoutRect); } - if (mBackgroundHover != null) { - mBackgroundHover.setBounds(mBackgroundLayoutRect); + if (mBackgroundMiniHover != null) { + mBackgroundMiniHover.setBounds(mBackgroundLayoutRect); + } + if (mBackgroundMini != null) { + mBackgroundMini.setBounds(mBackgroundLayoutRect); } } |