diff options
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r-- | src/ui/touch.c | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index 36bac267..dac1152e 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -65,6 +65,7 @@ struct Impl_Touch { | |||
65 | iBool isLeftDown; | 65 | iBool isLeftDown; |
66 | iBool isTouchDrag; | 66 | iBool isTouchDrag; |
67 | iBool isTapAndHold; | 67 | iBool isTapAndHold; |
68 | iBool didPostEdgeMove; | ||
68 | iBool didBeginOnTouchDrag; | 69 | iBool didBeginOnTouchDrag; |
69 | int pinchId; | 70 | int pinchId; |
70 | enum iTouchEdge edge; | 71 | enum iTouchEdge edge; |
@@ -391,6 +392,12 @@ static void checkNewPinch_TouchState_(iTouchState *d, iTouch *newTouch) { | |||
391 | pinch.touchIds[1] = other->id; | 392 | pinch.touchIds[1] = other->id; |
392 | newTouch->pinchId = other->pinchId = pinch.id; | 393 | newTouch->pinchId = other->pinchId = pinch.id; |
393 | clearWidgetMomentum_TouchState_(d, affinity); | 394 | clearWidgetMomentum_TouchState_(d, affinity); |
395 | if (other->edge && other->didPostEdgeMove) { | ||
396 | postCommandf_App("edgeswipe.ended abort:1 side:%d id:%llu", other->edge, other->id); | ||
397 | other->didPostEdgeMove = iFalse; | ||
398 | } | ||
399 | other->edge = none_TouchEdge; | ||
400 | newTouch->edge = none_TouchEdge; | ||
394 | /* Remember current positions to determine pinch amount. */ | 401 | /* Remember current positions to determine pinch amount. */ |
395 | newTouch->startPos = newTouch->pos[0]; | 402 | newTouch->startPos = newTouch->pos[0]; |
396 | other->startPos = other->pos[0]; | 403 | other->startPos = other->pos[0]; |
@@ -476,7 +483,6 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
476 | } | 483 | } |
477 | else if (x > rootSize.x - edgeWidth) { | 484 | else if (x > rootSize.x - edgeWidth) { |
478 | edge = right_TouchEdge; | 485 | edge = right_TouchEdge; |
479 | // puts("DOWN on right edge"); | ||
480 | } | 486 | } |
481 | iWidget *aff = hitChild_Window(window, init_I2(iRound(x), iRound(y_F3(pos)))); | 487 | iWidget *aff = hitChild_Window(window, init_I2(iRound(x), iRound(y_F3(pos)))); |
482 | #if 0 | 488 | #if 0 |
@@ -523,6 +529,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
523 | (int) (x_F3(pos) - x_F3(touch->startPos)), | 529 | (int) (x_F3(pos) - x_F3(touch->startPos)), |
524 | touch->edge, | 530 | touch->edge, |
525 | touch->id); | 531 | touch->id); |
532 | touch->didPostEdgeMove = iTrue; | ||
526 | return iTrue; | 533 | return iTrue; |
527 | } | 534 | } |
528 | if (touch && touch->affinity) { | 535 | if (touch && touch->affinity) { |
@@ -595,39 +602,6 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
595 | } | 602 | } |
596 | } | 603 | } |
597 | iAssert(touch->edge == none_TouchEdge); | 604 | iAssert(touch->edge == none_TouchEdge); |
598 | #if 0 | ||
599 | /* Edge swipe aborted? */ | ||
600 | if (touch->edge == left_TouchEdge) { | ||
601 | if (fing->dx < 0 && x_F3(touch->pos[0]) < tapRadiusPt_ * window->pixelRatio) { | ||
602 | touch->edge = none_TouchEdge; | ||
603 | if (touch->edgeDragging) { | ||
604 | setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse); | ||
605 | setVisualOffset_Widget(touch->edgeDragging, 0, 200, easeOut_AnimFlag); | ||
606 | touch->edgeDragging = NULL; | ||
607 | } | ||
608 | } | ||
609 | else if (touch->edgeDragging) { | ||
610 | setVisualOffset_Widget(touch->edgeDragging, x_F3(pos) - x_F3(touch->startPos), 10, 0); | ||
611 | } | ||
612 | } | ||
613 | if (touch->edge == right_TouchEdge) { | ||
614 | if (fing->dx > 0 && x_F3(touch->pos[0]) > window->size.x - tapRadiusPt_ * window->pixelRatio) { | ||
615 | puts("touch->edge==right returned to right edge, aborted"); | ||
616 | touch->edge = none_TouchEdge; | ||
617 | if (touch->edgeDragging) { | ||
618 | setFlags_Widget(touch->edgeDragging, dragged_WidgetFlag, iFalse); | ||
619 | setVisualOffset_Widget(touch->edgeDragging, 0, 200, easeOut_AnimFlag); | ||
620 | touch->edgeDragging = NULL; | ||
621 | } | ||
622 | } | ||
623 | else if (touch->edgeDragging) { | ||
624 | setVisualOffset_Widget(touch->edgeDragging, x_F3(pos) - x_F3(touch->startPos), 10, 0); | ||
625 | } | ||
626 | } | ||
627 | if (touch->edge) { | ||
628 | pixels.y = 0; | ||
629 | } | ||
630 | #endif | ||
631 | if (touch->axis == x_TouchAxis) { | 605 | if (touch->axis == x_TouchAxis) { |
632 | pixels.y = 0; | 606 | pixels.y = 0; |
633 | } | 607 | } |
@@ -671,7 +645,12 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
671 | } | 645 | } |
672 | #endif | 646 | #endif |
673 | if (touch->edge && !isStationary_Touch_(touch)) { | 647 | if (touch->edge && !isStationary_Touch_(touch)) { |
674 | postCommandf_App("edgeswipe.ended side:%d id:%llu", touch->edge, touch->id); | 648 | const iFloat3 gesture = gestureVector_Touch_(touch); |
649 | const float pixel = window->pixelRatio; | ||
650 | const int moveDir = x_F3(gesture) < -pixel ? -1 : x_F3(gesture) > pixel ? +1 : 0; | ||
651 | const int didAbort = (touch->edge == left_TouchEdge && moveDir < 0) || | ||
652 | (touch->edge == right_TouchEdge && moveDir > 0); | ||
653 | postCommandf_App("edgeswipe.ended abort:%d side:%d id:%llu", didAbort, touch->edge, touch->id); | ||
675 | remove_ArrayIterator(&i); | 654 | remove_ArrayIterator(&i); |
676 | continue; | 655 | continue; |
677 | } | 656 | } |