summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-10-14 20:16:14 -0700
committerJason Sams <rjsams@android.com>2009-10-14 20:16:14 -0700
commitb52dfa066d602c2a7304180690c47010dc4fce76 (patch)
tree3e1a0ba338b2e74ff249d10107f0dd8f55f2f875
parentd8152b999423773e27949c0745de3f92f54b7151 (diff)
downloadandroid_packages_apps_Trebuchet-b52dfa066d602c2a7304180690c47010dc4fce76.tar.gz
android_packages_apps_Trebuchet-b52dfa066d602c2a7304180690c47010dc4fce76.tar.bz2
android_packages_apps_Trebuchet-b52dfa066d602c2a7304180690c47010dc4fce76.zip
Change allApps to new view. Tweak rollo3 phyisics.
-rw-r--r--res/raw/rollo3.c98
-rw-r--r--src/com/android/launcher2/AllAppsView.java26
2 files changed, 48 insertions, 76 deletions
diff --git a/res/raw/rollo3.c b/res/raw/rollo3.c
index d79326737..5eec22a91 100644
--- a/res/raw/rollo3.c
+++ b/res/raw/rollo3.c
@@ -8,7 +8,6 @@
// Attraction to center values from page edge to page center.
float g_AttractionTable[9];
-float g_FrictionTable[9];
float g_PhysicsTableSize;
float g_PosPage;
@@ -64,15 +63,6 @@ void init() {
g_AttractionTable[6] = -6.5f;
g_AttractionTable[7] = -6.5f;
g_AttractionTable[8] = -6.5f; // dup 7 to avoid a clamp later
- g_FrictionTable[0] = 3.5f;
- g_FrictionTable[1] = 3.6f;
- g_FrictionTable[2] = 4.0f;
- g_FrictionTable[3] = 5.0f;
- g_FrictionTable[4] = 5.0f;
- g_FrictionTable[5] = 4.0f;
- g_FrictionTable[6] = 3.6f;
- g_FrictionTable[7] = 3.5f;
- g_FrictionTable[8] = 3.5f; // dup 7 to avoid a clamp later
g_PhysicsTableSize = 7;
g_PosVelocity = 0;
@@ -121,21 +111,6 @@ void fling() {
}
}
-void touchUp() {
- g_LastTouchDown = 0;
-}
-
-int
-count_pages(int iconCount)
-{
- int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
- int pages = iconCount / iconsPerPage;
- if (pages*iconsPerPage != iconCount) {
- pages++;
- }
- return pages;
-}
-
float
modf(float x, float y)
{
@@ -155,23 +130,19 @@ void updatePos() {
float accel = lerpf(g_AttractionTable[tablePosI],
g_AttractionTable[tablePosI + 1],
tablePosFrac) * g_DT;
- float friction = lerpf(g_FrictionTable[tablePosI],
- g_FrictionTable[tablePosI + 1],
- tablePosFrac) * g_DT;
+ float friction = 4.f * g_DT;
if (g_PosPage < -0.5f) {
accel = g_AttractionTable[0] * g_DT;
- friction = g_FrictionTable[0] * g_DT;
outOfRange = 1;
}
if ((g_PosPage - g_PosMax) > 0.5f) {
accel = g_AttractionTable[(int)g_PhysicsTableSize] * g_DT;
- friction = g_FrictionTable[(int)g_PhysicsTableSize] * g_DT;
outOfRange = 1;
}
// If our velocity is low OR acceleration is opposing it, apply it.
- if (fabsf(g_PosVelocity) < 1.0f || (g_PosVelocity * accel) < 0) {
+ if (fabsf(g_PosVelocity) < 1.0f || (g_PosVelocity * accel) < 0 || outOfRange) {
g_PosVelocity += accel;
}
@@ -221,11 +192,8 @@ void updatePos() {
int positionStrip(float row, float column, int isTop)
{
float mat1[16];
-
float x = 0.5f * (column - 1.5f);
-
float scale = 72.f * 3 / getWidth();
- //float xscale = scale * 4.55 / 1.8f / 2;
if (isTop) {
matrixLoadTranslate(mat1, x, 0.8f, 0.f);
@@ -236,17 +204,16 @@ int positionStrip(float row, float column, int isTop)
}
vpLoadModelMatrix(mat1);
- float soff = row;
+ float soff = -(row * 1.4);
if (isTop) {
matrixLoadScale(mat1, 1.f, -0.85f, 1.f);
- matrixTranslate(mat1, 0, -(row * 1.4) - 0.97, 0);
+ matrixTranslate(mat1, 0, soff - 0.97f, 0);
} else {
matrixLoadScale(mat1, 1.f, 0.85f, 1.f);
- matrixTranslate(mat1, 0, -(row * 1.4) - 0.45, 0);
+ matrixTranslate(mat1, 0, soff - 0.45f, 0);
}
vpLoadTextureMatrix(mat1);
-
- return 0;//- soff * 10.f;
+ return -soff * 10.f;
}
void
@@ -321,10 +288,18 @@ void drawFrontGrid(float rowOffset)
}
}
-void drawTop(float rowOffset)
+void drawStrip(float row, float column, int isTop, int iconNum)
{
- int intRowOffset = rowOffset;
+ if (iconNum < 0) return;
+ int offset = positionStrip(row, column, isTop);
+ bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
+ if (offset < -20) return;
+ offset = clamp(offset, 0, 199 - 20);
+ drawSimpleMeshRange(NAMED_SMMesh2, offset * 6, 20 * 6);
+}
+void drawTop(float rowOffset)
+{
int row, col;
int iconNum = 0;
for (row = 0; row < rowOffset; row++) {
@@ -332,10 +307,7 @@ void drawTop(float rowOffset)
if (iconNum >= state->iconCount) {
return;
}
-
- int ps = positionStrip(rowOffset - row, col, 1);
- bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
- drawSimpleMesh(NAMED_SMMesh2);
+ drawStrip(rowOffset - row, col, 1, iconNum);
iconNum++;
}
}
@@ -355,9 +327,7 @@ void drawBottom(float rowOffset)
return;
}
if (pos > -1) {
- int ps = positionStrip(pos, col, 0);
- bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
- drawSimpleMesh(NAMED_SMMesh2);
+ drawStrip(pos, col, 0, iconNum);
}
iconNum++;
}
@@ -378,10 +348,8 @@ main(int launchID)
// assume 30fps in this case.
g_DT = 0.033f;
}
- if (g_DT > 0.2f) {
- // physics may break if DT is large.
- g_DT = 0.2f;
- }
+ // physics may break if DT is large.
+ g_DT = minf(g_DT, 0.2f);
if (g_Zoom != state->zoomTarget) {
float dz = (state->zoomTarget - g_Zoom) * g_DT * 5;
@@ -429,31 +397,14 @@ main(int launchID)
//bindProgramFragment(NAMED_PFColor);
//positionStrip(1, 0, 0);
//drawSimpleMesh(NAMED_SMMesh2);
- //positionStrip(1, 1);
- //drawSimpleMesh(NAMED_SMMesh2);
- //positionStrip(1, 2);
- //drawSimpleMesh(NAMED_SMMesh2);
- //positionStrip(1, 3);
- //drawSimpleMesh(NAMED_SMMesh2);
bindProgramFragment(NAMED_PFTexLinear);
- int lastIcon = iconCount-1;
-
- int page = g_PosPage;
- float currentPagePosition = g_PosPage - page;
-
- int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
- float scale = (1 / g_Zoom);
-
- float pageAngle = VIEW_ANGLE * 1.2f;
-
- float zoomOffset = 40 * (1 - g_Zoom);
-
- drawTop(g_PosPage);
- drawBottom(g_PosPage);
- drawFrontGrid(g_PosPage);
+ float zoomOffset = 8.f * (1 - g_Zoom);
+ drawTop(g_PosPage - zoomOffset);
+ drawBottom(g_PosPage - zoomOffset);
+ drawFrontGrid(g_PosPage - zoomOffset);
{
float mat1[16];
@@ -461,6 +412,7 @@ main(int launchID)
vpLoadModelMatrix(mat1);
vpLoadTextureMatrix(mat1);
}
+ draw_home_button();
if (0) {
float h = getHeight();
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index 4d340cab9..27afaf4fa 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -219,7 +219,7 @@ public class AllAppsView extends RSSurfaceView
switch (action) {
case MotionEvent.ACTION_DOWN:
if (x < 60 && y > 700) {
- mRotateMove = mRollo.setView((++mRSMode) & 3);
+ //mRotateMove = mRollo.setView((++mRSMode) & 3);
}
if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
@@ -1005,7 +1005,7 @@ public class AllAppsView extends RSSurfaceView
mAllocTouchXBorders.data(mTouchXBorders);
}
- int chooseTappedIcon(int x, int y, float page) {
+ int chooseTappedIconHorz(int x, int y, float page) {
int currentPage = (int)page;
int col = -1;
@@ -1032,6 +1032,20 @@ public class AllAppsView extends RSSurfaceView
+ (row * Defines.ROWS_PER_PAGE) + col;
}
+ int chooseTappedIconVert(int x, int y, float pos) {
+ int ydead = (getHeight() - 4 * 145) / 2;
+ if (y < ydead || y > (getHeight() - ydead)) {
+ return -1;
+ }
+
+ y -= ydead;
+ y += pos * 145;
+ int row = y / 145;
+ int col = x / 120;
+
+ return row * 4 + col;
+ }
+
boolean setView(int v) {
mViewMode = v;
mRS.contextBindRootScript(mScript[mViewMode]);
@@ -1050,7 +1064,13 @@ public class AllAppsView extends RSSurfaceView
* You need to call save() on mState on your own after calling this.
*/
void selectIcon(int x, int y, float pos) {
- int index = chooseTappedIcon(x, y, pos);
+ int index;
+ //Log.e("rs", "select " + x + ", " + y + ", " + pos + ", " + mViewMode);
+ if (mViewMode != 0) {
+ index = chooseTappedIconHorz(x, y, pos);
+ } else {
+ index = chooseTappedIconVert(x, y, pos);
+ }
selectIcon(index);
}