Put the home button back in.

This commit is contained in:
Joe Onorato
2009-10-01 21:45:43 -07:00
parent fccc8dfc8a
commit bcbeab8fc7
4 changed files with 133 additions and 77 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

+21 -2
View File
@@ -275,6 +275,23 @@ draw_page(int icon, int lastIcon, float centerAngle, float scale)
} }
} }
void
draw_home_button()
{
color(1.0f, 1.0f, 1.0f, 1.0f);
bindTexture(NAMED_PFTexLinear, 0, params->homeButtonId);
float scale = 2.0f / SCREEN_WIDTH_PX;
float x = 0.0f;
float y = -(SCREEN_HEIGHT_PX / (float)SCREEN_WIDTH_PX);
y += g_Zoom * (scale * params->homeButtonTextureHeight / 2);
float z = 0.0f;
drawSprite(x, y, z, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
}
int int
main(int launchID) main(int launchID)
{ {
@@ -312,7 +329,7 @@ main(int launchID)
} else if (g_Zoom < 0.85f) { } else if (g_Zoom < 0.85f) {
pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom); pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
} else { } else {
pfClearColor(0.0f, 0.0f, 0.0f, 0.85f); pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
} }
// icons & labels // icons & labels
@@ -362,7 +379,9 @@ main(int launchID)
} }
*/ */
// Draw the scroll handle ======================================== // Draw the home button ========================================
draw_home_button();
/* /*
bindTexture(NAMED_PFOrtho, 0, loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_ID)); bindTexture(NAMED_PFOrtho, 0, loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_ID));
float handleLeft = 40 + (320 * (scrollXPx/(float)(maxScrollXPx))); float handleLeft = 40 + (320 * (scrollXPx/(float)(maxScrollXPx)));
+112 -75
View File
@@ -67,6 +67,9 @@ public class AllAppsView extends RSSurfaceView
/** Bit for mLocks for when there are icons being loaded. */ /** Bit for mLocks for when there are icons being loaded. */
private static final int LOCK_ICONS_PENDING = 1; private static final int LOCK_ICONS_PENDING = 1;
private static final int TRACKING_FLING = 0;
private static final int TRACKING_HOME = 1;
private Launcher mLauncher; private Launcher mLauncher;
private DragController mDragController; private DragController mDragController;
@@ -77,6 +80,7 @@ public class AllAppsView extends RSSurfaceView
private int mSlopX; private int mSlopX;
private int mMaxFlingVelocity; private int mMaxFlingVelocity;
private Defines mDefines = new Defines();
private RenderScript mRS; private RenderScript mRS;
private RolloRS mRollo; private RolloRS mRollo;
private ArrayList<ApplicationInfo> mAllAppsList; private ArrayList<ApplicationInfo> mAllAppsList;
@@ -84,18 +88,15 @@ public class AllAppsView extends RSSurfaceView
private int mPageCount; private int mPageCount;
private boolean mStartedScrolling; private boolean mStartedScrolling;
private VelocityTracker mVelocity; private VelocityTracker mVelocity;
private int mTouchTracking;
private int mLastMotionX; private int mLastMotionX;
private int mMotionDownRawX; private int mMotionDownRawX;
private int mMotionDownRawY; private int mMotionDownRawY;
private int mScrollHandleTop; private int mHomeButtonTop;
private long mTouchTime; private long mTouchTime;
private boolean mZoomSwipeInProgress; private boolean mZoomSwipeInProgress;
static class Defines { static class Defines {
private static float farSize(float sizeAt0) {
return sizeAt0 * (Defines.RADIUS - Defines.CAMERA_Z) / -Defines.CAMERA_Z;
}
public static final int ALLOC_PARAMS = 0; public static final int ALLOC_PARAMS = 0;
public static final int ALLOC_STATE = 1; public static final int ALLOC_STATE = 1;
public static final int ALLOC_READBACK = 2; public static final int ALLOC_READBACK = 2;
@@ -109,9 +110,6 @@ public class AllAppsView extends RSSurfaceView
public static final float RADIUS = 4.0f; public static final float RADIUS = 4.0f;
public static final int SCREEN_WIDTH_PX = 480;
public static final int SCREEN_HEIGHT_PX = 854;
public static final int ICON_WIDTH_PX = 64; public static final int ICON_WIDTH_PX = 64;
public static final int ICON_TEXTURE_WIDTH_PX = 128; public static final int ICON_TEXTURE_WIDTH_PX = 128;
@@ -120,8 +118,21 @@ public class AllAppsView extends RSSurfaceView
public static final float ICON_TOP_OFFSET = 0.2f; public static final float ICON_TOP_OFFSET = 0.2f;
public static final float CAMERA_Z = -2; public static final float CAMERA_Z = -2;
public static final float FAR_ICON_SIZE
= farSize(2 * ICON_WIDTH_PX / (float)SCREEN_WIDTH_PX); public int SCREEN_WIDTH_PX;
public int SCREEN_HEIGHT_PX;
public float FAR_ICON_SIZE;
public void recompute(int w, int h) {
SCREEN_WIDTH_PX = 480;
SCREEN_HEIGHT_PX = 800;
FAR_ICON_SIZE = farSize(2 * ICON_WIDTH_PX / (float)w);
}
private static float farSize(float sizeAt0) {
return sizeAt0 * (Defines.RADIUS - Defines.CAMERA_Z) / -Defines.CAMERA_Z;
}
} }
public AllAppsView(Context context, AttributeSet attrs) { public AllAppsView(Context context, AttributeSet attrs) {
@@ -171,7 +182,7 @@ public class AllAppsView extends RSSurfaceView
Resources res = getContext().getResources(); Resources res = getContext().getResources();
int barHeight = (int)res.getDimension(R.dimen.button_bar_height); int barHeight = (int)res.getDimension(R.dimen.button_bar_height);
mScrollHandleTop = h - barHeight; mHomeButtonTop = h - barHeight;
long endTime = SystemClock.uptimeMillis(); long endTime = SystemClock.uptimeMillis();
Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms"); Log.d(TAG, "surfaceChanged took " + (endTime-startTime) + "ms");
@@ -198,67 +209,89 @@ public class AllAppsView extends RSSurfaceView
super.onTouchEvent(ev); super.onTouchEvent(ev);
int x = (int)ev.getX(); int x = (int)ev.getX();
int y = (int)ev.getY();
int deltaX; int deltaX;
switch (ev.getAction()) { int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
mMotionDownRawX = (int)ev.getRawX(); if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
mMotionDownRawY = (int)ev.getRawY(); mTouchTracking = TRACKING_HOME;
mLastMotionX = x;
mRollo.mReadback.read();
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 1;
if (!mRollo.checkClickOK()) {
mRollo.clearSelectedIcon();
} else { } else {
mRollo.selectIcon(x, (int)ev.getY(), mRollo.mReadback.posX); mTouchTracking = TRACKING_FLING;
mMotionDownRawX = (int)ev.getRawX();
mMotionDownRawY = (int)ev.getRawY();
mLastMotionX = x;
mRollo.mReadback.read();
mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 1;
if (!mRollo.checkClickOK()) {
mRollo.clearSelectedIcon();
} else {
mRollo.selectIcon(x, y, mRollo.mReadback.posX);
}
mRollo.mState.save();
mRollo.mInvokeMove.execute();
mVelocity = VelocityTracker.obtain();
mVelocity.addMovement(ev);
mStartedScrolling = false;
} }
mRollo.mState.save();
mRollo.mInvokeMove.execute();
mVelocity = VelocityTracker.obtain();
mVelocity.addMovement(ev);
mStartedScrolling = false;
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_OUTSIDE: case MotionEvent.ACTION_OUTSIDE:
int slopX = Math.abs(x - mLastMotionX); if (mTouchTracking == TRACKING_HOME) {
if (!mStartedScrolling && slopX < mSlopX) { // TODO: highlight?
// don't update mLastMotionX so slopX is right and when we do start scrolling
// below, we get the right delta.
} else { } else {
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX; int slopX = Math.abs(x - mLastMotionX);
mRollo.mState.newTouchDown = 1; if (!mStartedScrolling && slopX < mSlopX) {
mRollo.mInvokeMove.execute(); // don't update mLastMotionX so slopX is right and when we do start scrolling
// below, we get the right delta.
} else {
mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 1;
mRollo.mInvokeMove.execute();
mStartedScrolling = true; mStartedScrolling = true;
mRollo.clearSelectedIcon(); mRollo.clearSelectedIcon();
deltaX = x - mLastMotionX; deltaX = x - mLastMotionX;
mVelocity.addMovement(ev); mVelocity.addMovement(ev);
mRollo.mState.save(); mRollo.mState.save();
mLastMotionX = x; mLastMotionX = x;
}
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
mRollo.mState.newTouchDown = 0; if (mTouchTracking == TRACKING_HOME) {
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX; if (action == MotionEvent.ACTION_UP) {
if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
if (!mZoomSwipeInProgress) { mLauncher.closeAllApps(true);
mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity); }
mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX; }
mRollo.clearSelectedIcon();
mRollo.mState.save();
mRollo.mInvokeFling.execute();
} else { } else {
mRollo.mState.save(); mRollo.mState.newTouchDown = 0;
mRollo.mInvokeMove.execute(); mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
}
mLastMotionX = -10000; if (!mZoomSwipeInProgress) {
mVelocity.recycle(); mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
mVelocity = null; mRollo.mState.flingVelocityX
break; = mVelocity.getXVelocity() / mDefines.SCREEN_WIDTH_PX;
mRollo.clearSelectedIcon();
mRollo.mState.save();
mRollo.mInvokeFling.execute();
} else {
mRollo.mState.save();
mRollo.mInvokeMove.execute();
}
mLastMotionX = -10000;
mVelocity.recycle();
mVelocity = null;
break;
}
} }
return true; return true;
@@ -285,13 +318,13 @@ public class AllAppsView extends RSSurfaceView
ApplicationInfo app = mAllAppsList.get(index); ApplicationInfo app = mAllAppsList.get(index);
// We don't really have an accurate location to use. This will do. // We don't really have an accurate location to use. This will do.
int screenX = mMotionDownRawX - (Defines.ICON_WIDTH_PX / 2); int screenX = mMotionDownRawX - (mDefines.ICON_WIDTH_PX / 2);
int screenY = mMotionDownRawY - Defines.ICON_HEIGHT_PX; int screenY = mMotionDownRawY - mDefines.ICON_HEIGHT_PX;
int left = (Defines.ICON_TEXTURE_WIDTH_PX - Defines.ICON_WIDTH_PX) / 2; int left = (mDefines.ICON_TEXTURE_WIDTH_PX - mDefines.ICON_WIDTH_PX) / 2;
int top = (Defines.ICON_TEXTURE_HEIGHT_PX - Defines.ICON_HEIGHT_PX) / 2; int top = (mDefines.ICON_TEXTURE_HEIGHT_PX - mDefines.ICON_HEIGHT_PX) / 2;
mDragController.startDrag(app.iconBitmap, screenX, screenY, mDragController.startDrag(app.iconBitmap, screenX, screenY,
left, top, Defines.ICON_WIDTH_PX, Defines.ICON_HEIGHT_PX, left, top, mDefines.ICON_WIDTH_PX, mDefines.ICON_HEIGHT_PX,
this, app, DragController.DRAG_ACTION_COPY); this, app, DragController.DRAG_ACTION_COPY);
mLauncher.closeAllApps(true); mLauncher.closeAllApps(true);
@@ -431,7 +464,7 @@ public class AllAppsView extends RSSurfaceView
private ProgramVertex mPV; private ProgramVertex mPV;
private ProgramVertex mPVOrtho; private ProgramVertex mPVOrtho;
private Allocation mScrollHandle; private Allocation mHomeButton;
private Allocation[] mIcons; private Allocation[] mIcons;
private int[] mIconIds; private int[] mIconIds;
@@ -479,9 +512,12 @@ public class AllAppsView extends RSSurfaceView
public int bubbleHeight; public int bubbleHeight;
public int bubbleBitmapWidth; public int bubbleBitmapWidth;
public int bubbleBitmapHeight; public int bubbleBitmapHeight;
public int scrollHandleId;
public int scrollHandleTextureWidth; public int homeButtonId;
public int scrollHandleTextureHeight; public int homeButtonWidth;
public int homeButtonHeight;
public int homeButtonTextureWidth;
public int homeButtonTextureHeight;
} }
class State extends BaseAlloc { class State extends BaseAlloc {
@@ -526,6 +562,7 @@ public class AllAppsView extends RSSurfaceView
mRes = res; mRes = res;
mWidth = width; mWidth = width;
mHeight = height; mHeight = height;
mDefines.recompute(width, height);
initProgramVertex(); initProgramVertex();
initProgramFragment(); initProgramFragment();
initProgramStore(); initProgramStore();
@@ -619,14 +656,14 @@ public class AllAppsView extends RSSurfaceView
mParams.bubbleBitmapWidth = bubble.getBitmapWidth(); mParams.bubbleBitmapWidth = bubble.getBitmapWidth();
mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
mScrollHandle = Allocation.createFromBitmapResource(mRS, mRes, mHomeButton = Allocation.createFromBitmapResource(mRS, mRes,
R.drawable.all_apps_button_pow2, Element.RGBA_8888(mRS), false); R.drawable.home_button, Element.RGBA_8888(mRS), false);
mScrollHandle.uploadToTexture(0); mHomeButton.uploadToTexture(0);
mParams.scrollHandleId = mScrollHandle.getID(); mParams.homeButtonId = mHomeButton.getID();
Log.d(TAG, "mParams.scrollHandleId=" + mParams.scrollHandleId); mParams.homeButtonWidth = 76;
mParams.scrollHandleTextureWidth = 128; mParams.homeButtonHeight = 68;
mParams.scrollHandleTextureHeight = 128; mParams.homeButtonTextureWidth = 128;
mParams.homeButtonTextureHeight = 128;
mParams.save(); mParams.save();
mState.save(); mState.save();
@@ -644,7 +681,7 @@ public class AllAppsView extends RSSurfaceView
ScriptC.Builder sb = new ScriptC.Builder(mRS); ScriptC.Builder sb = new ScriptC.Builder(mRS);
sb.setScript(mRes, R.raw.rollo); sb.setScript(mRes, R.raw.rollo);
sb.setRoot(true); sb.setRoot(true);
sb.addDefines(Defines.class); sb.addDefines(mDefines);
sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS); sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
sb.setType(mState.mType, "state", Defines.ALLOC_STATE); sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
sb.setType(mReadback.mType, "readback", Defines.ALLOC_READBACK); sb.setType(mReadback.mType, "readback", Defines.ALLOC_READBACK);