mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-03-28 17:40:16 +01:00
Merge pull request #269 from alek3y/master
Fix abrupt multitouch movement
This commit is contained in:
commit
9e01762794
@ -60,6 +60,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
private var mIsBucketFillOn = false
|
private var mIsBucketFillOn = false
|
||||||
private var mWasMultitouch = false
|
private var mWasMultitouch = false
|
||||||
private var mIgnoreTouches = false
|
private var mIgnoreTouches = false
|
||||||
|
private var mIgnoreMultitouchChanges = false
|
||||||
private var mWasScalingInGesture = false
|
private var mWasScalingInGesture = false
|
||||||
private var mWasMovingCanvasInGesture = false
|
private var mWasMovingCanvasInGesture = false
|
||||||
private var mBackgroundColor = 0
|
private var mBackgroundColor = 0
|
||||||
@ -160,7 +161,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
actionMove(newValueX, newValueY)
|
actionMove(newValueX, newValueY)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAllowMovingZooming && mWasMultitouch) {
|
if (mAllowMovingZooming && mWasMultitouch && !mIgnoreMultitouchChanges) {
|
||||||
mPosX += x - mLastTouchX
|
mPosX += x - mLastTouchX
|
||||||
mPosY += y - mLastTouchY
|
mPosY += y - mLastTouchY
|
||||||
mWasMovingCanvasInGesture = true
|
mWasMovingCanvasInGesture = true
|
||||||
@ -169,6 +170,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
|
|
||||||
mLastTouchX = x
|
mLastTouchX = x
|
||||||
mLastTouchY = y
|
mLastTouchY = y
|
||||||
|
mIgnoreMultitouchChanges = false
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
mActivePointerId = INVALID_POINTER_ID
|
mActivePointerId = INVALID_POINTER_ID
|
||||||
@ -179,12 +181,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||||
if (mAllowMovingZooming) {
|
if (mAllowMovingZooming) {
|
||||||
mWasMultitouch = true
|
mWasMultitouch = true
|
||||||
|
mIgnoreMultitouchChanges = true
|
||||||
mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY)
|
mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_POINTER_UP -> {
|
MotionEvent.ACTION_POINTER_UP -> {
|
||||||
if (mAllowMovingZooming) {
|
if (mAllowMovingZooming) {
|
||||||
mIgnoreTouches = true
|
mIgnoreTouches = true
|
||||||
|
mIgnoreMultitouchChanges = true
|
||||||
actionUp(!mWasScalingInGesture && !mWasMovingCanvasInGesture)
|
actionUp(!mWasScalingInGesture && !mWasMovingCanvasInGesture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user