2014-03-11 17:13:54 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "ui/UIScrollView.h"
|
2015-06-25 16:57:00 +08:00
|
|
|
#include "base/CCDirector.h"
|
2015-06-29 11:52:53 +08:00
|
|
|
#include "base/ccUtils.h"
|
2015-06-29 12:05:52 +08:00
|
|
|
#include "platform/CCDevice.h"
|
2015-07-01 11:41:47 +08:00
|
|
|
#include "ui/UIScrollViewBar.h"
|
2015-06-29 12:05:52 +08:00
|
|
|
#include "2d/CCTweenFunction.h"
|
2015-06-18 10:23:52 +08:00
|
|
|
#include "2d/CCCamera.h"
|
2014-03-11 17:13:54 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2015-09-04 11:46:01 +08:00
|
|
|
static const int NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED = 5;
|
2015-09-04 16:28:38 +08:00
|
|
|
static const float OUT_OF_BOUNDARY_BREAKING_FACTOR = 0.05f;
|
2015-07-01 11:41:47 +08:00
|
|
|
static const float BOUNCE_BACK_DURATION = 1.0f;
|
2015-08-31 13:17:48 +08:00
|
|
|
|
2015-06-25 16:57:00 +08:00
|
|
|
#define MOVE_INCH 7.0f/160.0f
|
2014-03-11 17:13:54 +08:00
|
|
|
|
2015-07-01 11:41:47 +08:00
|
|
|
static float convertDistanceFromPointToInch(const Vec2& dis)
|
2015-06-25 16:57:00 +08:00
|
|
|
{
|
|
|
|
auto glview = Director::getInstance()->getOpenGLView();
|
2015-06-25 20:57:23 +08:00
|
|
|
int dpi = Device::getDPI();
|
2015-06-25 21:34:00 +08:00
|
|
|
float distance = Vec2(dis.x * glview->getScaleX() / dpi, dis.y * glview->getScaleY() / dpi).getLength();
|
2015-06-25 20:57:23 +08:00
|
|
|
return distance;
|
2015-06-25 16:57:00 +08:00
|
|
|
}
|
2015-06-20 22:42:37 +08:00
|
|
|
|
2015-07-19 10:41:20 +08:00
|
|
|
namespace ui {
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
IMPLEMENT_CLASS_GUI_INFO(ScrollView)
|
|
|
|
|
|
|
|
ScrollView::ScrollView():
|
|
|
|
_innerContainer(nullptr),
|
2014-05-12 11:08:10 +08:00
|
|
|
_direction(Direction::VERTICAL),
|
2014-03-11 17:13:54 +08:00
|
|
|
_topBoundary(0.0f),
|
|
|
|
_bottomBoundary(0.0f),
|
|
|
|
_leftBoundary(0.0f),
|
|
|
|
_rightBoundary(0.0f),
|
|
|
|
_bePressed(false),
|
2015-06-25 16:57:00 +08:00
|
|
|
_childFocusCancelOffsetInInch(MOVE_INCH),
|
2015-08-30 14:58:20 +08:00
|
|
|
_touchMovePreviousTimestamp(0),
|
2016-01-18 18:16:35 +08:00
|
|
|
_touchTotalTimeThreshold(0.5f),
|
2017-07-13 10:35:29 +08:00
|
|
|
_scrolling(false),
|
2015-06-21 17:22:21 +08:00
|
|
|
_autoScrolling(false),
|
|
|
|
_autoScrollAttenuate(true),
|
2015-09-04 14:23:55 +08:00
|
|
|
_autoScrollTotalTime(0),
|
2015-06-21 17:22:21 +08:00
|
|
|
_autoScrollAccumulatedTime(0),
|
2015-09-04 16:28:38 +08:00
|
|
|
_autoScrollCurrentlyOutOfBoundary(false),
|
|
|
|
_autoScrollBraking(false),
|
2015-08-31 13:17:48 +08:00
|
|
|
_inertiaScrollEnabled(true),
|
2015-06-22 10:38:16 +08:00
|
|
|
_bounceEnabled(false),
|
2016-03-09 19:08:18 +08:00
|
|
|
_outOfBoundaryAmount(Vec2::ZERO),
|
2015-09-08 21:14:44 +08:00
|
|
|
_outOfBoundaryAmountDirty(true),
|
2015-07-01 11:41:47 +08:00
|
|
|
_scrollBarEnabled(true),
|
|
|
|
_verticalScrollBar(nullptr),
|
|
|
|
_horizontalScrollBar(nullptr),
|
2014-03-11 17:13:54 +08:00
|
|
|
_scrollViewEventListener(nullptr),
|
2014-05-12 11:08:10 +08:00
|
|
|
_eventCallback(nullptr)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-06-24 15:51:14 +08:00
|
|
|
setTouchEnabled(true);
|
2015-07-29 18:43:11 +08:00
|
|
|
_propagateTouchEvents = false;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView::~ScrollView()
|
|
|
|
{
|
2015-07-03 21:17:54 +08:00
|
|
|
_verticalScrollBar = nullptr;
|
|
|
|
_horizontalScrollBar = nullptr;
|
2014-03-11 17:13:54 +08:00
|
|
|
_scrollViewEventListener = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView* ScrollView::create()
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
ScrollView* widget = new (std::nothrow) ScrollView();
|
2014-03-11 17:13:54 +08:00
|
|
|
if (widget && widget->init())
|
|
|
|
{
|
|
|
|
widget->autorelease();
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(widget);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
void ScrollView::onEnter()
|
|
|
|
{
|
|
|
|
Layout::onEnter();
|
|
|
|
scheduleUpdate();
|
|
|
|
}
|
|
|
|
|
2017-12-14 13:38:03 +08:00
|
|
|
void ScrollView::onExit()
|
|
|
|
{
|
|
|
|
Layout::onExit();
|
|
|
|
stopOverallScroll();
|
|
|
|
}
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
bool ScrollView::init()
|
|
|
|
{
|
|
|
|
if (Layout::init())
|
|
|
|
{
|
|
|
|
setClippingEnabled(true);
|
|
|
|
_innerContainer->setTouchEnabled(false);
|
2015-07-03 22:03:02 +08:00
|
|
|
if(_scrollBarEnabled)
|
|
|
|
{
|
|
|
|
initScrollBar();
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::initRenderer()
|
|
|
|
{
|
|
|
|
Layout::initRenderer();
|
|
|
|
_innerContainer = Layout::create();
|
2014-10-09 18:28:09 +08:00
|
|
|
_innerContainer->setColor(Color3B(255,255,255));
|
|
|
|
_innerContainer->setOpacity(255);
|
|
|
|
_innerContainer->setCascadeColorEnabled(true);
|
|
|
|
_innerContainer->setCascadeOpacityEnabled(true);
|
2014-05-22 17:49:19 +08:00
|
|
|
addProtectedChild(_innerContainer, 1, 1);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::onSizeChanged()
|
|
|
|
{
|
|
|
|
Layout::onSizeChanged();
|
2014-06-20 10:40:16 +08:00
|
|
|
_topBoundary = _contentSize.height;
|
|
|
|
_rightBoundary = _contentSize.width;
|
2014-06-20 11:18:53 +08:00
|
|
|
Size innerSize = _innerContainer->getContentSize();
|
2014-03-11 17:13:54 +08:00
|
|
|
float orginInnerSizeWidth = innerSize.width;
|
|
|
|
float orginInnerSizeHeight = innerSize.height;
|
2014-06-20 10:40:16 +08:00
|
|
|
float innerSizeWidth = MAX(orginInnerSizeWidth, _contentSize.width);
|
|
|
|
float innerSizeHeight = MAX(orginInnerSizeHeight, _contentSize.height);
|
2014-06-20 14:03:33 +08:00
|
|
|
_innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight));
|
2019-09-24 11:31:35 +08:00
|
|
|
setInnerContainerPosition(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height));
|
2016-03-10 18:06:20 +08:00
|
|
|
|
|
|
|
if (_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onScrolled(getHowMuchOutOfBoundary());
|
|
|
|
}
|
|
|
|
if (_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onScrolled(getHowMuchOutOfBoundary());
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setInnerContainerSize(const Size &size)
|
|
|
|
{
|
2014-06-20 10:40:16 +08:00
|
|
|
float innerSizeWidth = _contentSize.width;
|
|
|
|
float innerSizeHeight = _contentSize.height;
|
2014-06-20 11:18:53 +08:00
|
|
|
Size originalInnerSize = _innerContainer->getContentSize();
|
2014-06-20 10:40:16 +08:00
|
|
|
if (size.width < _contentSize.width)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
CCLOG("Inner width <= scrollview width, it will be force sized!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
innerSizeWidth = size.width;
|
|
|
|
}
|
2014-06-20 10:40:16 +08:00
|
|
|
if (size.height < _contentSize.height)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
CCLOG("Inner height <= scrollview height, it will be force sized!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
innerSizeHeight = size.height;
|
|
|
|
}
|
2014-06-20 14:03:33 +08:00
|
|
|
_innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight));
|
2015-06-29 11:52:53 +08:00
|
|
|
|
|
|
|
// Calculate and set the position of the inner container.
|
|
|
|
Vec2 pos = _innerContainer->getPosition();
|
2015-12-10 13:37:07 +08:00
|
|
|
if (_innerContainer->getLeftBoundary() != 0.0f)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-06-29 11:52:53 +08:00
|
|
|
pos.x = _innerContainer->getAnchorPoint().x * _innerContainer->getContentSize().width;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2015-12-10 13:37:07 +08:00
|
|
|
if (_innerContainer->getTopBoundary() != _contentSize.height)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-06-29 11:52:53 +08:00
|
|
|
pos.y = _contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2015-07-08 19:23:16 +08:00
|
|
|
setInnerContainerPosition(pos);
|
2015-08-24 17:43:53 +08:00
|
|
|
|
|
|
|
updateScrollBar(Vec2::ZERO);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const Size& ScrollView::getInnerContainerSize() const
|
|
|
|
{
|
2015-06-29 11:52:53 +08:00
|
|
|
return _innerContainer->getContentSize();
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2015-07-08 19:23:16 +08:00
|
|
|
void ScrollView::setInnerContainerPosition(const Vec2 &position)
|
|
|
|
{
|
2015-08-07 17:47:46 +08:00
|
|
|
if(position == _innerContainer->getPosition())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-07-08 19:23:16 +08:00
|
|
|
_innerContainer->setPosition(position);
|
2015-09-08 21:14:44 +08:00
|
|
|
_outOfBoundaryAmountDirty = true;
|
2015-07-08 19:23:16 +08:00
|
|
|
|
2015-09-03 15:56:27 +08:00
|
|
|
// Process bouncing events
|
|
|
|
if(_bounceEnabled)
|
|
|
|
{
|
|
|
|
for(int direction = (int) MoveDirection::TOP; direction < (int) MoveDirection::RIGHT; ++direction)
|
|
|
|
{
|
|
|
|
if(isOutOfBoundary((MoveDirection) direction))
|
|
|
|
{
|
|
|
|
processScrollEvent((MoveDirection) direction, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-08 19:23:16 +08:00
|
|
|
this->retain();
|
|
|
|
if (_eventCallback)
|
|
|
|
{
|
|
|
|
_eventCallback(this, EventType::CONTAINER_MOVED);
|
|
|
|
}
|
|
|
|
if (_ccEventCallback)
|
|
|
|
{
|
|
|
|
_ccEventCallback(this, static_cast<int>(EventType::CONTAINER_MOVED));
|
|
|
|
}
|
|
|
|
this->release();
|
|
|
|
}
|
|
|
|
|
2016-02-15 23:25:01 +08:00
|
|
|
const Vec2& ScrollView::getInnerContainerPosition() const
|
2015-07-08 19:23:16 +08:00
|
|
|
{
|
|
|
|
return _innerContainer->getPosition();
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:17:16 +08:00
|
|
|
void ScrollView::addChild(Node* child)
|
|
|
|
{
|
|
|
|
ScrollView::addChild(child, child->getLocalZOrder(), child->getTag());
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-06-25 16:17:16 +08:00
|
|
|
void ScrollView::addChild(Node * child, int localZOrder)
|
|
|
|
{
|
|
|
|
ScrollView::addChild(child, localZOrder, child->getTag());
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
void ScrollView::addChild(Node *child, int zOrder, int tag)
|
|
|
|
{
|
2017-01-04 11:06:44 +08:00
|
|
|
child->setGlobalZOrder(_globalZOrder);
|
2014-03-13 10:11:41 +08:00
|
|
|
_innerContainer->addChild(child, zOrder, tag);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-06-25 11:27:48 +08:00
|
|
|
void ScrollView::addChild(Node* child, int zOrder, const std::string &name)
|
|
|
|
{
|
2017-01-04 11:06:44 +08:00
|
|
|
child->setGlobalZOrder(_globalZOrder);
|
2014-06-25 11:27:48 +08:00
|
|
|
_innerContainer->addChild(child, zOrder, name);
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
void ScrollView::removeAllChildren()
|
|
|
|
{
|
|
|
|
removeAllChildrenWithCleanup(true);
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
void ScrollView::removeAllChildrenWithCleanup(bool cleanup)
|
|
|
|
{
|
|
|
|
_innerContainer->removeAllChildrenWithCleanup(cleanup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::removeChild(Node* child, bool cleanup)
|
|
|
|
{
|
2015-06-29 11:52:53 +08:00
|
|
|
return _innerContainer->removeChild(child, cleanup);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector<Node*>& ScrollView::getChildren()
|
|
|
|
{
|
|
|
|
return _innerContainer->getChildren();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Vector<Node*>& ScrollView::getChildren() const
|
|
|
|
{
|
|
|
|
return _innerContainer->getChildren();
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t ScrollView::getChildrenCount() const
|
|
|
|
{
|
|
|
|
return _innerContainer->getChildrenCount();
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-05-17 15:40:36 +08:00
|
|
|
Node* ScrollView::getChildByTag(int tag) const
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return _innerContainer->getChildByTag(tag);
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-06-11 16:57:43 +08:00
|
|
|
Node* ScrollView::getChildByName(const std::string& name)const
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return _innerContainer->getChildByName(name);
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2015-09-19 21:42:14 +08:00
|
|
|
void ScrollView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-19 21:42:14 +08:00
|
|
|
Vec2 adjustedMove = flattenVectorByDirection(deltaMove);
|
|
|
|
|
|
|
|
setInnerContainerPosition(getInnerContainerPosition() + adjustedMove);
|
|
|
|
|
|
|
|
Vec2 outOfBoundary = getHowMuchOutOfBoundary();
|
2015-07-03 21:17:54 +08:00
|
|
|
updateScrollBar(outOfBoundary);
|
2015-09-19 21:42:14 +08:00
|
|
|
|
|
|
|
if(_bounceEnabled && canStartBounceBack)
|
|
|
|
{
|
|
|
|
startBounceBackIfNeeded();
|
|
|
|
}
|
2015-07-01 11:41:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::updateScrollBar(const Vec2& outOfBoundary)
|
|
|
|
{
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onScrolled(outOfBoundary);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onScrolled(outOfBoundary);
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 11:46:01 +08:00
|
|
|
Vec2 ScrollView::calculateTouchMoveVelocity() const
|
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
float totalTime = 0;
|
2015-09-04 11:46:01 +08:00
|
|
|
for(auto &timeDelta : _touchMoveTimeDeltas)
|
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
totalTime += timeDelta;
|
2015-09-04 11:46:01 +08:00
|
|
|
}
|
2016-01-18 18:16:35 +08:00
|
|
|
if(totalTime == 0 || totalTime >= _touchTotalTimeThreshold)
|
2015-09-04 11:46:01 +08:00
|
|
|
{
|
|
|
|
return Vec2::ZERO;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vec2 totalMovement;
|
|
|
|
for(auto &displacement : _touchMoveDisplacements)
|
|
|
|
{
|
|
|
|
totalMovement += displacement;
|
|
|
|
}
|
2015-09-04 14:23:55 +08:00
|
|
|
return totalMovement / totalTime;
|
2015-09-04 11:46:01 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 10:09:47 +08:00
|
|
|
void ScrollView::startInertiaScroll(const Vec2& touchMoveVelocity)
|
|
|
|
{
|
|
|
|
const float MOVEMENT_FACTOR = 0.7f;
|
2015-09-04 13:38:26 +08:00
|
|
|
Vec2 inertiaTotalMovement = touchMoveVelocity * MOVEMENT_FACTOR;
|
|
|
|
startAttenuatingAutoScroll(inertiaTotalMovement, touchMoveVelocity);
|
2015-09-04 10:09:47 +08:00
|
|
|
}
|
|
|
|
|
2015-06-20 16:28:29 +08:00
|
|
|
bool ScrollView::startBounceBackIfNeeded()
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
if (!_bounceEnabled)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 bounceBackAmount = getHowMuchOutOfBoundary();
|
2016-03-09 19:08:18 +08:00
|
|
|
if(fltEqualZero(bounceBackAmount))
|
2015-06-29 11:52:53 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-04 10:23:01 +08:00
|
|
|
|
2015-09-08 21:14:44 +08:00
|
|
|
startAutoScroll(bounceBackAmount, BOUNCE_BACK_DURATION, true);
|
2015-06-29 11:52:53 +08:00
|
|
|
return true;
|
2015-06-20 22:42:37 +08:00
|
|
|
}
|
|
|
|
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 ScrollView::flattenVectorByDirection(const Vec2& vector)
|
2015-06-20 22:42:37 +08:00
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 result = vector;
|
|
|
|
result.x = (_direction == Direction::VERTICAL ? 0 : result.x);
|
|
|
|
result.y = (_direction == Direction::HORIZONTAL ? 0 : result.y);
|
|
|
|
return result;
|
|
|
|
}
|
2015-06-29 11:52:53 +08:00
|
|
|
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 ScrollView::getHowMuchOutOfBoundary(const Vec2& addition)
|
|
|
|
{
|
|
|
|
if(addition == Vec2::ZERO && !_outOfBoundaryAmountDirty)
|
|
|
|
{
|
|
|
|
return _outOfBoundaryAmount;
|
|
|
|
}
|
|
|
|
|
2016-03-09 19:08:18 +08:00
|
|
|
Vec2 outOfBoundaryAmount(Vec2::ZERO);
|
2015-06-29 11:52:53 +08:00
|
|
|
if(_innerContainer->getLeftBoundary() + addition.x > _leftBoundary)
|
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
outOfBoundaryAmount.x = _leftBoundary - (_innerContainer->getLeftBoundary() + addition.x);
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
|
|
|
else if(_innerContainer->getRightBoundary() + addition.x < _rightBoundary)
|
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
outOfBoundaryAmount.x = _rightBoundary - (_innerContainer->getRightBoundary() + addition.x);
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
2015-09-08 21:14:44 +08:00
|
|
|
|
2015-06-29 11:52:53 +08:00
|
|
|
if(_innerContainer->getTopBoundary() + addition.y < _topBoundary)
|
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
outOfBoundaryAmount.y = _topBoundary - (_innerContainer->getTopBoundary() + addition.y);
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
|
|
|
else if(_innerContainer->getBottomBoundary() + addition.y > _bottomBoundary)
|
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
outOfBoundaryAmount.y = _bottomBoundary - (_innerContainer->getBottomBoundary() + addition.y);
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
2015-09-08 21:14:44 +08:00
|
|
|
|
|
|
|
if(addition == Vec2::ZERO)
|
|
|
|
{
|
|
|
|
_outOfBoundaryAmount = outOfBoundaryAmount;
|
|
|
|
_outOfBoundaryAmountDirty = false;
|
|
|
|
}
|
|
|
|
return outOfBoundaryAmount;
|
2015-09-08 15:54:58 +08:00
|
|
|
}
|
|
|
|
|
2015-09-08 21:14:44 +08:00
|
|
|
bool ScrollView::isOutOfBoundary(MoveDirection dir)
|
2015-06-19 17:32:32 +08:00
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 outOfBoundary = getHowMuchOutOfBoundary();
|
2015-06-29 11:52:53 +08:00
|
|
|
switch(dir)
|
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
case MoveDirection::TOP: return outOfBoundary.y > 0;
|
|
|
|
case MoveDirection::BOTTOM: return outOfBoundary.y < 0;
|
|
|
|
case MoveDirection::LEFT: return outOfBoundary.x < 0;
|
|
|
|
case MoveDirection::RIGHT: return outOfBoundary.x > 0;
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
2015-08-31 11:24:33 +08:00
|
|
|
return false;
|
2015-06-19 17:32:32 +08:00
|
|
|
}
|
|
|
|
|
2015-09-08 21:14:44 +08:00
|
|
|
bool ScrollView::isOutOfBoundary()
|
2015-08-31 13:17:48 +08:00
|
|
|
{
|
2016-03-09 19:08:18 +08:00
|
|
|
return !fltEqualZero(getHowMuchOutOfBoundary());
|
2015-08-31 13:17:48 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::startAutoScrollToDestination(const Vec2& destination, float timeInSec, bool attenuated)
|
2015-08-31 11:36:05 +08:00
|
|
|
{
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScroll(destination - _innerContainer->getPosition(), timeInSec, attenuated);
|
2015-08-31 11:36:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 14:23:55 +08:00
|
|
|
static float calculateAutoScrollTimeByInitialSpeed(float initialSpeed)
|
2015-09-04 10:09:47 +08:00
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
// Calculate the time from the initial speed according to quintic polynomial.
|
|
|
|
float time = sqrtf(sqrtf(initialSpeed / 5));
|
|
|
|
return time;
|
2015-09-04 10:09:47 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 10:23:01 +08:00
|
|
|
void ScrollView::startAttenuatingAutoScroll(const Vec2& deltaMove, const Vec2& initialVelocity)
|
2015-09-04 10:09:47 +08:00
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
float time = calculateAutoScrollTimeByInitialSpeed(initialVelocity.length());
|
|
|
|
startAutoScroll(deltaMove, time, true);
|
2015-09-04 10:09:47 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::startAutoScroll(const Vec2& deltaMove, float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-08 15:54:58 +08:00
|
|
|
Vec2 adjustedDeltaMove = flattenVectorByDirection(deltaMove);
|
2015-09-04 13:38:26 +08:00
|
|
|
|
2015-06-29 11:52:53 +08:00
|
|
|
_autoScrolling = true;
|
2015-09-04 13:38:26 +08:00
|
|
|
_autoScrollTargetDelta = adjustedDeltaMove;
|
2015-06-29 11:52:53 +08:00
|
|
|
_autoScrollAttenuate = attenuated;
|
|
|
|
_autoScrollStartPosition = _innerContainer->getPosition();
|
2015-09-11 14:59:46 +08:00
|
|
|
_autoScrollTotalTime = timeInSec;
|
2015-06-29 11:52:53 +08:00
|
|
|
_autoScrollAccumulatedTime = 0;
|
2015-09-04 16:28:38 +08:00
|
|
|
_autoScrollBraking = false;
|
|
|
|
_autoScrollBrakingStartPosition = Vec2::ZERO;
|
|
|
|
|
2015-12-21 07:21:45 +08:00
|
|
|
// If the destination is also out of boundary of same side, start brake from beginning.
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 currentOutOfBoundary = getHowMuchOutOfBoundary();
|
2016-03-09 19:08:18 +08:00
|
|
|
if (!fltEqualZero(currentOutOfBoundary))
|
2015-09-04 16:28:38 +08:00
|
|
|
{
|
2015-09-08 21:14:44 +08:00
|
|
|
_autoScrollCurrentlyOutOfBoundary = true;
|
2015-09-04 16:28:38 +08:00
|
|
|
Vec2 afterOutOfBoundary = getHowMuchOutOfBoundary(adjustedDeltaMove);
|
|
|
|
if(currentOutOfBoundary.x * afterOutOfBoundary.x > 0 || currentOutOfBoundary.y * afterOutOfBoundary.y > 0)
|
|
|
|
{
|
|
|
|
_autoScrollBraking = true;
|
|
|
|
}
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2017-12-14 13:38:03 +08:00
|
|
|
void ScrollView::stopScroll()
|
|
|
|
{
|
|
|
|
if (_scrolling)
|
|
|
|
{
|
|
|
|
if (_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onTouchEnded();
|
|
|
|
}
|
|
|
|
if (_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onTouchEnded();
|
|
|
|
}
|
|
|
|
|
|
|
|
_scrolling = false;
|
|
|
|
_bePressed = false;
|
|
|
|
|
|
|
|
startBounceBackIfNeeded();
|
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::SCROLLING_ENDED);
|
2017-12-14 13:38:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-21 08:05:52 +08:00
|
|
|
void ScrollView::stopAutoScroll()
|
|
|
|
{
|
2017-12-14 13:38:03 +08:00
|
|
|
if (_autoScrolling)
|
|
|
|
{
|
|
|
|
if (_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onTouchEnded();
|
|
|
|
}
|
|
|
|
if (_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onTouchEnded();
|
|
|
|
}
|
|
|
|
|
|
|
|
_autoScrolling = false;
|
|
|
|
_autoScrollAttenuate = true;
|
|
|
|
_autoScrollTotalTime = 0;
|
|
|
|
_autoScrollAccumulatedTime = 0;
|
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::AUTOSCROLL_ENDED);
|
2017-12-14 13:38:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::stopOverallScroll()
|
|
|
|
{
|
|
|
|
stopScroll();
|
|
|
|
stopAutoScroll();
|
2016-01-21 08:05:52 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 16:28:38 +08:00
|
|
|
bool ScrollView::isNecessaryAutoScrollBrake()
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-04 16:28:38 +08:00
|
|
|
if(_autoScrollBraking)
|
2015-08-31 11:36:05 +08:00
|
|
|
{
|
2015-09-04 16:28:38 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isOutOfBoundary())
|
|
|
|
{
|
|
|
|
// It just went out of boundary.
|
|
|
|
if(!_autoScrollCurrentlyOutOfBoundary)
|
2015-08-31 11:36:05 +08:00
|
|
|
{
|
2015-09-04 16:28:38 +08:00
|
|
|
_autoScrollCurrentlyOutOfBoundary = true;
|
|
|
|
_autoScrollBraking = true;
|
|
|
|
_autoScrollBrakingStartPosition = getInnerContainerPosition();
|
|
|
|
return true;
|
2015-08-31 11:36:05 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-04 16:28:38 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_autoScrollCurrentlyOutOfBoundary = false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-09 19:08:18 +08:00
|
|
|
float ScrollView::getAutoScrollStopEpsilon() const
|
2016-02-04 15:24:06 +08:00
|
|
|
{
|
|
|
|
return FLT_EPSILON;
|
|
|
|
}
|
2016-03-09 19:08:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
bool ScrollView::fltEqualZero(const Vec2& point) const
|
|
|
|
{
|
|
|
|
return (fabsf(point.x) <= 0.0001f && fabsf(point.y) <= 0.0001f);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-04 15:24:06 +08:00
|
|
|
|
2015-09-04 16:28:38 +08:00
|
|
|
void ScrollView::processAutoScrolling(float deltaTime)
|
|
|
|
{
|
|
|
|
// Make auto scroll shorter if it needs to deaccelerate.
|
|
|
|
float brakingFactor = (isNecessaryAutoScrollBrake() ? OUT_OF_BOUNDARY_BREAKING_FACTOR : 1);
|
2015-08-31 11:36:05 +08:00
|
|
|
|
2015-09-04 10:23:01 +08:00
|
|
|
// Elapsed time
|
2015-09-04 16:28:38 +08:00
|
|
|
_autoScrollAccumulatedTime += deltaTime * (1 / brakingFactor);
|
2015-09-04 10:23:01 +08:00
|
|
|
|
|
|
|
// Calculate the progress percentage
|
2015-09-04 14:23:55 +08:00
|
|
|
float percentage = MIN(1, _autoScrollAccumulatedTime / _autoScrollTotalTime);
|
2015-09-04 10:23:01 +08:00
|
|
|
if(_autoScrollAttenuate)
|
2015-08-31 11:36:05 +08:00
|
|
|
{
|
2015-09-04 10:23:01 +08:00
|
|
|
// Use quintic(5th degree) polynomial
|
|
|
|
percentage = tweenfunc::quintEaseOut(percentage);
|
2015-08-31 11:36:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-01 14:12:27 +08:00
|
|
|
// Calculate the new position
|
2015-09-04 10:23:01 +08:00
|
|
|
Vec2 newPosition = _autoScrollStartPosition + (_autoScrollTargetDelta * percentage);
|
2016-07-12 03:13:56 +08:00
|
|
|
bool reachedEnd = std::abs(percentage - 1) <= this->getAutoScrollStopEpsilon();
|
2015-09-01 14:12:27 +08:00
|
|
|
|
2016-04-08 03:08:02 +08:00
|
|
|
if (reachedEnd)
|
|
|
|
{
|
|
|
|
newPosition = _autoScrollStartPosition + _autoScrollTargetDelta;
|
|
|
|
}
|
|
|
|
|
2015-09-01 14:33:32 +08:00
|
|
|
if(_bounceEnabled)
|
2015-09-01 14:12:27 +08:00
|
|
|
{
|
2015-09-04 10:23:01 +08:00
|
|
|
// The new position is adjusted if out of boundary
|
2015-09-04 16:28:38 +08:00
|
|
|
newPosition = _autoScrollBrakingStartPosition + (newPosition - _autoScrollBrakingStartPosition) * brakingFactor;
|
2015-09-01 14:33:32 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-04 10:23:01 +08:00
|
|
|
// Don't let go out of boundary
|
2015-09-01 14:33:32 +08:00
|
|
|
Vec2 moveDelta = newPosition - getInnerContainerPosition();
|
|
|
|
Vec2 outOfBoundary = getHowMuchOutOfBoundary(moveDelta);
|
2016-03-09 19:08:18 +08:00
|
|
|
if (!fltEqualZero(outOfBoundary))
|
2015-09-01 14:12:27 +08:00
|
|
|
{
|
2015-09-01 14:33:32 +08:00
|
|
|
newPosition += outOfBoundary;
|
|
|
|
reachedEnd = true;
|
2015-09-01 14:12:27 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-19 21:42:14 +08:00
|
|
|
|
2015-09-01 14:12:27 +08:00
|
|
|
// Finish auto scroll if it ended
|
2015-09-04 10:23:01 +08:00
|
|
|
if(reachedEnd)
|
2015-08-31 13:17:48 +08:00
|
|
|
{
|
|
|
|
_autoScrolling = false;
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::AUTOSCROLL_ENDED);
|
2015-08-31 13:17:48 +08:00
|
|
|
}
|
2015-09-19 21:42:14 +08:00
|
|
|
|
|
|
|
moveInnerContainer(newPosition - getInnerContainerPosition(), reachedEnd);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void ScrollView::jumpToDestination(const Vec2 &des)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-19 22:16:36 +08:00
|
|
|
_autoScrolling = false;
|
|
|
|
moveInnerContainer(des - getInnerContainerPosition(), true);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-20 08:14:13 +08:00
|
|
|
void ScrollView::scrollChildren(const Vec2& deltaMove)
|
2015-06-18 21:28:04 +08:00
|
|
|
{
|
2015-09-20 08:14:13 +08:00
|
|
|
Vec2 realMove = deltaMove;
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_bounceEnabled)
|
|
|
|
{
|
|
|
|
// If the position of the inner container is out of the boundary, the offsets should be divided by two.
|
2015-09-08 21:14:44 +08:00
|
|
|
Vec2 outOfBoundary = getHowMuchOutOfBoundary();
|
2015-09-20 08:14:13 +08:00
|
|
|
realMove.x *= (outOfBoundary.x == 0 ? 1 : 0.5f);
|
|
|
|
realMove.y *= (outOfBoundary.y == 0 ? 1 : 0.5f);
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-20 14:21:22 +08:00
|
|
|
if(!_bounceEnabled)
|
|
|
|
{
|
2015-09-20 08:14:13 +08:00
|
|
|
Vec2 outOfBoundary = getHowMuchOutOfBoundary(realMove);
|
|
|
|
realMove += outOfBoundary;
|
2015-09-20 14:21:22 +08:00
|
|
|
}
|
2015-07-03 21:17:54 +08:00
|
|
|
|
2015-07-08 19:23:16 +08:00
|
|
|
bool scrolledToLeft = false;
|
|
|
|
bool scrolledToRight = false;
|
|
|
|
bool scrolledToTop = false;
|
|
|
|
bool scrolledToBottom = false;
|
2015-09-20 08:14:13 +08:00
|
|
|
if (realMove.y > 0.0f) // up
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
|
|
|
float icBottomPos = _innerContainer->getBottomBoundary();
|
2015-09-20 08:14:13 +08:00
|
|
|
if (icBottomPos + realMove.y >= _bottomBoundary)
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
2015-07-08 19:23:16 +08:00
|
|
|
scrolledToBottom = true;
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-20 08:14:13 +08:00
|
|
|
else if (realMove.y < 0.0f) // down
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
|
|
|
float icTopPos = _innerContainer->getTopBoundary();
|
2015-09-20 08:14:13 +08:00
|
|
|
if (icTopPos + realMove.y <= _topBoundary)
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
2015-07-08 19:23:16 +08:00
|
|
|
scrolledToTop = true;
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-20 08:14:13 +08:00
|
|
|
if (realMove.x < 0.0f) // left
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
|
|
|
float icRightPos = _innerContainer->getRightBoundary();
|
2015-09-20 08:14:13 +08:00
|
|
|
if (icRightPos + realMove.x <= _rightBoundary)
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
2015-07-08 19:23:16 +08:00
|
|
|
scrolledToRight = true;
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-20 08:14:13 +08:00
|
|
|
else if (realMove.x > 0.0f) // right
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
|
|
|
float icLeftPos = _innerContainer->getLeftBoundary();
|
2015-09-20 08:14:13 +08:00
|
|
|
if (icLeftPos + realMove.x >= _leftBoundary)
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
2015-07-08 19:23:16 +08:00
|
|
|
scrolledToLeft = true;
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-20 08:14:13 +08:00
|
|
|
moveInnerContainer(realMove, false);
|
2015-07-08 19:23:16 +08:00
|
|
|
|
2015-09-20 08:14:13 +08:00
|
|
|
if(realMove.x != 0 || realMove.y != 0)
|
2015-07-08 19:23:16 +08:00
|
|
|
{
|
|
|
|
processScrollingEvent();
|
|
|
|
}
|
|
|
|
if(scrolledToBottom)
|
|
|
|
{
|
|
|
|
processScrollEvent(MoveDirection::BOTTOM, false);
|
|
|
|
}
|
|
|
|
if(scrolledToTop)
|
|
|
|
{
|
|
|
|
processScrollEvent(MoveDirection::TOP, false);
|
|
|
|
}
|
|
|
|
if(scrolledToLeft)
|
|
|
|
{
|
|
|
|
processScrollEvent(MoveDirection::LEFT, false);
|
|
|
|
}
|
|
|
|
if(scrolledToRight)
|
|
|
|
{
|
|
|
|
processScrollEvent(MoveDirection::RIGHT, false);
|
|
|
|
}
|
2015-06-18 21:28:04 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToBottom(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_innerContainer->getPosition().x, 0.0f), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToTop(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_innerContainer->getPosition().x,
|
2015-09-11 14:59:46 +08:00
|
|
|
_contentSize.height - _innerContainer->getContentSize().height), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToLeft(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(0.0f, _innerContainer->getPosition().y), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToRight(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-09-04 14:23:55 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
2015-09-11 14:59:46 +08:00
|
|
|
_innerContainer->getPosition().y), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToTopLeft(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToTopRight(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-09-04 14:23:55 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
2015-09-11 14:59:46 +08:00
|
|
|
_contentSize.height - _innerContainer->getContentSize().height), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToBottomLeft(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2::ZERO, timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToBottomRight(float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToPercentVertical(float percent, float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-06-20 11:18:53 +08:00
|
|
|
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
2014-03-11 17:13:54 +08:00
|
|
|
float h = - minY;
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToPercentHorizontal(float percent, float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-06-20 11:18:53 +08:00
|
|
|
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float timeInSec, bool attenuated)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-06-20 11:18:53 +08:00
|
|
|
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
2014-03-11 17:13:54 +08:00
|
|
|
float h = - minY;
|
2014-06-20 11:18:53 +08:00
|
|
|
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
2015-09-11 14:59:46 +08:00
|
|
|
startAutoScrollToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), timeInSec, attenuated);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2017-07-13 10:35:29 +08:00
|
|
|
|
|
|
|
float ScrollView::getScrolledPercentVertical() const {
|
|
|
|
const float minY = getContentSize().height - getInnerContainerSize().height;
|
|
|
|
return (1.f - getInnerContainerPosition().y / minY)*100.f;
|
|
|
|
}
|
|
|
|
float ScrollView::getScrolledPercentHorizontal() const {
|
|
|
|
const float minX = getContentSize().width - getInnerContainerSize().width;
|
|
|
|
return getInnerContainerPosition().x / minX * 100.f;
|
|
|
|
}
|
|
|
|
Vec2 ScrollView::getScrolledPercentBothDirection() const {
|
|
|
|
return {getScrolledPercentHorizontal(), getScrolledPercentVertical()};
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
void ScrollView::jumpToBottom()
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2(_innerContainer->getPosition().x, 0.0f));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToTop()
|
|
|
|
{
|
2014-06-20 10:40:16 +08:00
|
|
|
jumpToDestination(Vec2(_innerContainer->getPosition().x,
|
2014-06-20 11:18:53 +08:00
|
|
|
_contentSize.height - _innerContainer->getContentSize().height));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToLeft()
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2(0.0f, _innerContainer->getPosition().y));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToRight()
|
|
|
|
{
|
2014-06-20 11:18:53 +08:00
|
|
|
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, _innerContainer->getPosition().y));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToTopLeft()
|
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-06-20 11:18:53 +08:00
|
|
|
jumpToDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToTopRight()
|
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-06-20 11:18:53 +08:00
|
|
|
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width,
|
|
|
|
_contentSize.height - _innerContainer->getContentSize().height));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToBottomLeft()
|
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2::ZERO);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToBottomRight()
|
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-01 11:41:47 +08:00
|
|
|
CCLOG("Scroll direction is not both!");
|
2014-03-11 17:13:54 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-06-20 11:18:53 +08:00
|
|
|
jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToPercentVertical(float percent)
|
|
|
|
{
|
2014-06-20 11:18:53 +08:00
|
|
|
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
2014-03-11 17:13:54 +08:00
|
|
|
float h = - minY;
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::jumpToPercentHorizontal(float percent)
|
|
|
|
{
|
2014-06-20 11:18:53 +08:00
|
|
|
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void ScrollView::jumpToPercentBothDirection(const Vec2& percent)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-12 11:08:10 +08:00
|
|
|
if (_direction != Direction::BOTH)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-06-20 11:18:53 +08:00
|
|
|
float minY = _contentSize.height - _innerContainer->getContentSize().height;
|
2014-03-11 17:13:54 +08:00
|
|
|
float h = - minY;
|
2014-06-20 11:18:53 +08:00
|
|
|
float w = _innerContainer->getContentSize().width - _contentSize.width;
|
2014-05-15 01:07:09 +08:00
|
|
|
jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f));
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-11 14:59:46 +08:00
|
|
|
bool ScrollView::calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt)
|
2015-09-04 11:46:01 +08:00
|
|
|
{
|
|
|
|
if (nullptr == _hittedByCamera ||
|
|
|
|
false == hitTest(touch->getLocation(), _hittedByCamera, currPt) ||
|
|
|
|
false == hitTest(touch->getPreviousLocation(), _hittedByCamera, prevPt))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::gatherTouchMove(const Vec2& delta)
|
|
|
|
{
|
|
|
|
while(_touchMoveDisplacements.size() >= NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED)
|
|
|
|
{
|
|
|
|
_touchMoveDisplacements.pop_front();
|
|
|
|
_touchMoveTimeDeltas.pop_front();
|
|
|
|
}
|
|
|
|
_touchMoveDisplacements.push_back(delta);
|
|
|
|
|
|
|
|
long long timestamp = utils::getTimeInMilliseconds();
|
|
|
|
_touchMoveTimeDeltas.push_back((timestamp - _touchMovePreviousTimestamp) / 1000.0f);
|
|
|
|
_touchMovePreviousTimestamp = timestamp;
|
|
|
|
}
|
|
|
|
|
2016-11-16 09:48:37 +08:00
|
|
|
void ScrollView::handlePressLogic(Touch* /*touch*/)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-07-19 10:41:20 +08:00
|
|
|
_bePressed = true;
|
2015-08-31 13:17:48 +08:00
|
|
|
_autoScrolling = false;
|
2015-07-19 10:41:20 +08:00
|
|
|
|
2015-09-04 11:46:01 +08:00
|
|
|
// Clear gathered touch move information
|
2015-08-30 14:58:20 +08:00
|
|
|
{
|
|
|
|
_touchMovePreviousTimestamp = utils::getTimeInMilliseconds();
|
|
|
|
_touchMoveDisplacements.clear();
|
|
|
|
_touchMoveTimeDeltas.clear();
|
|
|
|
}
|
|
|
|
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onTouchBegan();
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onTouchBegan();
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2014-06-06 16:48:49 +08:00
|
|
|
void ScrollView::handleMoveLogic(Touch *touch)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2017-12-14 13:38:03 +08:00
|
|
|
if (!_bePressed)
|
|
|
|
return;
|
|
|
|
|
2015-06-18 10:23:52 +08:00
|
|
|
Vec3 currPt, prevPt;
|
2015-09-11 14:59:46 +08:00
|
|
|
if(!calculateCurrAndPrevTouchPoints(touch, &currPt, &prevPt))
|
2015-06-18 10:23:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-06-30 14:32:14 +08:00
|
|
|
Vec3 delta3 = currPt - prevPt;
|
|
|
|
Vec2 delta(delta3.x, delta3.y);
|
2015-09-20 08:14:13 +08:00
|
|
|
scrollChildren(delta);
|
2015-07-19 10:41:20 +08:00
|
|
|
|
2015-08-30 14:58:20 +08:00
|
|
|
// Gather touch move information for speed calculation
|
2015-09-04 11:46:01 +08:00
|
|
|
gatherTouchMove(delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::handleReleaseLogic(Touch *touch)
|
|
|
|
{
|
2017-12-14 13:38:03 +08:00
|
|
|
if (!_bePressed)
|
|
|
|
return;
|
|
|
|
|
2015-09-04 11:46:01 +08:00
|
|
|
// Gather the last touch information when released
|
2015-06-29 11:52:53 +08:00
|
|
|
{
|
2015-09-04 11:46:01 +08:00
|
|
|
Vec3 currPt, prevPt;
|
2015-09-11 14:59:46 +08:00
|
|
|
if(calculateCurrAndPrevTouchPoints(touch, &currPt, &prevPt))
|
2015-07-19 10:41:20 +08:00
|
|
|
{
|
2015-09-04 11:46:01 +08:00
|
|
|
Vec3 delta3 = currPt - prevPt;
|
|
|
|
Vec2 delta(delta3.x, delta3.y);
|
|
|
|
gatherTouchMove(delta);
|
2015-07-19 10:41:20 +08:00
|
|
|
}
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
_bePressed = false;
|
2015-07-03 21:17:54 +08:00
|
|
|
|
2015-07-19 10:41:20 +08:00
|
|
|
bool bounceBackStarted = startBounceBackIfNeeded();
|
|
|
|
if(!bounceBackStarted && _inertiaScrollEnabled)
|
|
|
|
{
|
2015-08-31 13:17:48 +08:00
|
|
|
Vec2 touchMoveVelocity = calculateTouchMoveVelocity();
|
|
|
|
if(touchMoveVelocity != Vec2::ZERO)
|
2015-08-30 14:58:20 +08:00
|
|
|
{
|
2015-08-31 13:17:48 +08:00
|
|
|
startInertiaScroll(touchMoveVelocity);
|
2015-08-30 14:58:20 +08:00
|
|
|
}
|
2015-07-19 10:41:20 +08:00
|
|
|
}
|
|
|
|
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->onTouchEnded();
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->onTouchEnded();
|
|
|
|
}
|
2017-07-13 10:35:29 +08:00
|
|
|
|
|
|
|
if ( _scrolling ) {
|
|
|
|
processScrollingEndedEvent();
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
bool ScrollView::onTouchBegan(Touch *touch, Event *unusedEvent)
|
|
|
|
{
|
|
|
|
bool pass = Layout::onTouchBegan(touch, unusedEvent);
|
2014-08-15 15:28:28 +08:00
|
|
|
if (!_isInterceptTouch)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-08-15 15:28:28 +08:00
|
|
|
if (_hitted)
|
|
|
|
{
|
|
|
|
handlePressLogic(touch);
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::onTouchMoved(Touch *touch, Event *unusedEvent)
|
|
|
|
{
|
|
|
|
Layout::onTouchMoved(touch, unusedEvent);
|
2014-08-15 15:28:28 +08:00
|
|
|
if (!_isInterceptTouch)
|
|
|
|
{
|
|
|
|
handleMoveLogic(touch);
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::onTouchEnded(Touch *touch, Event *unusedEvent)
|
|
|
|
{
|
|
|
|
Layout::onTouchEnded(touch, unusedEvent);
|
2014-08-15 15:28:28 +08:00
|
|
|
if (!_isInterceptTouch)
|
|
|
|
{
|
|
|
|
handleReleaseLogic(touch);
|
|
|
|
}
|
|
|
|
_isInterceptTouch = false;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent)
|
|
|
|
{
|
|
|
|
Layout::onTouchCancelled(touch, unusedEvent);
|
2014-08-15 15:28:28 +08:00
|
|
|
if (!_isInterceptTouch)
|
|
|
|
{
|
|
|
|
handleReleaseLogic(touch);
|
|
|
|
}
|
|
|
|
_isInterceptTouch = false;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::update(float dt)
|
|
|
|
{
|
2015-08-31 13:17:48 +08:00
|
|
|
if (_autoScrolling)
|
2015-07-03 21:17:54 +08:00
|
|
|
{
|
|
|
|
processAutoScrolling(dt);
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2014-06-06 16:48:49 +08:00
|
|
|
void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sender,Touch* touch)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-08-06 22:50:53 +08:00
|
|
|
if(!_touchEnabled)
|
|
|
|
{
|
|
|
|
Layout::interceptTouchEvent(event, sender, touch);
|
|
|
|
return;
|
|
|
|
}
|
2015-12-06 22:51:22 +08:00
|
|
|
if(_direction == Direction::NONE)
|
|
|
|
return;
|
2014-06-06 16:48:49 +08:00
|
|
|
Vec2 touchPoint = touch->getLocation();
|
2014-05-22 15:23:13 +08:00
|
|
|
switch (event)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-22 15:23:13 +08:00
|
|
|
case TouchEventType::BEGAN:
|
2014-08-15 15:28:28 +08:00
|
|
|
{
|
|
|
|
_isInterceptTouch = true;
|
2014-06-25 10:45:08 +08:00
|
|
|
_touchBeganPosition = touch->getLocation();
|
2014-06-06 16:48:49 +08:00
|
|
|
handlePressLogic(touch);
|
2014-08-15 15:28:28 +08:00
|
|
|
}
|
|
|
|
break;
|
2014-05-22 15:23:13 +08:00
|
|
|
case TouchEventType::MOVED:
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-08-19 15:14:07 +08:00
|
|
|
_touchMovePosition = touch->getLocation();
|
2015-06-25 16:57:00 +08:00
|
|
|
// calculates move offset in points
|
2015-06-25 20:57:23 +08:00
|
|
|
float offsetInInch = 0;
|
2015-06-25 16:57:00 +08:00
|
|
|
switch (_direction)
|
|
|
|
{
|
|
|
|
case Direction::HORIZONTAL:
|
2019-09-24 11:31:35 +08:00
|
|
|
offsetInInch = convertDistanceFromPointToInch(Vec2(std::abs(sender->getTouchBeganPosition().x - touchPoint.x), 0.0f));
|
2015-06-25 16:57:00 +08:00
|
|
|
break;
|
|
|
|
case Direction::VERTICAL:
|
2019-09-24 11:31:35 +08:00
|
|
|
offsetInInch = convertDistanceFromPointToInch(Vec2(0.0f, std::abs(sender->getTouchBeganPosition().y - touchPoint.y)));
|
2015-06-25 16:57:00 +08:00
|
|
|
break;
|
|
|
|
case Direction::BOTH:
|
2015-06-25 20:57:23 +08:00
|
|
|
offsetInInch = convertDistanceFromPointToInch(sender->getTouchBeganPosition() - touchPoint);
|
2015-06-25 16:57:00 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-06-25 20:57:23 +08:00
|
|
|
if (offsetInInch > _childFocusCancelOffsetInInch)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2014-05-06 12:04:52 +08:00
|
|
|
sender->setHighlighted(false);
|
2014-06-06 16:48:49 +08:00
|
|
|
handleMoveLogic(touch);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
2014-08-15 15:28:28 +08:00
|
|
|
break;
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-05-22 15:23:13 +08:00
|
|
|
case TouchEventType::CANCELED:
|
|
|
|
case TouchEventType::ENDED:
|
2014-08-15 15:28:28 +08:00
|
|
|
{
|
2014-06-25 10:45:08 +08:00
|
|
|
_touchEndPosition = touch->getLocation();
|
2014-06-06 16:48:49 +08:00
|
|
|
handleReleaseLogic(touch);
|
2014-08-15 15:28:28 +08:00
|
|
|
if (sender->isSwallowTouches())
|
|
|
|
{
|
|
|
|
_isInterceptTouch = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-19 09:25:46 +08:00
|
|
|
void ScrollView::processScrollEvent(MoveDirection dir, bool bounce)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2015-06-29 11:52:53 +08:00
|
|
|
EventType eventType;
|
|
|
|
switch(dir) {
|
2015-08-31 11:24:33 +08:00
|
|
|
case MoveDirection::TOP:
|
|
|
|
{
|
|
|
|
eventType = (bounce ? EventType::BOUNCE_TOP : EventType::SCROLL_TO_TOP);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MoveDirection::BOTTOM:
|
|
|
|
{
|
|
|
|
eventType = (bounce ? EventType::BOUNCE_BOTTOM : EventType::SCROLL_TO_BOTTOM);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MoveDirection::LEFT:
|
|
|
|
{
|
|
|
|
eventType = (bounce ? EventType::BOUNCE_LEFT : EventType::SCROLL_TO_LEFT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MoveDirection::RIGHT:
|
|
|
|
{
|
|
|
|
eventType = (bounce ? EventType::BOUNCE_RIGHT : EventType::SCROLL_TO_RIGHT);
|
|
|
|
break;
|
2015-07-03 21:17:54 +08:00
|
|
|
}
|
2015-06-29 11:52:53 +08:00
|
|
|
}
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(eventType);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2015-06-19 09:25:46 +08:00
|
|
|
void ScrollView::processScrollingEvent()
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
2017-07-13 10:35:29 +08:00
|
|
|
if ( !_scrolling ) {
|
|
|
|
_scrolling = true;
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::SCROLLING_BEGAN);
|
2017-07-13 10:35:29 +08:00
|
|
|
}
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::SCROLLING);
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2017-07-13 10:35:29 +08:00
|
|
|
|
|
|
|
void ScrollView::processScrollingEndedEvent() {
|
|
|
|
_scrolling = false;
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
dispatchEvent(EventType::SCROLLING_ENDED);
|
2017-07-13 10:35:29 +08:00
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
void ScrollView::dispatchEvent(EventType eventType)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
this->retain();
|
|
|
|
if (_eventCallback)
|
|
|
|
{
|
|
|
|
_eventCallback(this, eventType);
|
|
|
|
}
|
|
|
|
if (_ccEventCallback)
|
|
|
|
{
|
|
|
|
_ccEventCallback(this, static_cast<int>(eventType));
|
|
|
|
}
|
|
|
|
this->release();
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2014-05-14 16:14:28 +08:00
|
|
|
void ScrollView::addEventListener(const ccScrollViewCallback& callback)
|
2014-05-12 11:08:10 +08:00
|
|
|
{
|
|
|
|
_eventCallback = callback;
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
2014-05-12 11:08:10 +08:00
|
|
|
void ScrollView::setDirection(Direction dir)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
_direction = dir;
|
2015-07-03 22:03:02 +08:00
|
|
|
if(_scrollBarEnabled)
|
|
|
|
{
|
|
|
|
removeScrollBar();
|
|
|
|
initScrollBar();
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-27 10:48:53 +08:00
|
|
|
ScrollView::Direction ScrollView::getDirection()const
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return _direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setBounceEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
_bounceEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollView::isBounceEnabled() const
|
|
|
|
{
|
|
|
|
return _bounceEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setInertiaScrollEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
_inertiaScrollEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollView::isInertiaScrollEnabled() const
|
|
|
|
{
|
|
|
|
return _inertiaScrollEnabled;
|
|
|
|
}
|
|
|
|
|
2015-07-01 11:41:47 +08:00
|
|
|
void ScrollView::setScrollBarEnabled(bool enabled)
|
|
|
|
{
|
2015-11-10 20:03:51 +08:00
|
|
|
if(_scrollBarEnabled == enabled)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:03:02 +08:00
|
|
|
if(_scrollBarEnabled)
|
|
|
|
{
|
|
|
|
removeScrollBar();
|
|
|
|
}
|
2015-07-03 21:17:54 +08:00
|
|
|
_scrollBarEnabled = enabled;
|
2015-07-03 22:03:02 +08:00
|
|
|
if(_scrollBarEnabled)
|
|
|
|
{
|
|
|
|
initScrollBar();
|
|
|
|
}
|
2015-07-01 11:41:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollView::isScrollBarEnabled() const
|
|
|
|
{
|
2015-07-03 21:17:54 +08:00
|
|
|
return _scrollBarEnabled;
|
2015-07-01 11:41:47 +08:00
|
|
|
}
|
|
|
|
|
2015-07-03 23:11:01 +08:00
|
|
|
void ScrollView::setScrollBarPositionFromCorner(const Vec2& positionFromCorner)
|
2015-07-03 20:32:29 +08:00
|
|
|
{
|
2015-07-03 23:11:01 +08:00
|
|
|
if(_direction != Direction::HORIZONTAL)
|
2015-07-03 22:03:02 +08:00
|
|
|
{
|
2015-07-03 23:11:01 +08:00
|
|
|
setScrollBarPositionFromCornerForVertical(positionFromCorner);
|
2015-07-03 22:03:02 +08:00
|
|
|
}
|
2015-07-03 23:11:01 +08:00
|
|
|
if(_direction != Direction::VERTICAL)
|
2015-07-03 22:03:02 +08:00
|
|
|
{
|
2015-07-03 23:11:01 +08:00
|
|
|
setScrollBarPositionFromCornerForHorizontal(positionFromCorner);
|
2015-07-03 22:03:02 +08:00
|
|
|
}
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
2015-07-03 23:11:01 +08:00
|
|
|
void ScrollView::setScrollBarPositionFromCornerForVertical(const Vec2& positionFromCorner)
|
2015-07-03 20:32:29 +08:00
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
2015-07-03 23:11:01 +08:00
|
|
|
CCASSERT(_direction != Direction::HORIZONTAL, "Scroll view doesn't have a vertical scroll bar!");
|
|
|
|
_verticalScrollBar->setPositionFromCorner(positionFromCorner);
|
|
|
|
}
|
|
|
|
|
2015-07-04 14:40:47 +08:00
|
|
|
Vec2 ScrollView::getScrollBarPositionFromCornerForVertical() const
|
2015-07-03 23:11:01 +08:00
|
|
|
{
|
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
CCASSERT(_direction != Direction::HORIZONTAL, "Scroll view doesn't have a vertical scroll bar!");
|
|
|
|
return _verticalScrollBar->getPositionFromCorner();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setScrollBarPositionFromCornerForHorizontal(const Vec2& positionFromCorner)
|
|
|
|
{
|
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
CCASSERT(_direction != Direction::VERTICAL, "Scroll view doesn't have a horizontal scroll bar!");
|
|
|
|
_horizontalScrollBar->setPositionFromCorner(positionFromCorner);
|
|
|
|
}
|
|
|
|
|
2015-07-04 14:40:47 +08:00
|
|
|
Vec2 ScrollView::getScrollBarPositionFromCornerForHorizontal() const
|
2015-07-03 23:11:01 +08:00
|
|
|
{
|
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
CCASSERT(_direction != Direction::VERTICAL, "Scroll view doesn't have a horizontal scroll bar!");
|
|
|
|
return _horizontalScrollBar->getPositionFromCorner();
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setScrollBarWidth(float width)
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->setWidth(width);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->setWidth(width);
|
|
|
|
}
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float ScrollView::getScrollBarWidth() const
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _verticalScrollBar->getWidth();
|
|
|
|
}
|
|
|
|
else if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _horizontalScrollBar->getWidth();
|
|
|
|
}
|
|
|
|
return 0;
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setScrollBarColor(const Color3B& color)
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->setColor(color);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->setColor(color);
|
|
|
|
}
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const Color3B& ScrollView::getScrollBarColor() const
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _verticalScrollBar->getColor();
|
|
|
|
}
|
|
|
|
else if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _horizontalScrollBar->getColor();
|
|
|
|
}
|
|
|
|
return Color3B::WHITE;
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
2019-06-05 17:58:33 +08:00
|
|
|
void ScrollView::setScrollBarOpacity(uint8_t opacity)
|
2015-07-08 14:16:47 +08:00
|
|
|
{
|
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->setOpacity(opacity);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->setOpacity(opacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-05 17:58:33 +08:00
|
|
|
uint8_t ScrollView::getScrollBarOpacity() const
|
2015-07-08 14:16:47 +08:00
|
|
|
{
|
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _verticalScrollBar->getOpacity();
|
|
|
|
}
|
|
|
|
else if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _horizontalScrollBar->getOpacity();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-07-03 20:32:29 +08:00
|
|
|
void ScrollView::setScrollBarAutoHideEnabled(bool autoHideEnabled)
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->setAutoHideEnabled(autoHideEnabled);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->setAutoHideEnabled(autoHideEnabled);
|
|
|
|
}
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScrollView::isScrollBarAutoHideEnabled() const
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _verticalScrollBar->isAutoHideEnabled();
|
|
|
|
}
|
|
|
|
else if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _horizontalScrollBar->isAutoHideEnabled();
|
|
|
|
}
|
|
|
|
return false;
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::setScrollBarAutoHideTime(float autoHideTime)
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar->setAutoHideTime(autoHideTime);
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar->setAutoHideTime(autoHideTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-03 20:32:29 +08:00
|
|
|
float ScrollView::getScrollBarAutoHideTime() const
|
|
|
|
{
|
2015-07-03 22:03:02 +08:00
|
|
|
CCASSERT(_scrollBarEnabled, "Scroll bar should be enabled!");
|
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _verticalScrollBar->getAutoHideTime();
|
|
|
|
}
|
|
|
|
else if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
return _horizontalScrollBar->getAutoHideTime();
|
|
|
|
}
|
|
|
|
return 0;
|
2015-07-03 20:32:29 +08:00
|
|
|
}
|
2016-01-18 18:16:35 +08:00
|
|
|
|
|
|
|
void ScrollView::setTouchTotalTimeThreshold(float touchTotalTimeThreshold)
|
|
|
|
{
|
|
|
|
_touchTotalTimeThreshold = touchTotalTimeThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
float ScrollView::getTouchTotalTimeThreshold() const
|
|
|
|
{
|
|
|
|
return _touchTotalTimeThreshold;
|
|
|
|
}
|
2015-07-03 20:32:29 +08:00
|
|
|
|
2014-05-27 10:48:53 +08:00
|
|
|
Layout* ScrollView::getInnerContainer()const
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return _innerContainer;
|
|
|
|
}
|
|
|
|
|
2014-05-12 18:00:54 +08:00
|
|
|
void ScrollView::setLayoutType(Type type)
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
_innerContainer->setLayoutType(type);
|
|
|
|
}
|
|
|
|
|
2014-05-12 18:00:54 +08:00
|
|
|
Layout::Type ScrollView::getLayoutType() const
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
return _innerContainer->getLayoutType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::doLayout()
|
|
|
|
{
|
|
|
|
if (!_doLayoutDirty)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_doLayoutDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ScrollView::getDescription() const
|
|
|
|
{
|
|
|
|
return "ScrollView";
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget* ScrollView::createCloneInstance()
|
|
|
|
{
|
|
|
|
return ScrollView::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::copyClonedWidgetChildren(Widget* model)
|
|
|
|
{
|
|
|
|
Layout::copyClonedWidgetChildren(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::copySpecialProperties(Widget *widget)
|
|
|
|
{
|
|
|
|
ScrollView* scrollView = dynamic_cast<ScrollView*>(widget);
|
|
|
|
if (scrollView)
|
|
|
|
{
|
|
|
|
Layout::copySpecialProperties(widget);
|
|
|
|
setDirection(scrollView->_direction);
|
2015-09-03 18:29:58 +08:00
|
|
|
setInnerContainerPosition(scrollView->getInnerContainerPosition());
|
2015-06-29 11:52:53 +08:00
|
|
|
setInnerContainerSize(scrollView->getInnerContainerSize());
|
|
|
|
_topBoundary = scrollView->_topBoundary;
|
|
|
|
_bottomBoundary = scrollView->_bottomBoundary;
|
|
|
|
_leftBoundary = scrollView->_leftBoundary;
|
|
|
|
_rightBoundary = scrollView->_rightBoundary;
|
|
|
|
_bePressed = scrollView->_bePressed;
|
2015-06-29 12:05:52 +08:00
|
|
|
_childFocusCancelOffsetInInch = scrollView->_childFocusCancelOffsetInInch;
|
2015-08-30 14:58:20 +08:00
|
|
|
_touchMoveDisplacements = scrollView->_touchMoveDisplacements;
|
|
|
|
_touchMoveTimeDeltas = scrollView->_touchMoveTimeDeltas;
|
|
|
|
_touchMovePreviousTimestamp = scrollView->_touchMovePreviousTimestamp;
|
2017-07-13 10:35:29 +08:00
|
|
|
_scrolling = scrollView->_scrolling;
|
2015-06-29 11:52:53 +08:00
|
|
|
_autoScrolling = scrollView->_autoScrolling;
|
|
|
|
_autoScrollAttenuate = scrollView->_autoScrollAttenuate;
|
|
|
|
_autoScrollStartPosition = scrollView->_autoScrollStartPosition;
|
|
|
|
_autoScrollTargetDelta = scrollView->_autoScrollTargetDelta;
|
2015-09-04 14:23:55 +08:00
|
|
|
_autoScrollTotalTime = scrollView->_autoScrollTotalTime;
|
2015-06-29 11:52:53 +08:00
|
|
|
_autoScrollAccumulatedTime = scrollView->_autoScrollAccumulatedTime;
|
2015-09-04 16:28:38 +08:00
|
|
|
_autoScrollCurrentlyOutOfBoundary = scrollView->_autoScrollCurrentlyOutOfBoundary;
|
|
|
|
_autoScrollBraking = scrollView->_autoScrollBraking;
|
|
|
|
_autoScrollBrakingStartPosition = scrollView->_autoScrollBrakingStartPosition;
|
2015-08-31 13:17:48 +08:00
|
|
|
setInertiaScrollEnabled(scrollView->_inertiaScrollEnabled);
|
2015-06-29 11:52:53 +08:00
|
|
|
setBounceEnabled(scrollView->_bounceEnabled);
|
2014-05-23 15:03:46 +08:00
|
|
|
_scrollViewEventListener = scrollView->_scrollViewEventListener;
|
|
|
|
_eventCallback = scrollView->_eventCallback;
|
2014-11-27 16:49:19 +08:00
|
|
|
_ccEventCallback = scrollView->_ccEventCallback;
|
2015-07-03 22:03:02 +08:00
|
|
|
|
|
|
|
setScrollBarEnabled(scrollView->isScrollBarEnabled());
|
|
|
|
if(isScrollBarEnabled())
|
|
|
|
{
|
2015-07-03 23:11:01 +08:00
|
|
|
if(_direction != Direction::HORIZONTAL)
|
|
|
|
{
|
|
|
|
setScrollBarPositionFromCornerForVertical(scrollView->getScrollBarPositionFromCornerForVertical());
|
|
|
|
}
|
|
|
|
if(_direction != Direction::VERTICAL)
|
|
|
|
{
|
|
|
|
setScrollBarPositionFromCornerForHorizontal(scrollView->getScrollBarPositionFromCornerForHorizontal());
|
|
|
|
}
|
2015-07-03 22:03:02 +08:00
|
|
|
setScrollBarWidth(scrollView->getScrollBarWidth());
|
|
|
|
setScrollBarColor(scrollView->getScrollBarColor());
|
|
|
|
setScrollBarAutoHideEnabled(scrollView->isScrollBarAutoHideEnabled());
|
|
|
|
setScrollBarAutoHideTime(scrollView->getScrollBarAutoHideTime());
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
2015-04-15 16:37:11 +08:00
|
|
|
|
2015-07-01 11:41:47 +08:00
|
|
|
void ScrollView::initScrollBar()
|
|
|
|
{
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_direction != Direction::HORIZONTAL && _verticalScrollBar == nullptr)
|
|
|
|
{
|
|
|
|
_verticalScrollBar = ScrollViewBar::create(this, Direction::VERTICAL);
|
|
|
|
addProtectedChild(_verticalScrollBar, 2);
|
|
|
|
}
|
|
|
|
if(_direction != Direction::VERTICAL && _horizontalScrollBar == nullptr)
|
|
|
|
{
|
|
|
|
_horizontalScrollBar = ScrollViewBar::create(this, Direction::HORIZONTAL);
|
|
|
|
addProtectedChild(_horizontalScrollBar, 2);
|
|
|
|
}
|
2015-07-01 11:41:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollView::removeScrollBar()
|
|
|
|
{
|
2015-07-03 21:17:54 +08:00
|
|
|
if(_verticalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
removeProtectedChild(_verticalScrollBar);
|
|
|
|
_verticalScrollBar = nullptr;
|
|
|
|
}
|
|
|
|
if(_horizontalScrollBar != nullptr)
|
|
|
|
{
|
|
|
|
removeProtectedChild(_horizontalScrollBar);
|
|
|
|
_horizontalScrollBar = nullptr;
|
|
|
|
}
|
2015-07-01 11:41:47 +08:00
|
|
|
}
|
|
|
|
|
2014-05-23 10:59:18 +08:00
|
|
|
Widget* ScrollView::findNextFocusedWidget(cocos2d::ui::Widget::FocusDirection direction, cocos2d::ui::Widget *current)
|
|
|
|
{
|
|
|
|
if (this->getLayoutType() == Layout::Type::VERTICAL
|
2014-12-16 16:44:04 +08:00
|
|
|
|| this->getLayoutType() == Layout::Type::HORIZONTAL)
|
|
|
|
{
|
2014-05-23 10:59:18 +08:00
|
|
|
return _innerContainer->findNextFocusedWidget(direction, current);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Widget::findNextFocusedWidget(direction, current);
|
|
|
|
}
|
|
|
|
}
|
2014-03-11 17:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|