Reset rollo to page 0 when it's fully zoomed out.
This commit is contained in:
parent
0a8dc2cd98
commit
360d0353fd
|
@ -92,6 +92,10 @@ void fling() {
|
|||
//g_Zoom += (maxf(fabsf(g_PosVelocity), 3) - 3) / 2.f;
|
||||
}
|
||||
|
||||
void touchUp() {
|
||||
g_LastTouchDown = 0;
|
||||
}
|
||||
|
||||
void setZoomTarget() {
|
||||
g_ZoomTarget = state->zoomTarget;
|
||||
//debugF("zoom target", g_ZoomTarget);
|
||||
|
@ -320,8 +324,10 @@ main(int launchID)
|
|||
// Set clear value to dim the background based on the zoom position.
|
||||
if (g_Zoom < 0.001f) {
|
||||
pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// Nothing else to do if fully zoomed out.
|
||||
g_PosPage = roundf(g_PosPage);
|
||||
// When we're zoomed out and not tracking motion events, reset the pos to 0.
|
||||
if (!g_LastTouchDown) {
|
||||
g_PosPage = 0;
|
||||
}
|
||||
return 1; // 0;
|
||||
} else if (g_Zoom < 0.8f) {
|
||||
pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
|
||||
|
@ -329,8 +335,6 @@ main(int launchID)
|
|||
pfClearColor(0.0f, 0.0f, 0.0f, 0.80f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// icons & labels
|
||||
int iconCount = state->iconCount;
|
||||
g_PageCount = count_pages(iconCount);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class AllAppsView extends RSSurfaceView
|
|||
private int mMotionDownRawY;
|
||||
private int mScrollHandleTop;
|
||||
private long mTouchTime;
|
||||
private boolean mZoomSwipeInProgress;
|
||||
|
||||
static class Defines {
|
||||
private static float farSize(float sizeAt0) {
|
||||
|
@ -236,16 +237,17 @@ public class AllAppsView extends RSSurfaceView
|
|||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!mZoomSwipeInProgress) {
|
||||
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
|
||||
mRollo.mState.newTouchDown = 0;
|
||||
|
||||
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
|
||||
mRollo.mState.newTouchDown = 0;
|
||||
|
||||
mVelocity.computeCurrentVelocity(1000 /* px/sec */,
|
||||
mConfig.getScaledMaximumFlingVelocity());
|
||||
mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
|
||||
mRollo.clearSelectedIcon();
|
||||
mRollo.mState.save();
|
||||
mRollo.mInvokeFling.execute();
|
||||
mVelocity.computeCurrentVelocity(1000 /* px/sec */,
|
||||
mConfig.getScaledMaximumFlingVelocity());
|
||||
mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
|
||||
mRollo.clearSelectedIcon();
|
||||
mRollo.mState.save();
|
||||
mRollo.mInvokeFling.execute();
|
||||
}
|
||||
mLastMotionX = -10000;
|
||||
mVelocity.recycle();
|
||||
mVelocity = null;
|
||||
|
@ -297,6 +299,15 @@ public class AllAppsView extends RSSurfaceView
|
|||
public void onDropCompleted(View target, boolean success) {
|
||||
}
|
||||
|
||||
public void setZoomSwipeInProgress(boolean swiping, boolean touchStillDown) {
|
||||
mZoomSwipeInProgress = swiping;
|
||||
if (!touchStillDown) {
|
||||
mRollo.mState.newTouchDown = 0;
|
||||
mRollo.mState.save();
|
||||
mRollo.mInvokeTouchUp.execute();
|
||||
}
|
||||
}
|
||||
|
||||
public void setZoomTarget(float amount) {
|
||||
zoom(amount, true);
|
||||
}
|
||||
|
@ -403,6 +414,7 @@ public class AllAppsView extends RSSurfaceView
|
|||
private Script.Invokable mInvokeFling;
|
||||
private Script.Invokable mInvokeSetZoomTarget;
|
||||
private Script.Invokable mInvokeSetZoom;
|
||||
private Script.Invokable mInvokeTouchUp;
|
||||
|
||||
private Sampler mSampler;
|
||||
private Sampler mSamplerText;
|
||||
|
@ -631,6 +643,7 @@ public class AllAppsView extends RSSurfaceView
|
|||
mInvokeFling = sb.addInvokable("fling");
|
||||
mInvokeSetZoomTarget = sb.addInvokable("setZoomTarget");
|
||||
mInvokeSetZoom = sb.addInvokable("setZoom");
|
||||
mInvokeTouchUp = sb.addInvokable("touchUp");
|
||||
mScript = sb.create();
|
||||
mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ public class SwipeController {
|
|||
mTracking = false;
|
||||
mDownX = screenX;
|
||||
mDownY = screenY;
|
||||
mAllAppsView.setZoomSwipeInProgress(true, true);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
|
@ -132,6 +133,7 @@ public class SwipeController {
|
|||
if (Math.abs(deltaX) > mSlop) {
|
||||
mCanceled = true;
|
||||
mTracking = false;
|
||||
mAllAppsView.setZoomSwipeInProgress(false, true);
|
||||
}
|
||||
if (Math.abs(deltaY) > mSlop) {
|
||||
mTracking = true;
|
||||
|
@ -146,6 +148,7 @@ public class SwipeController {
|
|||
case MotionEvent.ACTION_UP:
|
||||
if (mTracking && !mCanceled) {
|
||||
fling(screenY);
|
||||
mAllAppsView.setZoomSwipeInProgress(false, false);
|
||||
}
|
||||
mVelocityTracker.recycle();
|
||||
mVelocityTracker = null;
|
||||
|
|
Loading…
Reference in New Issue