MCPcopy Create free account
hub / github.com/axmolengine/axmol / onTouchMoved

Method onTouchMoved

extensions/GUI/src/GUI/ScrollView/ScrollView.cpp:742–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742void ScrollView::onTouchMoved(Touch* touch, Event* /*event*/)
743{
744 if (!this->isVisible())
745 {
746 return;
747 }
748
749 if (std::find(_touches.begin(), _touches.end(), touch) != _touches.end())
750 {
751 if (_touches.size() == 1 && _dragging)
752 { // scrolling
753 Vec2 moveDistance, newPoint;
754 Rect frame;
755 float newX, newY;
756
757 frame = getViewRect();
758
759 newPoint = this->convertTouchToNodeSpace(_touches[0]);
760 moveDistance = newPoint - _touchPoint;
761
762 float dis = 0.0f;
763 if (_direction == Direction::VERTICAL)
764 {
765 dis = moveDistance.y;
766 float pos = _container->getPosition().y;
767 if (!(minContainerOffset().y <= pos && pos <= maxContainerOffset().y))
768 {
769 moveDistance.y *= BOUNCE_BACK_FACTOR;
770 }
771 }
772 else if (_direction == Direction::HORIZONTAL)
773 {
774 dis = moveDistance.x;
775 float pos = _container->getPosition().x;
776 if (!(minContainerOffset().x <= pos && pos <= maxContainerOffset().x))
777 {
778 moveDistance.x *= BOUNCE_BACK_FACTOR;
779 }
780 }
781 else
782 {
783 dis = sqrtf(moveDistance.x * moveDistance.x + moveDistance.y * moveDistance.y);
784
785 float pos = _container->getPosition().y;
786 if (!(minContainerOffset().y <= pos && pos <= maxContainerOffset().y))
787 {
788 moveDistance.y *= BOUNCE_BACK_FACTOR;
789 }
790
791 pos = _container->getPosition().x;
792 if (!(minContainerOffset().x <= pos && pos <= maxContainerOffset().x))
793 {
794 moveDistance.x *= BOUNCE_BACK_FACTOR;
795 }
796 }
797
798 if (!_touchMoved && fabs(convertDistanceFromPointToInch(dis)) < MOVE_INCH)
799 {

Callers

nothing calls this directly

Calls 15

setContentOffsetMethod · 0.95
setZoomScaleMethod · 0.95
getZoomScaleMethod · 0.95
fabsFunction · 0.85
findFunction · 0.50
Vec2Function · 0.50
isVisibleMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected