From df2aae04986a386d625ef8d39c833718723e3750 Mon Sep 17 00:00:00 2001 From: Neo Kim Date: Mon, 18 Jan 2016 19:16:35 +0900 Subject: [PATCH] Add a setter for touch total time threshold in ScrollView --- cocos/ui/UIScrollView.cpp | 13 ++++++++++++- cocos/ui/UIScrollView.h | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 3cc24b17ce..0d3488a217 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -59,6 +59,7 @@ _rightBoundary(0.0f), _bePressed(false), _childFocusCancelOffsetInInch(MOVE_INCH), _touchMovePreviousTimestamp(0), +_touchTotalTimeThreshold(0.5f), _autoScrolling(false), _autoScrollAttenuate(true), _autoScrollTotalTime(0), @@ -328,7 +329,7 @@ Vec2 ScrollView::calculateTouchMoveVelocity() const { totalTime += timeDelta; } - if(totalTime == 0 || totalTime >= 0.5f) + if(totalTime == 0 || totalTime >= _touchTotalTimeThreshold) { return Vec2::ZERO; } @@ -1303,6 +1304,16 @@ float ScrollView::getScrollBarAutoHideTime() const } return 0; } + +void ScrollView::setTouchTotalTimeThreshold(float touchTotalTimeThreshold) +{ + _touchTotalTimeThreshold = touchTotalTimeThreshold; +} + +float ScrollView::getTouchTotalTimeThreshold() const +{ + return _touchTotalTimeThreshold; +} Layout* ScrollView::getInnerContainer()const { diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 0fe4c75acb..2858f36fa3 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -505,6 +505,20 @@ public: */ float getScrollBarAutoHideTime() const; + /** + * @brief Set the touch total time threshold + * + * @param the touch total time threshold + */ + void setTouchTotalTimeThreshold(float touchTotalTimeThreshold); + + /** + * @brief Get the touch total time threshold + * + * @return the touch total time threshold + */ + float getTouchTotalTimeThreshold() const; + /** * Set layout type for scrollview. * @@ -620,6 +634,7 @@ protected: std::list _touchMoveDisplacements; std::list _touchMoveTimeDeltas; long long _touchMovePreviousTimestamp; + float _touchTotalTimeThreshold; bool _autoScrolling; bool _autoScrollAttenuate;