Bug 706891 part 1 - Rename Axis setLocked/mLocked to setScrolledDisabled/mScrollingDisabled to clarify meaning. r=kats

This commit is contained in:
Chris Peterson 2012-02-14 10:55:22 -08:00
parent 5e22b7de58
commit 307a888c50
2 changed files with 16 additions and 15 deletions

View File

@ -88,7 +88,7 @@ abstract class Axis {
private float mTouchPos; /* Position of the most recent touch event on the current drag. */ private float mTouchPos; /* Position of the most recent touch event on the current drag. */
private float mLastTouchPos; /* Position of the touch event before touchPos. */ private float mLastTouchPos; /* Position of the touch event before touchPos. */
private float mVelocity; /* Velocity in this direction; pixels per animation frame. */ private float mVelocity; /* Velocity in this direction; pixels per animation frame. */
private boolean mLocked; /* Whether movement on this axis is locked. */ public boolean mScrollingDisabled; /* Whether movement on this axis is locked. */
private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */ private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */
private float mDisplacement; private float mDisplacement;
@ -108,7 +108,7 @@ abstract class Axis {
void startTouch(float pos) { void startTouch(float pos) {
mVelocity = 0.0f; mVelocity = 0.0f;
mLocked = false; mScrollingDisabled = false;
mFirstTouchPos = mTouchPos = mLastTouchPos = pos; mFirstTouchPos = mTouchPos = mLastTouchPos = pos;
} }
@ -116,8 +116,8 @@ abstract class Axis {
return currentPos - mFirstTouchPos; return currentPos - mFirstTouchPos;
} }
void setLocked(boolean locked) { void setScrollingDisabled(boolean disabled) {
mLocked = locked; mScrollingDisabled = disabled;
} }
void saveTouchPos() { void saveTouchPos() {
@ -172,11 +172,12 @@ abstract class Axis {
} }
/* /*
* Returns true if the page is zoomed in to some degree along this axis such that scrolling * Returns true if the page is zoomed in to some degree along this axis such that scrolling is
* is possible. Otherwise, returns false. * possible and this axis has not been scroll locked while panning. Otherwise, returns false.
*/ */
private boolean scrollable() { private boolean scrollable() {
return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE; return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE &&
!mScrollingDisabled;
} }
/* /*
@ -195,7 +196,7 @@ abstract class Axis {
/* Returns the velocity. If the axis is locked, returns 0. */ /* Returns the velocity. If the axis is locked, returns 0. */
float getRealVelocity() { float getRealVelocity() {
return (mLocked || !scrollable()) ? 0.0f : mVelocity; return scrollable() ? mVelocity : 0f;
} }
void startPan() { void startPan() {
@ -253,7 +254,7 @@ abstract class Axis {
// Performs displacement of the viewport position according to the current velocity. // Performs displacement of the viewport position according to the current velocity.
void displace() { void displace() {
if (!mSubscroller.scrolling() && (mLocked || !scrollable())) if (!mSubscroller.scrolling() && !scrollable())
return; return;
if (mFlingState == FlingStates.PANNING) if (mFlingState == FlingStates.PANNING)

View File

@ -387,17 +387,17 @@ public class PanZoomController
angle = Math.abs(angle); // range [0, pi] angle = Math.abs(angle); // range [0, pi]
if (angle < AXIS_LOCK_ANGLE || angle > (Math.PI - AXIS_LOCK_ANGLE)) { if (angle < AXIS_LOCK_ANGLE || angle > (Math.PI - AXIS_LOCK_ANGLE)) {
// lock to x-axis // lock to x-axis
mX.setLocked(false); mX.setScrollingDisabled(false);
mY.setLocked(true); mY.setScrollingDisabled(true);
} else if (Math.abs(angle - (Math.PI / 2)) < AXIS_LOCK_ANGLE) { } else if (Math.abs(angle - (Math.PI / 2)) < AXIS_LOCK_ANGLE) {
// lock to y-axis // lock to y-axis
mX.setLocked(true); mX.setScrollingDisabled(true);
mY.setLocked(false); mY.setScrollingDisabled(false);
} else { } else {
// break axis lock but log the angle so we can fine-tune this when people complain // break axis lock but log the angle so we can fine-tune this when people complain
mState = PanZoomState.PANNING; mState = PanZoomState.PANNING;
mX.setLocked(false); mX.setScrollingDisabled(false);
mY.setLocked(false); mY.setScrollingDisabled(false);
angle = Math.abs(angle - (Math.PI / 2)); // range [0, pi/2] angle = Math.abs(angle - (Math.PI / 2)); // range [0, pi/2]
} }
} }