void UIListView::drag(float offset) { if (m_children->count() <= 0) { return; } scrollChildren(offset); }
void ScrollView::handleMoveLogic(Touch *touch) { Vec2 touchPositionInNodeSpace = this->convertToNodeSpace(touch->getLocation()); Vec2 previousTouchPositionInNodeSpace = this->convertToNodeSpace(touch->getPreviousLocation()); Vec2 delta = touchPositionInNodeSpace - previousTouchPositionInNodeSpace; scrollChildren(delta); // Gather touch move information for speed calculation gatherTouchMove(delta); }
void ScrollView::handleMoveLogic(Touch *touch) { Vec3 currPt, prevPt; if(!calculateCurrAndPrevTouchPoints(touch, &currPt, &prevPt)) { return; } Vec3 delta3 = currPt - prevPt; Vec2 delta(delta3.x, delta3.y); scrollChildren(delta); // Gather touch move information for speed calculation gatherTouchMove(delta); }
void UIListView::handleMoveLogic(const Point &touchPoint) { Point nsp = _renderer->convertToNodeSpace(touchPoint); float offset = 0.0f; switch (_direction) { case LISTVIEW_DIR_VERTICAL: // vertical { float moveY = nsp.y; offset = moveY - _touchMoveStartLocation; _touchMoveStartLocation = moveY; if (offset < 0.0f) { _moveDirection = LISTVIEW_MOVE_DIR_DOWN; // down } else if (offset > 0.0f) { _moveDirection = LISTVIEW_MOVE_DIR_UP; // up } } break; case LISTVIEW_DIR_HORIZONTAL: // horizontal { float moveX = nsp.x; offset = moveX - _touchMoveStartLocation; _touchMoveStartLocation = moveX; if (offset < 0) { _moveDirection = LISTVIEW_MOVE_DIR_LEFT; // left } else if (offset > 0) { _moveDirection = LISTVIEW_MOVE_DIR_RIGHT; // right } } break; default: break; } scrollChildren(offset); }
void UIScrollViewP::handleMoveLogic(const CCPoint &touchPoint) { CCPoint nsp = m_pRenderer->convertToNodeSpace(touchPoint); float offset = 0.0f; switch (m_eDirection) { case SCROLLVIEW_DIR_VERTICAL: // vertical { float moveY = nsp.y; offset = moveY - m_fTouchMoveStartLocation; m_fTouchMoveStartLocation = moveY; if (offset < 0.0f) { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_DOWN; // down } else if (offset > 0.0f) { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_UP; // up } } break; case SCROLLVIEW_DIR_HORIZONTAL: // horizontal { float moveX = nsp.x; offset = moveX - m_fTouchMoveStartLocation; m_fTouchMoveStartLocation = moveX; if (offset < 0) { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_LEFT; // left } else if (offset > 0) { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_RIGHT; // right } } break; default: break; } scrollChildren(offset); }
void ScrollView::handleMoveLogic(Touch *touch) { Vec3 currPt, prevPt; if (nullptr == _hittedByCamera || false == hitTest(touch->getLocation(), _hittedByCamera, &currPt) || false == hitTest(touch->getPreviousLocation(), _hittedByCamera, &prevPt)) { return; } Vec3 delta3 = currPt - prevPt; Vec2 delta(delta3.x, delta3.y); scrollChildren(delta.x, delta.y); while(_inertiaTouchDisplacements.size() > 5) { _inertiaTouchDisplacements.pop_front(); _inertiaTouchTimeDeltas.pop_front(); } _inertiaTouchDisplacements.push_back(delta); long long timestamp = utils::getTimeInMilliseconds(); _inertiaTouchTimeDeltas.push_back((timestamp - _inertiaPrevTouchTimestamp) / 1000.0f); _inertiaPrevTouchTimestamp = timestamp; }
void UIListView::autoScrollChildren(float dt) { switch (_direction) { case LISTVIEW_DIR_VERTICAL: // vertical switch (_moveDirection) { case LISTVIEW_MOVE_DIR_UP: // up { float curDis = getCurAutoScrollDistance(dt); if (curDis <= 0) { curDis = 0; stopAutoScrollChildren(); } if (!scrollChildren(curDis)) { stopAutoScrollChildren(); } } break; case LISTVIEW_MOVE_DIR_DOWN: // down { float curDis = getCurAutoScrollDistance(dt); if (curDis <= 0) { curDis = 0; stopAutoScrollChildren(); } if (!scrollChildren(-curDis)) { stopAutoScrollChildren(); } } break; default: break; } break; case LISTVIEW_DIR_HORIZONTAL: // horizontal switch (_moveDirection) { case LISTVIEW_MOVE_DIR_LEFT: // left { float curDis = getCurAutoScrollDistance(dt); if (curDis <= 0) { curDis = 0; stopAutoScrollChildren(); } if (!scrollChildren(-curDis)) { stopAutoScrollChildren(); } } break; case LISTVIEW_MOVE_DIR_RIGHT: // right { float curDis = getCurAutoScrollDistance(dt); if (curDis <= 0) { curDis = 0; stopAutoScrollChildren(); } if (!scrollChildren(curDis)) { stopAutoScrollChildren(); } } break; default: break; } break; default: break; } }
void QWidgetPrivate::scroll_sys(int dx, int dy) { Q_Q(QWidget); scrollChildren(dx, dy); scrollRect(q->rect(), dx, dy); }
void UIScrollViewP::scrollToTop() { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_DOWN; // down scrollChildren(-m_pInnerContainer->getSize().height); }
void UIScrollViewP::scrollToBottom() { m_eMoveDirection = SCROLLVIEW_MOVE_DIR_UP; // up scrollChildren(m_pInnerContainer->getSize().height); }