diff options
author | Jason Sams <rjsams@android.com> | 2009-10-20 18:19:55 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-10-20 18:19:55 -0700 |
commit | 2e19c05891c9c7abd2200b8f9ade875a3ca02aa6 (patch) | |
tree | 6591c74c1f35f855e6cf5080675a37150f87ed3d | |
parent | 96b49d860cbb54daf83721ec67d292140e6753c9 (diff) | |
download | android_packages_apps_Trebuchet-2e19c05891c9c7abd2200b8f9ade875a3ca02aa6.tar.gz android_packages_apps_Trebuchet-2e19c05891c9c7abd2200b8f9ade875a3ca02aa6.tar.bz2 android_packages_apps_Trebuchet-2e19c05891c9c7abd2200b8f9ade875a3ca02aa6.zip |
Return friction table, tweak values for line rather than pages.
-rw-r--r-- | res/raw/rollo3.c | 44 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsView.java | 28 |
2 files changed, 42 insertions, 30 deletions
diff --git a/res/raw/rollo3.c b/res/raw/rollo3.c index ffd59d01c..1e7b5f018 100644 --- a/res/raw/rollo3.c +++ b/res/raw/rollo3.c @@ -9,6 +9,7 @@ int g_SpecialHWWar; // Attraction to center values from page edge to page center. float g_AttractionTable[9]; +float g_FrictionTable[9]; float g_PhysicsTableSize; float g_PosPage; @@ -66,15 +67,24 @@ void setColor(float r, float g, float b, float a) { } void init() { - g_AttractionTable[0] = 6.5f; - g_AttractionTable[1] = 6.5f; - g_AttractionTable[2] = 7.0f; - g_AttractionTable[3] = 6.0f; - g_AttractionTable[4] = -6.0f; - g_AttractionTable[5] = -7.0f; - g_AttractionTable[6] = -6.5f; - g_AttractionTable[7] = -6.5f; - g_AttractionTable[8] = -6.5f; // dup 7 to avoid a clamp later + g_AttractionTable[0] = 20.0f; + g_AttractionTable[1] = 20.0f; + g_AttractionTable[2] = 15.0f; + g_AttractionTable[3] = 10.0f; + g_AttractionTable[4] = -10.0f; + g_AttractionTable[5] = -15.0f; + g_AttractionTable[6] = -15.0f; + g_AttractionTable[7] = -20.0f; + g_AttractionTable[8] = -20.0f; // dup 7 to avoid a clamp later + g_FrictionTable[0] = 10.0f; + g_FrictionTable[1] = 10.0f; + g_FrictionTable[2] = 11.0f; + g_FrictionTable[3] = 15.0f; + g_FrictionTable[4] = 15.0f; + g_FrictionTable[5] = 11.0f; + g_FrictionTable[6] = 10.0f; + g_FrictionTable[7] = 10.0f; + g_FrictionTable[8] = 10.0f; // dup 7 to avoid a clamp later g_PhysicsTableSize = 7; g_PosVelocity = 0; @@ -112,7 +122,7 @@ void moveTo() { g_MoveToTime = g_MoveToTotalTime; g_PosVelocity = 0; g_MoveToOldPos = g_PosPage; - + // debugF("======= moveTo", state->targetPos); } @@ -170,10 +180,12 @@ void updatePos() { float accel = lerpf(g_AttractionTable[tablePosI], g_AttractionTable[tablePosI + 1], tablePosFrac) * g_DT; - float friction = 4.f * g_DT; + float friction = lerpf(g_FrictionTable[tablePosI], + g_FrictionTable[tablePosI + 1], + tablePosFrac) * g_DT; if (g_MoveToTime) { - + /* float a = 2.f * (state->targetPos - g_MoveToOldPos) / (g_MoveToTotalTime * g_MoveToTotalTime); @@ -186,10 +198,10 @@ void updatePos() { g_PosPage = g_MoveToOldPos + 0.5f * a * (t * t); } */ - + // New position is old posiition + (total distance) * (interpolated time) g_PosPage = g_MoveToOldPos + (state->targetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime); - + g_MoveToTime -= g_DT; if (g_MoveToTime <= 0) { g_MoveToTime = 0; @@ -208,7 +220,7 @@ void updatePos() { } // If our velocity is low OR acceleration is opposing it, apply it. - if (fabsf(g_PosVelocity) < 1.0f || (g_PosVelocity * accel) < 0 || outOfRange) { + if (fabsf(g_PosVelocity) < 2.5f || (g_PosVelocity * accel) < 0 || outOfRange) { g_PosVelocity += accel; } @@ -424,7 +436,7 @@ main(int launchID) int newTime = uptimeMillis(); g_DT = (newTime - g_LastTime) / 1000.f; g_LastTime = newTime; - + if (!g_DrawLastFrame) { // If we stopped rendering we cannot use DT. // assume 30fps in this case. diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index 9c73a01be..d842f2d95 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -88,12 +88,12 @@ public class AllAppsView extends RSSurfaceView private RenderScript mRS; private RolloRS mRollo; private ArrayList<ApplicationInfo> mAllAppsList; - + /** * True when we are using arrow keys or trackball to drive navigation */ private boolean mArrowNavigation = false; - + private int mPageCount; private boolean mStartedScrolling; private VelocityTracker mVelocity; @@ -181,7 +181,7 @@ public class AllAppsView extends RSSurfaceView long endTime = SystemClock.uptimeMillis(); Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms"); } - + @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { @@ -205,7 +205,7 @@ public class AllAppsView extends RSSurfaceView @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - + if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) { if (mArrowNavigation) { int whichApp = mRollo.mState.selectedIconIndex; @@ -215,20 +215,20 @@ public class AllAppsView extends RSSurfaceView } } } - + if (mArrowNavigation && mRollo.mState.iconCount > 0) { mArrowNavigation = true; - + int currentSelection = mRollo.mState.selectedIconIndex; int currentTopRow = (int) mRollo.mMessageProc.mPosX; - + // The column of the current selection, in the range 0..COLUMNS_PER_PAGE-1 int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE; - + // The row of the current selection, in the range 0..ROWS_PER_PAGE-1 int currentPageRow = (currentSelection - (currentTopRow * Defines.COLUMNS_PER_PAGE)) / Defines.ROWS_PER_PAGE; - + int newSelection = currentSelection; switch (keyCode) { @@ -237,7 +237,7 @@ public class AllAppsView extends RSSurfaceView newSelection = currentSelection - Defines.COLUMNS_PER_PAGE; } else if (currentTopRow > 0) { mRollo.moveTo(currentTopRow - 1); - newSelection = currentSelection - Defines.COLUMNS_PER_PAGE; + newSelection = currentSelection - Defines.COLUMNS_PER_PAGE; } break; case KeyEvent.KEYCODE_DPAD_DOWN: @@ -256,7 +256,7 @@ public class AllAppsView extends RSSurfaceView } break; case KeyEvent.KEYCODE_DPAD_RIGHT: - if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) && + if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) && (currentSelection < mRollo.mState.iconCount - 1)) { newSelection = currentSelection + 1; } @@ -276,7 +276,7 @@ public class AllAppsView extends RSSurfaceView public boolean onTouchEvent(MotionEvent ev) { mArrowNavigation = false; - + if (!isVisible()) { return true; } @@ -635,8 +635,8 @@ public class AllAppsView extends RSSurfaceView private boolean checkClickOK() { //android.util.Log.e("rs", "check click " + Float.toString(mReadback.velocity) + ", " + Float.toString(mReadback.posX)); - return (Math.abs(mMessageProc.mVelocity) < 0.1f) && - (Math.abs(mMessageProc.mPosX - Math.round(mMessageProc.mPosX)) < 0.1f); + return (Math.abs(mMessageProc.mVelocity) < 0.4f) && + (Math.abs(mMessageProc.mPosX - Math.round(mMessageProc.mPosX)) < 0.4f); } class Params extends BaseAlloc { |