зеркало из https://github.com/mozilla/gecko-dev.git
Bug 804949: Change the way panning works. r=cjones a=blocking-basecamp
This commit is contained in:
Родитель
cd35ecb8fa
Коммит
652bd75bad
|
@ -46,11 +46,6 @@ static const int32_t FLING_REPAINT_INTERVAL = 75;
|
||||||
*/
|
*/
|
||||||
static const float MIN_SKATE_SPEED = 0.7f;
|
static const float MIN_SKATE_SPEED = 0.7f;
|
||||||
|
|
||||||
/**
|
|
||||||
* Angle from axis within which we stay axis-locked.
|
|
||||||
*/
|
|
||||||
static const float AXIS_LOCK_ANGLE = M_PI / 9.0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duration of a zoom to animation.
|
* Duration of a zoom to animation.
|
||||||
*/
|
*/
|
||||||
|
@ -610,12 +605,6 @@ void AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent) {
|
||||||
angle = fabs(angle); // range [0, pi]
|
angle = fabs(angle); // range [0, pi]
|
||||||
|
|
||||||
SetState(PANNING);
|
SetState(PANNING);
|
||||||
|
|
||||||
if (angle < AXIS_LOCK_ANGLE || angle > (M_PI - AXIS_LOCK_ANGLE)) {
|
|
||||||
mY.LockPanning();
|
|
||||||
} else if (fabsf(angle - M_PI / 2) < AXIS_LOCK_ANGLE) {
|
|
||||||
mX.LockPanning();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(const MultiTouchInput& aEvent) {
|
void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(const MultiTouchInput& aEvent) {
|
||||||
|
|
|
@ -364,8 +364,8 @@ protected:
|
||||||
SingleTouchData& GetFirstSingleTouch(const MultiTouchInput& aEvent);
|
SingleTouchData& GetFirstSingleTouch(const MultiTouchInput& aEvent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up anything needed for panning. This may lock one of the axes if the
|
* Sets up anything needed for panning. This takes us out of the "TOUCHING"
|
||||||
* angle of movement is heavily skewed towards it.
|
* state and starts actually panning us.
|
||||||
*/
|
*/
|
||||||
void StartPanning(const MultiTouchInput& aStartPoint);
|
void StartPanning(const MultiTouchInput& aStartPoint);
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ private:
|
||||||
NOTHING, /* no touch-start events received */
|
NOTHING, /* no touch-start events received */
|
||||||
FLING, /* all touches removed, but we're still scrolling page */
|
FLING, /* all touches removed, but we're still scrolling page */
|
||||||
TOUCHING, /* one touch-start event received */
|
TOUCHING, /* one touch-start event received */
|
||||||
PANNING, /* panning without axis lock */
|
PANNING, /* panning the frame */
|
||||||
PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */
|
PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */
|
||||||
ANIMATING_ZOOM, /* animated zoom to a new rect */
|
ANIMATING_ZOOM, /* animated zoom to a new rect */
|
||||||
WAITING_LISTENERS, /* a state halfway between NOTHING and TOUCHING - the user has
|
WAITING_LISTENERS, /* a state halfway between NOTHING and TOUCHING - the user has
|
||||||
|
|
|
@ -52,17 +52,12 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
|
||||||
: mPos(0.0f),
|
: mPos(0.0f),
|
||||||
mVelocity(0.0f),
|
mVelocity(0.0f),
|
||||||
mAcceleration(0),
|
mAcceleration(0),
|
||||||
mAsyncPanZoomController(aAsyncPanZoomController),
|
mAsyncPanZoomController(aAsyncPanZoomController)
|
||||||
mLockPanning(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
|
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
|
||||||
if (mLockPanning) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float newVelocity = (mPos - aPos) / aTimeDelta.ToMilliseconds();
|
float newVelocity = (mPos - aPos) / aTimeDelta.ToMilliseconds();
|
||||||
|
|
||||||
bool curVelocityIsLow = fabsf(newVelocity) < 0.01f;
|
bool curVelocityIsLow = fabsf(newVelocity) < 0.01f;
|
||||||
|
@ -91,7 +86,6 @@ void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeD
|
||||||
void Axis::StartTouch(int32_t aPos) {
|
void Axis::StartTouch(int32_t aPos) {
|
||||||
mStartPos = aPos;
|
mStartPos = aPos;
|
||||||
mPos = aPos;
|
mPos = aPos;
|
||||||
mLockPanning = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Axis::GetDisplacementForDuration(float aScale, const TimeDuration& aDelta) {
|
float Axis::GetDisplacementForDuration(float aScale, const TimeDuration& aDelta) {
|
||||||
|
@ -126,10 +120,6 @@ void Axis::CancelTouch() {
|
||||||
mAcceleration = 0;
|
mAcceleration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Axis::LockPanning() {
|
|
||||||
mLockPanning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Axis::FlingApplyFrictionOrCancel(const TimeDuration& aDelta) {
|
bool Axis::FlingApplyFrictionOrCancel(const TimeDuration& aDelta) {
|
||||||
if (fabsf(mVelocity) <= FLING_STOPPED_THRESHOLD) {
|
if (fabsf(mVelocity) <= FLING_STOPPED_THRESHOLD) {
|
||||||
// If the velocity is very low, just set it to 0 and stop the fling,
|
// If the velocity is very low, just set it to 0 and stop the fling,
|
||||||
|
|
|
@ -66,14 +66,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void CancelTouch();
|
void CancelTouch();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets axis locking. This prevents any panning along this axis. If the
|
|
||||||
* current touch point is updated and the axis is locked, the velocity will
|
|
||||||
* not be recalculated. Any already-existing velocity will however stay the
|
|
||||||
* same.
|
|
||||||
*/
|
|
||||||
void LockPanning();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets displacement that should have happened since the previous touch.
|
* Gets displacement that should have happened since the previous touch.
|
||||||
* Note: Does not reset the displacement. It gets recalculated on the next
|
* Note: Does not reset the displacement. It gets recalculated on the next
|
||||||
|
@ -192,7 +184,6 @@ protected:
|
||||||
// reach one of the extremes of the page.
|
// reach one of the extremes of the page.
|
||||||
int32_t mAcceleration;
|
int32_t mAcceleration;
|
||||||
nsRefPtr<AsyncPanZoomController> mAsyncPanZoomController;
|
nsRefPtr<AsyncPanZoomController> mAsyncPanZoomController;
|
||||||
bool mLockPanning;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AxisX : public Axis {
|
class AxisX : public Axis {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче