void PageView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint) { switch (handleState) { case 0: handlePressLogic(touchPoint); break; case 1: { float offset = 0; offset = fabs(sender->getTouchStartPos().x - touchPoint.x); if (offset > _childFocusCancelOffset) { sender->setFocused(false); handleMoveLogic(touchPoint); } } break; case 2: handleReleaseLogic(touchPoint); break; case 3: handleReleaseLogic(touchPoint); break; } }
void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sender,Touch* touch) { if(!_touchEnabled) { Layout::interceptTouchEvent(event, sender, touch); return; } if(_direction == Direction::NONE) return; Vec2 touchPoint = touch->getLocation(); switch (event) { case TouchEventType::BEGAN: { _isInterceptTouch = true; _touchBeganPosition = touch->getLocation(); handlePressLogic(touch); } break; case TouchEventType::MOVED: { _touchMovePosition = touch->getLocation(); // calculates move offset in points float offsetInInch = 0; switch (_direction) { case Direction::HORIZONTAL: offsetInInch = convertDistanceFromPointToInch(Vec2(fabs(sender->getTouchBeganPosition().x - touchPoint.x), 0)); break; case Direction::VERTICAL: offsetInInch = convertDistanceFromPointToInch(Vec2(0, fabs(sender->getTouchBeganPosition().y - touchPoint.y))); break; case Direction::BOTH: offsetInInch = convertDistanceFromPointToInch(sender->getTouchBeganPosition() - touchPoint); break; default: break; } if (offsetInInch > _childFocusCancelOffsetInInch) { sender->setHighlighted(false); handleMoveLogic(touch); } } break; case TouchEventType::CANCELED: case TouchEventType::ENDED: { _touchEndPosition = touch->getLocation(); handleReleaseLogic(touch); if (sender->isSwallowTouches()) { _isInterceptTouch = false; } } break; } }
void UIDragPanel::interceptTouchEvent(int handleState, UIWidget *sender, const CCPoint &touchPoint) { switch (handleState) { case 0: handlePressLogic(touchPoint); break; case 1: { float offset = ccpDistance(sender->getTouchStartPos(), touchPoint); if (offset > 5.0) { sender->setFocused(false); handleMoveLogic(touchPoint); } } break; case 2: handleReleaseLogic(touchPoint); break; case 3: break; } }
void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch *touch) { Vec2 touchPoint = touch->getLocation(); switch (event) { case TouchEventType::BEGAN: handlePressLogic(touch); break; case TouchEventType::MOVED: { float offset = 0; offset = fabs(sender->getTouchBeganPosition().x - touchPoint.x); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); handleMoveLogic(touch); } } break; case TouchEventType::CANCELED: case TouchEventType::ENDED: handleReleaseLogic(touch); break; } }
void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); if (!_isInterceptTouch) { handleReleaseLogic(touch); } _isInterceptTouch = false; }
void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); if (!_isInterceptTouch) { handleReleaseLogic(touch); } _isInterceptTouch = false; }
void UIListView::interceptTouchEvent(int handleState, UIWidget *sender, const Point &touchPoint) { switch (handleState) { case 0: handlePressLogic(touchPoint); break; case 1: { float offset = 0; switch (_direction) { case LISTVIEW_DIR_VERTICAL: // vertical offset = fabs(sender->getTouchStartPos().y - touchPoint.y); break; case LISTVIEW_DIR_HORIZONTAL: // horizontal offset = fabs(sender->getTouchStartPos().x - touchPoint.x); break; default: break; } if (offset > _childFocusCancelOffset) { sender->setFocused(false); handleMoveLogic(touchPoint); } } break; case 2: handleReleaseLogic(touchPoint); break; case 3: break; } }
void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, const Vec2 &touchPoint) { switch (event) { case TouchEventType::BEGAN: handlePressLogic(touchPoint); break; case TouchEventType::MOVED: { float offset = 0; offset = fabs(sender->getTouchStartPos().x - touchPoint.x); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); handleMoveLogic(touchPoint); } } break; case TouchEventType::CANCELED: case TouchEventType::ENDED: handleReleaseLogic(touchPoint); break; } }
void UIListView::onTouchEnded(const Point &touchPoint) { Layout::onTouchEnded(touchPoint); handleReleaseLogic(touchPoint); }
void UIDragPanel::onTouchEnded(const CCPoint &touchPoint) { Layout::onTouchEnded(touchPoint); handleReleaseLogic(touchPoint); }
void PageView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); handleReleaseLogic(touch); }
void UIScrollViewP::onTouchEnded(const CCPoint &touchPoint) { Layout::onTouchEnded(touchPoint); handleReleaseLogic(touchPoint); }
void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); handleReleaseLogic(_touchEndPos); }
void UIPageView::onTouchEnded(const CCPoint &touchPoint) { Layout::onTouchEnded(touchPoint); handleReleaseLogic(touchPoint); }