diff options
author | Simon Wilson <simonwilson@google.com> | 2010-12-14 17:37:04 -0800 |
---|---|---|
committer | Simon Wilson <simonwilson@google.com> | 2010-12-14 17:37:07 -0800 |
commit | 1a5b4d109397ea175b5cbaa7490ca18e78eb040f (patch) | |
tree | b40e85d0e7fa1b6072adb6cb98749ed61784e22d /carousel/java | |
parent | 358868df5043b240c9a241c7bb75128ff94b1f34 (diff) | |
download | android_frameworks_ex-1a5b4d109397ea175b5cbaa7490ca18e78eb040f.tar.gz android_frameworks_ex-1a5b4d109397ea175b5cbaa7490ca18e78eb040f.tar.bz2 android_frameworks_ex-1a5b4d109397ea175b5cbaa7490ca18e78eb040f.zip |
Allow top-to-bottom card order when rowCount>1
Add a member function to CarouselRS.java called setFirstCardTop()
to allow the first card to appear on top instead of the bottom
when rowCount>1. The default is false, meaning the existing
behaviour is not changed for other apps.
Change-Id: I38d666958ebb802e211496895cbe3f91e78f5392
Diffstat (limited to 'carousel/java')
4 files changed, 30 insertions, 1 deletions
diff --git a/carousel/java/com/android/ex/carousel/CarouselController.java b/carousel/java/com/android/ex/carousel/CarouselController.java index 40853d5..b722583 100644 --- a/carousel/java/com/android/ex/carousel/CarouselController.java +++ b/carousel/java/com/android/ex/carousel/CarouselController.java @@ -91,6 +91,7 @@ public class CarouselController { new int[] {0}, 0, 1, 1, 1, Bitmap.Config.ARGB_4444); private int mDragModel = CarouselRS.DRAG_MODEL_SCREEN_DELTA; private int mFillDirection = CarouselRS.FILL_DIRECTION_CCW; + private boolean mFirstCardTop = false; public CarouselController() { boolean useDepthBuffer = true; @@ -110,6 +111,7 @@ public class CarouselController { setPrefetchCardCount(mPrefetchCardCount); setRowCount(mRowCount); setRowSpacing(mRowSpacing); + setFirstCardTop(mFirstCardTop); setDetailTextureAlignment(mDetailTextureAlignment); setForceBlendCardsWithZ(mForceBlendCardsWithZ); setDrawRuler(mDrawRuler); @@ -235,6 +237,16 @@ public class CarouselController { } } + /** + * Sets the position of the first card when rowCount > 1 . + */ + public void setFirstCardTop(boolean f) { + mFirstCardTop = f; + if (mRenderScript != null) { + mRenderScript.setFirstCardTop(f); + } + } + /** * Sets how detail textures are aligned with respect to the card. * diff --git a/carousel/java/com/android/ex/carousel/CarouselRS.java b/carousel/java/com/android/ex/carousel/CarouselRS.java index a5e53d2..ea4be35 100644 --- a/carousel/java/com/android/ex/carousel/CarouselRS.java +++ b/carousel/java/com/android/ex/carousel/CarouselRS.java @@ -453,6 +453,10 @@ public class CarouselRS { mScript.set_rowSpacing(spacing); } + public void setFirstCardTop(boolean first) { + mScript.set_firstCardTop(first); + } + public void setPrefetchCardCount(int count) { mPrefetchCardCount = count; mScript.set_prefetchCardCount(count); diff --git a/carousel/java/com/android/ex/carousel/CarouselView.java b/carousel/java/com/android/ex/carousel/CarouselView.java index 471e827..572f172 100644 --- a/carousel/java/com/android/ex/carousel/CarouselView.java +++ b/carousel/java/com/android/ex/carousel/CarouselView.java @@ -247,6 +247,13 @@ public abstract class CarouselView extends RSSurfaceView { } /** + * Sets the position of the first card when rowCount > 1. + */ + public void setFirstCardTop(boolean f) { + mController.setFirstCardTop(f); + } + + /** * Set the number of detail textures that can be visible at one time. * * @param n the number of slots diff --git a/carousel/java/com/android/ex/carousel/carousel.rs b/carousel/java/com/android/ex/carousel/carousel.rs index 45dbd21..e35cc1a 100644 --- a/carousel/java/com/android/ex/carousel/carousel.rs +++ b/carousel/java/com/android/ex/carousel/carousel.rs @@ -171,6 +171,7 @@ float detailFadeRate; // rate at which details fade as they move into the distan float4 backgroundColor; int rowCount; // number of rows of cards in a given slot, default 1 float rowSpacing; // spacing between rows of cards +bool firstCardTop; // set true for first card on top row when multiple rows used int dragModel = DRAG_MODEL_SCREEN_DELTA; int fillDirection; // the order in which to lay out cards: +1 for CCW (default), -1 for CW @@ -275,6 +276,7 @@ void init() { cardCount = 0; rowCount = 1; rowSpacing = 0.0f; + firstCardTop = false; fadeInDuration = 250; rezInCardCount = 0.0f; // alpha will ramp to 1.0f over this many cards (0.0f means disabled) detailFadeRate = 0.5f; // fade details over this many slot positions. @@ -552,7 +554,11 @@ static float getVerticalOffsetForCard(int i) { } const float cardHeight = cardVertices[3].y - cardVertices[0].y; const float totalHeight = rowCount * (cardHeight + rowSpacing) - rowSpacing; - const float rowOffset = (i % rowCount) * (cardHeight + rowSpacing); + if (firstCardTop) + i = rowCount - (i % rowCount) - 1; + else + i = i % rowCount; + const float rowOffset = i * (cardHeight + rowSpacing); return (cardHeight - totalHeight) / 2 + rowOffset; } |