| 699 | } |
| 700 | |
| 701 | bool ScrollView::onTouchBegan(Touch* touch, Event* /*event*/) |
| 702 | { |
| 703 | if (!this->isVisible() || !this->hasVisibleParents()) |
| 704 | { |
| 705 | return false; |
| 706 | } |
| 707 | |
| 708 | Rect frame = getViewRect(); |
| 709 | |
| 710 | // dispatcher does not know about clipping. reject touches outside visible bounds. |
| 711 | if (_touches.size() > 2 || _touchMoved || !frame.containsPoint(touch->getLocation())) |
| 712 | { |
| 713 | return false; |
| 714 | } |
| 715 | |
| 716 | if (std::find(_touches.begin(), _touches.end(), touch) == _touches.end()) |
| 717 | { |
| 718 | _touches.emplace_back(touch); |
| 719 | } |
| 720 | |
| 721 | if (_touches.size() == 1) |
| 722 | { // scrolling |
| 723 | _touchPoint = this->convertTouchToNodeSpace(touch); |
| 724 | _touchMoved = false; |
| 725 | _dragging = true; // dragging started |
| 726 | _scrollDistance.setZero(); |
| 727 | _touchLength = 0.0f; |
| 728 | } |
| 729 | else if (_touches.size() == 2) |
| 730 | { |
| 731 | _touchPoint = |
| 732 | (this->convertTouchToNodeSpace(_touches[0]).getMidpoint(this->convertTouchToNodeSpace(_touches[1]))); |
| 733 | |
| 734 | _touchLength = _container->convertTouchToNodeSpace(_touches[0]) |
| 735 | .getDistance(_container->convertTouchToNodeSpace(_touches[1])); |
| 736 | |
| 737 | _dragging = false; |
| 738 | } |
| 739 | return true; |
| 740 | } |
| 741 | |
| 742 | void ScrollView::onTouchMoved(Touch* touch, Event* /*event*/) |
| 743 | { |
nothing calls this directly
no test coverage detected