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

Method onTouchBegan

extensions/GUI/src/GUI/ScrollView/ScrollView.cpp:701–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701bool 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
742void ScrollView::onTouchMoved(Touch* touch, Event* /*event*/)
743{

Callers

nothing calls this directly

Calls 13

hasVisibleParentsMethod · 0.95
getMidpointMethod · 0.80
findFunction · 0.50
isVisibleMethod · 0.45
sizeMethod · 0.45
containsPointMethod · 0.45
getLocationMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
setZeroMethod · 0.45

Tested by

no test coverage detected