Merge pull request #11445 from andyque/improve-the-arguments

make scrollview time arguments more meaningful
This commit is contained in:
minggo 2015-04-16 10:14:11 +08:00
commit 29de9d397f
2 changed files with 128 additions and 128 deletions

View File

@ -502,7 +502,7 @@ void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Vec2& dir, float
_autoScrollAcceleration = acceleration;
}
void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float time, bool attenuated)
void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float second, bool attenuated)
{
_needCheckAutoScrollDestination = false;
_autoScrollDestination = des;
@ -512,13 +512,13 @@ void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float t
float acceleration = -1000.0f;
if (attenuated)
{
acceleration = (-(2 * dis.getLength())) / (time * time);
orSpeed = 2 * dis.getLength() / time;
acceleration = (-(2 * dis.getLength())) / (second * second);
orSpeed = 2 * dis.getLength() / second;
}
else
{
_needCheckAutoScrollDestination = true;
orSpeed = dis.getLength() / time;
orSpeed = dis.getLength() / second;
}
startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration);
}
@ -1224,39 +1224,39 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
return scrollenabled;
}
void ScrollView::scrollToBottom(float time, bool attenuated)
void ScrollView::scrollToBottom(float second, bool attenuated)
{
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, 0.0f), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, 0.0f), second, attenuated);
}
void ScrollView::scrollToTop(float time, bool attenuated)
void ScrollView::scrollToTop(float second, bool attenuated)
{
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x,
_contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
_contentSize.height - _innerContainer->getContentSize().height), second, attenuated);
}
void ScrollView::scrollToLeft(float time, bool attenuated)
void ScrollView::scrollToLeft(float second, bool attenuated)
{
startAutoScrollChildrenWithDestination(Vec2(0.0f, _innerContainer->getPosition().y), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(0.0f, _innerContainer->getPosition().y), second, attenuated);
}
void ScrollView::scrollToRight(float time, bool attenuated)
void ScrollView::scrollToRight(float second, bool attenuated)
{
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
_innerContainer->getPosition().y), time, attenuated);
_innerContainer->getPosition().y), second, attenuated);
}
void ScrollView::scrollToTopLeft(float time, bool attenuated)
void ScrollView::scrollToTopLeft(float second, bool attenuated)
{
if (_direction != Direction::BOTH)
{
CCLOG("Scroll diretion is not both!");
return;
}
startAutoScrollChildrenWithDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height), second, attenuated);
}
void ScrollView::scrollToTopRight(float time, bool attenuated)
void ScrollView::scrollToTopRight(float second, bool attenuated)
{
if (_direction != Direction::BOTH)
{
@ -1264,43 +1264,43 @@ void ScrollView::scrollToTopRight(float time, bool attenuated)
return;
}
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
_contentSize.height - _innerContainer->getContentSize().height), time, attenuated);
_contentSize.height - _innerContainer->getContentSize().height), second, attenuated);
}
void ScrollView::scrollToBottomLeft(float time, bool attenuated)
void ScrollView::scrollToBottomLeft(float second, bool attenuated)
{
if (_direction != Direction::BOTH)
{
CCLOG("Scroll diretion is not both!");
return;
}
startAutoScrollChildrenWithDestination(Vec2::ZERO, time, attenuated);
startAutoScrollChildrenWithDestination(Vec2::ZERO, second, attenuated);
}
void ScrollView::scrollToBottomRight(float time, bool attenuated)
void ScrollView::scrollToBottomRight(float second, bool attenuated)
{
if (_direction != Direction::BOTH)
{
CCLOG("Scroll diretion is not both!");
return;
}
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f), second, attenuated);
}
void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated)
void ScrollView::scrollToPercentVertical(float percent, float second, bool attenuated)
{
float minY = _contentSize.height - _innerContainer->getContentSize().height;
float h = - minY;
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), second, attenuated);
}
void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated)
void ScrollView::scrollToPercentHorizontal(float percent, float second, bool attenuated)
{
float w = _innerContainer->getContentSize().width - _contentSize.width;
startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), second, attenuated);
}
void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float time, bool attenuated)
void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float second, bool attenuated)
{
if (_direction != Direction::BOTH)
{
@ -1309,7 +1309,7 @@ void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float time, b
float minY = _contentSize.height - _innerContainer->getContentSize().height;
float h = - minY;
float w = _innerContainer->getContentSize().width - _contentSize.width;
startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated);
startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), second, attenuated);
}
void ScrollView::jumpToBottom()

View File

@ -152,56 +152,56 @@ public:
/**
* Scroll inner container to bottom boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToBottom(float time, bool attenuated);
void scrollToBottom(float second, bool attenuated);
/**
* Scroll inner container to top boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToTop(float time, bool attenuated);
void scrollToTop(float second, bool attenuated);
/**
* Scroll inner container to left boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToLeft(float time, bool attenuated);
void scrollToLeft(float second, bool attenuated);
/**
* Scroll inner container to right boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToRight(float time, bool attenuated);
/**
* Scroll inner container to top and left boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToTopLeft(float time, bool attenuated);
void scrollToTopLeft(float second, bool attenuated);
/**
* Scroll inner container to top and right boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToTopRight(float time, bool attenuated);
/**
* Scroll inner container to bottom and left boundary of scrollview.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToBottomLeft(float time, bool attenuated);
void scrollToBottomLeft(float second, bool attenuated);
/**
* Scroll inner container to bottom and right boundary of scrollview.
* @param time Time in seconds
* @param second Time in seconds
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToBottomRight(float time, bool attenuated);
@ -209,26 +209,26 @@ public:
/**
* Scroll inner container to vertical percent position of scrollview.
* @param percent A value between 0 and 100.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToPercentVertical(float percent, float time, bool attenuated);
void scrollToPercentVertical(float percent, float second, bool attenuated);
/**
* Scroll inner container to horizontal percent position of scrollview.
* @param percent A value between 0 and 100.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToPercentHorizontal(float percent, float time, bool attenuated);
void scrollToPercentHorizontal(float percent, float second, bool attenuated);
/**
* Scroll inner container to both direction percent position of scrollview.
* @param percent A value between 0 and 100.
* @param time Time in seconds.
* @param second Time in seconds.
* @param attenuated Whether scroll speed attenuate or not.
*/
void scrollToPercentBothDirection(const Vec2& percent, float time, bool attenuated);
void scrollToPercentBothDirection(const Vec2& percent, float second, bool attenuated);
/**
* Move inner container to bottom boundary of scrollview.
@ -424,7 +424,7 @@ protected:
void checkBounceBoundary();
bool checkNeedBounce();
void startAutoScrollChildrenWithOriginalSpeed(const Vec2& dir, float v, bool attenuated, float acceleration);
void startAutoScrollChildrenWithDestination(const Vec2& des, float time, bool attenuated);
void startAutoScrollChildrenWithDestination(const Vec2& des, float second, bool attenuated);
void jumpToDestination(const Vec2& des);
void stopAutoScrollChildren();
void startBounceChildren(float v);