mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Revert previous change
This commit is contained in:
@@ -21,10 +21,10 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
public abstract boolean panStop(float x, float y);
|
public abstract boolean panStop(float x, float y);
|
||||||
public abstract boolean zoom(float x, float y, float amount);
|
public abstract boolean zoom(float x, float y, float amount);
|
||||||
|
|
||||||
private float tapSquareSize, longPressDelay, lastTapX, lastTapY, lastTwoFingerTapX, lastTwoFingerTapY, tapSquareCenterX, tapSquareCenterY;
|
private float tapSquareSize, longPressDelay, lastTapX, lastTapY, tapSquareCenterX, tapSquareCenterY;
|
||||||
private long tapCountInterval, flingDelay, lastTapTime, gestureStartTime, lastTwoFingerTapTime;
|
private long tapCountInterval, flingDelay, lastTapTime, gestureStartTime;
|
||||||
private int tapCount, lastTapButton, lastTapPointer, twoFingerTapCount, lastTwoFingerTapButton;
|
private int tapCount, lastTapButton, lastTapPointer;
|
||||||
private boolean inTapSquare, pressed, longPressed, longPressHandled, pinching, panning, inTwoFingerTapSquare;
|
private boolean inTapSquare, pressed, longPressed, longPressHandled, pinching, panning;
|
||||||
|
|
||||||
private final VelocityTracker tracker = new VelocityTracker();
|
private final VelocityTracker tracker = new VelocityTracker();
|
||||||
private final Vector2 pointer1 = new Vector2();
|
private final Vector2 pointer1 = new Vector2();
|
||||||
@@ -83,10 +83,16 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
gestureStartTime = Gdx.input.getCurrentEventTime();
|
gestureStartTime = Gdx.input.getCurrentEventTime();
|
||||||
tracker.start(x, y, gestureStartTime);
|
tracker.start(x, y, gestureStartTime);
|
||||||
if (Gdx.input.isTouched(1)) {
|
if (Gdx.input.isTouched(1)) {
|
||||||
startPinch();
|
// Start pinch.
|
||||||
|
inTapSquare = false;
|
||||||
|
pinching = true;
|
||||||
|
prevPointer1.set(pointer1);
|
||||||
|
prevPointer2.set(pointer2);
|
||||||
|
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
|
||||||
endPress(x, y);
|
endPress(x, y);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Normal touch down.
|
||||||
inTapSquare = true;
|
inTapSquare = true;
|
||||||
pinching = false;
|
pinching = false;
|
||||||
tapSquareCenterX = x;
|
tapSquareCenterX = x;
|
||||||
@@ -95,8 +101,13 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Start pinch.
|
||||||
pointer2.set(x, y);
|
pointer2.set(x, y);
|
||||||
startPinch();
|
inTapSquare = false;
|
||||||
|
pinching = true;
|
||||||
|
prevPointer1.set(pointer1);
|
||||||
|
prevPointer2.set(pointer2);
|
||||||
|
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
|
||||||
endPress(pointer1.x, pointer1.y);
|
endPress(pointer1.x, pointer1.y);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -118,15 +129,8 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
pointer2.set(x, y);
|
pointer2.set(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle pinch zoom if not two finger tapping
|
// handle pinch zoom
|
||||||
if (pinching) {
|
if (pinching) {
|
||||||
if (inTwoFingerTapSquare) {
|
|
||||||
Vector2 p = pointer == 0 ? pointer1 : pointer2;
|
|
||||||
if (isWithinTapSquare(x, y, p.x, p.y)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
inTwoFingerTapSquare = false;
|
|
||||||
}
|
|
||||||
return zoom(focalPoint.x, focalPoint.y, pointer1.dst(pointer2) - prevPointer1.dst(prevPointer2));
|
return zoom(focalPoint.x, focalPoint.y, pointer1.dst(pointer2) - prevPointer1.dst(prevPointer2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +165,7 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we are still tapping
|
// check if we are still tapping.
|
||||||
if (inTapSquare && !isWithinTapSquare(x, y, tapSquareCenterX, tapSquareCenterY)) {
|
if (inTapSquare && !isWithinTapSquare(x, y, tapSquareCenterX, tapSquareCenterY)) {
|
||||||
inTapSquare = false;
|
inTapSquare = false;
|
||||||
}
|
}
|
||||||
@@ -195,34 +199,6 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inTwoFingerTapSquare) {
|
|
||||||
Vector2 p = pointer == 0 ? pointer1 : pointer2;
|
|
||||||
if (isWithinTapSquare(x, y, p.x, p.y)) {
|
|
||||||
if (!pinching) { //don't raise two finger tap until both fingers up
|
|
||||||
x = focalPoint.x;
|
|
||||||
y = focalPoint.y;
|
|
||||||
long time = Gdx.input.getCurrentEventTime();
|
|
||||||
if (twoFingerTapCount == 2 //treat 3rd tap as a first tap, and 4th as a double tap
|
|
||||||
|| lastTwoFingerTapButton != button
|
|
||||||
|| time - lastTwoFingerTapTime > tapCountInterval
|
|
||||||
|| !isWithinTapSquare(x, y, lastTwoFingerTapX, lastTwoFingerTapY)) {
|
|
||||||
twoFingerTapCount = 0;
|
|
||||||
}
|
|
||||||
twoFingerTapCount++;
|
|
||||||
lastTwoFingerTapTime = time;
|
|
||||||
lastTwoFingerTapX = x;
|
|
||||||
lastTwoFingerTapY = y;
|
|
||||||
lastTwoFingerTapButton = button;
|
|
||||||
gestureStartTime = 0;
|
|
||||||
inTwoFingerTapSquare = false;
|
|
||||||
return twoFingerTap(x, y, twoFingerTapCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inTwoFingerTapSquare = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pinching) {
|
if (pinching) {
|
||||||
// handle pinch end
|
// handle pinch end
|
||||||
pinching = false;
|
pinching = false;
|
||||||
@@ -280,17 +256,6 @@ public abstract class FGestureAdapter extends InputAdapter {
|
|||||||
return Math.abs(x - centerX) < tapSquareSize && Math.abs(y - centerY) < tapSquareSize;
|
return Math.abs(x - centerX) < tapSquareSize && Math.abs(y - centerY) < tapSquareSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startPinch() {
|
|
||||||
if (inTapSquare && pointer2.dst(pointer1) < Utils.AVG_FINGER_WIDTH * 3) {
|
|
||||||
inTwoFingerTapSquare = true;
|
|
||||||
}
|
|
||||||
inTapSquare = false;
|
|
||||||
pinching = true;
|
|
||||||
prevPointer1.set(pointer1);
|
|
||||||
prevPointer2.set(pointer2);
|
|
||||||
focalPoint.set(Utils.getMidpoint(pointer1, pointer2));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class VelocityTracker {
|
private static class VelocityTracker {
|
||||||
int sampleSize = 10;
|
int sampleSize = 10;
|
||||||
float startX, startY;
|
float startX, startY;
|
||||||
|
|||||||
Reference in New Issue
Block a user