From a257f0d0f8cf83e5aa0656d16b876e3edc027009 Mon Sep 17 00:00:00 2001 From: nebkat Date: Tue, 18 Dec 2012 19:20:24 +0000 Subject: Cylinder Transition Effect Change-Id: Id9bdd2ae83472ba0dc90527d55272463395d1aaf --- .../trebuchet/AppsCustomizePagedView.java | 29 ++++++++++++++++++++- src/com/cyanogenmod/trebuchet/Workspace.java | 30 ++++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java index 945d5b76e..fca6eda9c 100644 --- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java +++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java @@ -318,7 +318,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen CubeIn, CubeOut, Stack, - Accordian + Accordian, + CylinderIn, + CylinderOut } private TransitionEffect mTransitionEffect = TransitionEffect.Standard; @@ -2031,6 +2033,24 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } + private void screenScrolledCylinder(int screenScroll, boolean in) { + for (int i = 0; i < getChildCount(); i++) { + View v = getPageAt(i); + if (v != null) { + float scrollProgress = getScrollProgress(screenScroll, v, i); + float rotation = (in ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress; + + v.setPivotX((scrollProgress + 1) * v.getMeasuredWidth() * 0.5f); + v.setPivotY(v.getMeasuredHeight() * 0.5f); + v.setRotationY(rotation); + if (mFadeInAdjacentScreens) { + float alpha = 1 - Math.abs(scrollProgress); + v.setAlpha(alpha); + } + } + } + } + // Transition effects @Override protected void screenScrolled(int screenScroll) { @@ -2044,6 +2064,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (!isInOverscroll || mScrollTransformsDirty) { // Limit the "normal" effects to mScrollX/Y int scroll = !mVertical ? mScrollX : mScrollY; + // Reset transforms when we aren't in overscroll if (mOverscrollTransformsDirty) { mOverscrollTransformsDirty = false; @@ -2067,6 +2088,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen v0.setPivotY(v0.getMeasuredHeight() / 2); v1.setPivotY(v1.getMeasuredHeight() / 2); } + switch (mTransitionEffect) { case Standard: screenScrolledStandard(scroll); @@ -2104,6 +2126,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen case Accordian: screenScrolledAccordian(scroll); break; + case CylinderIn: + screenScrolledCylinder(scroll, true); + break; + case CylinderOut: + screenScrolledCylinder(scroll, false); } mScrollTransformsDirty = false; } diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index b03a1cbac..231d8ee23 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -297,7 +297,9 @@ public class Workspace extends SmoothPagedView CubeIn, CubeOut, Stack, - Accordian + Accordian, + CylinderIn, + CylinderOut } private TransitionEffect mTransitionEffect = TransitionEffect.Standard; @@ -1493,7 +1495,7 @@ public class Workspace extends SmoothPagedView } else { cl.setScaleX(scale); cl.setScaleY(scale); - cl.setPivotX(scrollProgress * cl.getMeasuredWidth() * 0.5f + cl.getMeasuredWidth() * 0.5f); + cl.setPivotX((scrollProgress + 1) * cl.getMeasuredWidth() * 0.5f); } cl.setPivotY(cl.getMeasuredHeight() * 0.5f); cl.setRotationY(rotation); @@ -1607,6 +1609,23 @@ public class Workspace extends SmoothPagedView invalidate(); } + private void screenScrolledCylinder(int screenScroll, boolean in) { + for (int i = 0; i < getChildCount(); i++) { + CellLayout cl = (CellLayout) getPageAt(i); + if (cl != null) { + float scrollProgress = getScrollProgress(screenScroll, cl, i); + float rotation = (in ? WORKSPACE_ROTATION : -WORKSPACE_ROTATION) * scrollProgress; + + cl.setPivotX((scrollProgress + 1) * cl.getMeasuredWidth() * 0.5f); + cl.setPivotY(cl.getMeasuredHeight() * 0.5f); + cl.setRotationY(rotation); + if (mFadeInAdjacentScreens && !isSmall()) { + setCellLayoutFadeAdjacent(cl, scrollProgress); + } + } + } + } + @Override protected void screenScrolled(int screenScroll) { super.screenScrolled(screenScroll); @@ -1635,6 +1654,7 @@ public class Workspace extends SmoothPagedView // Limit the "normal" effects to mScrollX int scroll = mScrollX; + // Reset transforms when we aren't in overscroll if (mOverscrollFade != 0) { setFadeForOverScroll(0); } @@ -1681,6 +1701,12 @@ public class Workspace extends SmoothPagedView case Accordian: screenScrolledAccordian(scroll); break; + case CylinderIn: + screenScrolledCylinder(scroll, true); + break; + case CylinderOut: + screenScrolledCylinder(scroll, false); + break; } mScrollTransformsDirty = false; } -- cgit v1.2.3