diff --git a/extensions/CocoStudio/Armature/animation/CCTween.cpp b/extensions/CocoStudio/Armature/animation/CCTween.cpp index 22893e3dd6..b66e33465f 100644 --- a/extensions/CocoStudio/Armature/animation/CCTween.cpp +++ b/extensions/CocoStudio/Armature/animation/CCTween.cpp @@ -271,28 +271,34 @@ void Tween::updateHandler() } } -void Tween::setBetween(FrameData *from, FrameData *to) +void Tween::setBetween(FrameData *from, FrameData *to, bool limit) { do { if(from->displayIndex < 0 && to->displayIndex >= 0) { _from->copy(to); - _between->subtract(to, to); + _between->subtract(to, to, limit); break; } else if(to->displayIndex < 0 && from->displayIndex >= 0) { _from->copy(from); - _between->subtract(to, to); + _between->subtract(to, to, limit); break; } _from->copy(from); - _between->subtract(from, to); + _between->subtract(from, to, limit); } while (0); + if (!from->isTween) + { + _tweenData->copy(from); + _tweenData->isTween = true; + } + arriveKeyFrame(from); } @@ -334,6 +340,11 @@ FrameData *Tween::tweenNodeTo(float percent, FrameData *node) { node = node == NULL ? _tweenData : node; + if (!_from->isTween) + { + return _from; + } + node->x = _from->x + percent * _between->x; node->y = _from->y + percent * _between->y; node->scaleX = _from->scaleX + percent * _between->scaleX; @@ -427,7 +438,7 @@ float Tween::updateFrameData(float currentPercent) _frameTweenEasing = from->tweenEasing; - setBetween(from, to); + setBetween(from, to, false); } currentPercent = _betweenDuration == 0 ? 0 : (playedTime - _totalDuration) / (float)_betweenDuration; diff --git a/extensions/CocoStudio/Armature/animation/CCTween.h b/extensions/CocoStudio/Armature/animation/CCTween.h index 6069ccb0fb..b4a64bc3ef 100644 --- a/extensions/CocoStudio/Armature/animation/CCTween.h +++ b/extensions/CocoStudio/Armature/animation/CCTween.h @@ -106,7 +106,7 @@ protected: /** * Calculate the between value of _from and _to, and give it to between frame data */ - virtual void setBetween(FrameData *from, FrameData *to); + virtual void setBetween(FrameData *from, FrameData *to, bool limit = true); /** * According to the percent to calculate current FrameData with tween effect diff --git a/extensions/CocoStudio/Armature/datas/CCDatas.cpp b/extensions/CocoStudio/Armature/datas/CCDatas.cpp index ce1839059e..38c31db4b7 100644 --- a/extensions/CocoStudio/Armature/datas/CCDatas.cpp +++ b/extensions/CocoStudio/Armature/datas/CCDatas.cpp @@ -74,7 +74,7 @@ void BaseData::copy(const BaseData *node ) } -void BaseData::subtract(BaseData *from, BaseData *to) +void BaseData::subtract(BaseData *from, BaseData *to, bool limit) { x = to->x - from->x; y = to->y - from->y; @@ -98,22 +98,25 @@ void BaseData::subtract(BaseData *from, BaseData *to) isUseColorInfo = false; } - if (skewX > M_PI) - { - skewX -= (float)CC_DOUBLE_PI; - } - if (skewX < -M_PI) - { - skewX += (float)CC_DOUBLE_PI; - } + if (limit) + { + if (skewX > M_PI) + { + skewX -= (float)CC_DOUBLE_PI; + } + if (skewX < -M_PI) + { + skewX += (float)CC_DOUBLE_PI; + } - if (skewY > M_PI) - { - skewY -= (float)CC_DOUBLE_PI; - } - if (skewY < -M_PI) - { - skewY += (float)CC_DOUBLE_PI; + if (skewY > M_PI) + { + skewY -= (float)CC_DOUBLE_PI; + } + if (skewY < -M_PI) + { + skewY += (float)CC_DOUBLE_PI; + } } if (to->tweenRotate) @@ -121,6 +124,7 @@ void BaseData::subtract(BaseData *from, BaseData *to) skewX += to->tweenRotate; skewY -= to->tweenRotate; } + } void BaseData::setColor(const Color4B &color) @@ -261,6 +265,7 @@ FrameData::FrameData(void) : frameID(0) , duration(1) , tweenEasing(Linear) + , isTween(true) , displayIndex(0) , blendType(BLEND_NORMAL) diff --git a/extensions/CocoStudio/Armature/datas/CCDatas.h b/extensions/CocoStudio/Armature/datas/CCDatas.h index 7b69e9c438..be2b67e45c 100644 --- a/extensions/CocoStudio/Armature/datas/CCDatas.h +++ b/extensions/CocoStudio/Armature/datas/CCDatas.h @@ -87,7 +87,7 @@ public: * @param from from BaseData * @param to to BaseData */ - virtual void subtract(BaseData *from, BaseData *to); + virtual void subtract(BaseData *from, BaseData *to, bool limit); virtual void setColor(const Color4B &color); virtual Color4B getColor(); @@ -342,6 +342,7 @@ public: int frameID; int duration; //! The frame will last duration frames CCTweenType tweenEasing; //! Every frame's tween easing effect + bool isTween; //! Whether it's a tween key frame /** * The current display index when change to this frame. diff --git a/extensions/CocoStudio/Armature/utils/CCArmatureDefine.h b/extensions/CocoStudio/Armature/utils/CCArmatureDefine.h index 488bb0a1cc..fdf82a43c0 100644 --- a/extensions/CocoStudio/Armature/utils/CCArmatureDefine.h +++ b/extensions/CocoStudio/Armature/utils/CCArmatureDefine.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include "ExtensionMacros.h" #define VERSION_COMBINED 0.30f - +#define VERSION_CHANGE_ROTATION_RANGE 1.0f #ifndef AUTO_ADD_SPRITE_FRAME_NAME_PREFIX #define AUTO_ADD_SPRITE_FRAME_NAME_PREFIX 0 diff --git a/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp index a9c7830706..76d56a4b8d 100644 --- a/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp +++ b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp @@ -101,6 +101,7 @@ static const char *A_RED_OFFSET = "rM"; static const char *A_GREEN_OFFSET = "gM"; static const char *A_BLUE_OFFSET = "bM"; static const char *A_COLOR_TRANSFORM = "colorTransform"; +static const char *A_TWEEN_FRAME = "tweenFrame"; //static const char *A_ROTATION = "rotation"; //static const char *A_USE_COLOR_INFO = "uci"; @@ -853,6 +854,28 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov } + //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) + CCFrameData **frames = (CCFrameData **)movBoneData->frameList.data->arr; + for (int i = movBoneData->frameList.count() - 1; i >= 0; i--) + { + if (i > 0) + { + float difSkewX = frames[i]->skewX - frames[i - 1]->skewX; + float difSkewY = frames[i]->skewY - frames[i - 1]->skewY; + + if (difSkewX < -M_PI || difSkewX > M_PI) + { + frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI; + } + + if (difSkewY < -M_PI || difSkewY > M_PI) + { + frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI; + } + } + } + + // FrameData *frameData = new FrameData(); frameData->copy((FrameData *)movBoneData->frameList.getLastObject()); @@ -1405,6 +1428,31 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::JsonDictionary &json) delete dic; } + + if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) + { + //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) + CCFrameData **frames = (CCFrameData **)movementBoneData->frameList.data->arr; + for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--) + { + if (i > 0) + { + float difSkewX = frames[i]->skewX - frames[i - 1]->skewX; + float difSkewY = frames[i]->skewY - frames[i - 1]->skewY; + + if (difSkewX < -M_PI || difSkewX > M_PI) + { + frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI; + } + + if (difSkewY < -M_PI || difSkewY > M_PI) + { + frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI; + } + } + } + } + if (s_CocoStudioVersion < VERSION_COMBINED) { if (movementBoneData->frameList.count() > 0) @@ -1430,6 +1478,7 @@ FrameData *DataReaderHelper::decodeFrame(cs::JsonDictionary &json) frameData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear); frameData->displayIndex = json.getItemIntValue(A_DISPLAY_INDEX, 0); frameData->blendType = (BlendType)json.getItemIntValue(A_BLEND_TYPE, 0); + frameData->isTween = (bool)json.getItemBoolvalue(A_TWEEN_FRAME, true); const char *event = json.getItemStringValue(A_EVENT); if (event != NULL) diff --git a/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.cpp b/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.cpp index e2b7a69ceb..bc34480328 100644 --- a/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.cpp +++ b/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.cpp @@ -56,4 +56,9 @@ bool UIRootWidget::init() return false; } +const char* UIRootWidget::getDescription() const +{ + return "RootWidget"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.h b/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.h index 59ba41a498..c08a75f457 100644 --- a/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.h +++ b/extensions/CocoStudio/GUI/BaseClasses/UIRootWidget.h @@ -46,6 +46,11 @@ public: * Allocates and initializes a widget. */ static UIRootWidget* create(); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: //initializes state of widget. virtual bool init(); diff --git a/extensions/CocoStudio/GUI/BaseClasses/UIWidget.cpp b/extensions/CocoStudio/GUI/BaseClasses/UIWidget.cpp index 78584293a0..3a64c4667a 100644 --- a/extensions/CocoStudio/GUI/BaseClasses/UIWidget.cpp +++ b/extensions/CocoStudio/GUI/BaseClasses/UIWidget.cpp @@ -1158,6 +1158,11 @@ LayoutParameter* UIWidget::getLayoutParameter() return _layoutParameter; } +const char* UIWidget::getDescription() const +{ + return "Widget"; +} + /*temp action*/ void UIWidget::setActionTag(int tag) { diff --git a/extensions/CocoStudio/GUI/BaseClasses/UIWidget.h b/extensions/CocoStudio/GUI/BaseClasses/UIWidget.h index 4600eea4b7..ce3c9e59a8 100644 --- a/extensions/CocoStudio/GUI/BaseClasses/UIWidget.h +++ b/extensions/CocoStudio/GUI/BaseClasses/UIWidget.h @@ -875,6 +875,11 @@ public: virtual void onEnter(); virtual void onExit(); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; + /*temp action*/ void setActionTag(int tag); int getActionTag(); diff --git a/extensions/CocoStudio/GUI/Layouts/Layout.cpp b/extensions/CocoStudio/GUI/Layouts/Layout.cpp index 17e90a2108..a32aaf6cb6 100644 --- a/extensions/CocoStudio/GUI/Layouts/Layout.cpp +++ b/extensions/CocoStudio/GUI/Layouts/Layout.cpp @@ -425,6 +425,11 @@ const Size& Layout::getContentSize() const return _renderer->getContentSize(); } +const char* Layout::getDescription() const +{ + return "Layout"; +} + RectClippingNode::RectClippingNode(): m_pInnerStencil(NULL), _enabled(true), diff --git a/extensions/CocoStudio/GUI/Layouts/Layout.h b/extensions/CocoStudio/GUI/Layouts/Layout.h index 6b29af43a4..9afa9f539c 100644 --- a/extensions/CocoStudio/GUI/Layouts/Layout.h +++ b/extensions/CocoStudio/GUI/Layouts/Layout.h @@ -179,6 +179,10 @@ public: */ virtual const Size& getContentSize() const; + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: //override "init" method of widget. virtual bool init(); diff --git a/extensions/CocoStudio/GUI/System/UIInputManager.cpp b/extensions/CocoStudio/GUI/System/UIInputManager.cpp index b1ed1668a7..21371d481a 100644 --- a/extensions/CocoStudio/GUI/System/UIInputManager.cpp +++ b/extensions/CocoStudio/GUI/System/UIInputManager.cpp @@ -45,7 +45,6 @@ _rootWidget(NULL) UIInputManager::~UIInputManager() { - CCLOG("~UIInputManager"); _manageredWidget->removeAllObjects(); CC_SAFE_RELEASE_NULL(_manageredWidget); _checkedDoubleClickWidget->removeAllObjects(); @@ -177,9 +176,7 @@ void UIInputManager::onTouchEnd(Touch* touch) { UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[i]); hitWidget->onTouchEnded(_touchEndedPoint); - CCLOG("widget touch end"); } - CCLOG("_selectedWidgets remove widgets"); _selectedWidgets->removeAllObjects(); } diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.cpp b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.cpp index 01e6403700..d533fcd6c2 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.cpp @@ -28,67 +28,35 @@ NS_CC_EXT_BEGIN UIDragPanel::UIDragPanel() -: m_pInnerContainer(NULL) -, m_bTouchPressed(false) -, m_bTouchMoved(false) -, m_bTouchReleased(false) -, m_bTouchCanceld(false) -, m_touchStartNodeSpace(Point::ZERO) -, m_touchStartWorldSpace(Point::ZERO) -, m_touchEndWorldSpace(Point::ZERO) -, m_fSlidTime(0.0f) -, m_eMoveType(DRAGPANEL_MOVE_TYPE_AUTOMOVE) -, m_fAutoMoveDuration(0.5f) -, m_fAutoMoveEaseRate(2.0f) -, m_eBerthDirection(DRAGPANEL_BERTH_DIR_NONE) -, m_pBerthToLeftListener(NULL) -, m_pfnBerthToLeftSelector(NULL) -, m_pBerthToRightListener(NULL) -, m_pfnBerthToRightSelector(NULL) -, m_pBerthToTopListener(NULL) -, m_pfnBerthToTopSelector(NULL) -, m_pBerthToBottomListener(NULL) -, m_pfnBerthToBottomSelector(NULL) -, m_pBerthToLeftBottomListener(NULL) -, m_pfnBerthToLeftBottomSelector(NULL) -, m_pBerthToLeftTopListener(NULL) -, m_pfnBerthToLeftTopSelector(NULL) -, m_pBerthToRightBottomListener(NULL) -, m_pfnBerthToRightBottomSelector(NULL) -, m_pBerthToRightTopListener(NULL) -, m_pfnBerthToRightTopSelector(NULL) -, m_bBounceEnable(false) -, m_eBounceDirection(DRAGPANEL_BOUNCE_DIR_NONE) -, m_fBounceDuration(0.5f) -, m_fBounceEaseRate(2.0f) -, m_pBounceOverListener(NULL) -, m_pfnBounceOverSelector(NULL) -, m_pBounceToLeftBottomListener(NULL) -, m_pfnBounceToLeftBottomSelector(NULL) -, m_pBounceToLeftTopListener(NULL) -, m_pfnBounceToLeftTopSelector(NULL) -, m_pBounceToRightBottomListener(NULL) -, m_pfnBounceToRightBottomSelector(NULL) -, m_pBounceToRightTopListener(NULL) -, m_pfnBounceToRightTopSelector(NULL) -, m_pBounceToLeftListener(NULL) -, m_pfnBounceToLeftSelector(NULL) -, m_pBounceToTopListener(NULL) -, m_pfnBounceToTopSelector(NULL) -, m_pBounceToRightListener(NULL) -, m_pfnBounceToRightSelector(NULL) -, m_pBounceToBottomListener(NULL) -, m_pfnBounceToBottomSelector(NULL) -, m_bRunningAction(false) -, m_nActionType(0) -, m_pActionWidget(NULL) -, m_fDuration(0.0f) -, m_elapsed(0.0f) -, m_bFirstTick(false) -, m_positionDelta(Point::ZERO) -, m_startPosition(Point::ZERO) -, m_previousPosition(Point::ZERO) -, m_endPosition(Point::ZERO) +: _innerContainer(NULL) +, _touchPressed(false) +, _touchMoved(false) +, _touchReleased(false) +, _touchCanceld(false) +, _touchStartNodeSpace(Point::ZERO) +, _touchStartWorldSpace(Point::ZERO) +, _touchEndWorldSpace(Point::ZERO) +, _slidTime(0.0f) +, _moveType(DRAGPANEL_MOVE_TYPE_AUTOMOVE) +, _autoMoveDuration(0.5f) +, _autoMoveEaseRate(2.0f) +, _eventLister(NULL) +, _eventSelector(NULL) +, _berthDirection(DRAGPANEL_BERTH_DIR_NONE) +, _bounceEnable(false) +, _bounceDirection(DRAGPANEL_BOUNCE_DIR_NONE) +, _bounceDuration(0.5f) +, _bounceEaseRate(2.0f) +, _runningAction(false) +, _actionType(0) +, _actionWidget(NULL) +, _duration(0.0f) +, _elapsed(0.0f) +, _firstTick(false) +, _positionDelta(Point::ZERO) +, _startPosition(Point::ZERO) +, _previousPosition(Point::ZERO) +, _endPosition(Point::ZERO) { } @@ -126,8 +94,8 @@ void UIDragPanel::initRenderer() { Layout::initRenderer(); - m_pInnerContainer = Layout::create(); - Layout::addChild(m_pInnerContainer); + _innerContainer = Layout::create(); + Layout::addChild(_innerContainer); } @@ -139,7 +107,7 @@ void UIDragPanel::releaseResoures() _renderer->removeFromParentAndCleanup(true); _renderer->release(); - Layout::removeChild(m_pInnerContainer); + Layout::removeChild(_innerContainer); _children->release(); } @@ -176,7 +144,7 @@ void UIDragPanel::onTouchLongClicked(const Point &touchPoint) void UIDragPanel::update(float dt) { // widget action - if (m_bRunningAction) + if (_runningAction) { if (actionIsDone()) { @@ -194,14 +162,14 @@ void UIDragPanel::update(float dt) bool UIDragPanel::addChild(UIWidget *widget) { - m_pInnerContainer->addChild(widget); + _innerContainer->addChild(widget); return true; } bool UIDragPanel::removeChild(UIWidget *child) { bool value = false; - if (m_pInnerContainer->removeChild(child)) + if (_innerContainer->removeChild(child)) { value = true; } @@ -211,28 +179,28 @@ bool UIDragPanel::removeChild(UIWidget *child) void UIDragPanel::removeAllChildren() { - m_pInnerContainer->removeAllChildren(); + _innerContainer->removeAllChildren(); } Array* UIDragPanel::getChildren() { - return m_pInnerContainer->getChildren(); + return _innerContainer->getChildren(); } void UIDragPanel::onSizeChanged() { Layout::onSizeChanged(); - Size innerSize = m_pInnerContainer->getSize(); + Size innerSize = _innerContainer->getSize(); float orginInnerSizeWidth = innerSize.width; float orginInnerSizeHeight = innerSize.height; float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width); float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height); - m_pInnerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); + _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); } const Size& UIDragPanel::getInnerContainerSize() const { - return m_pInnerContainer->getContentSize(); + return _innerContainer->getContentSize(); } void UIDragPanel::setInnerContainerSize(const cocos2d::Size &size) @@ -255,20 +223,20 @@ void UIDragPanel::setInnerContainerSize(const cocos2d::Size &size) { innerSizeHeight = size.height; } - m_pInnerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); - m_pInnerContainer->setPosition(Point(0, _size.height - m_pInnerContainer->getSize().height)); + _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); + _innerContainer->setPosition(Point(0, _size.height - _innerContainer->getSize().height)); } const Point& UIDragPanel::getInnerContainerPosition() const { - return m_pInnerContainer->getPosition(); + return _innerContainer->getPosition(); } void UIDragPanel::setInnerContainerPosition(const Point &point, bool animated) { - Point delta = point - m_pInnerContainer->getPosition(); + Point delta = point - _innerContainer->getPosition(); -// Point delta = ccpSub(point, m_pInnerContainer->getPosition()); +// Point delta = ccpSub(point, _innerContainer->getPosition()); setInnerContainerOffset(delta, animated); } @@ -282,8 +250,8 @@ void UIDragPanel::setInnerContainerOffset(const Point &offset, bool animated) { delta = calculateToBoundaryDeltaPosition(delta); } - actionStartWithWidget(m_pInnerContainer); - moveByWithDuration(m_fAutoMoveDuration, delta); + actionStartWithWidget(_innerContainer); + moveByWithDuration(_autoMoveDuration, delta); } else { @@ -312,18 +280,18 @@ void UIDragPanel::handlePressLogic(const Point &touchPoint) // check inner rect < drag panel rect if (checkContainInnerRect()) { - m_bTouchPressed = false; + _touchPressed = false; return; } - m_bTouchPressed = true; - m_bTouchMoved = false; - m_bTouchReleased = false; - m_bTouchCanceld = false; + _touchPressed = true; + _touchMoved = false; + _touchReleased = false; + _touchCanceld = false; - if (m_bRunningAction) + if (_runningAction) { - switch (m_eMoveType) + switch (_moveType) { case DRAGPANEL_MOVE_TYPE_AUTOMOVE: stopAutoMove(); @@ -331,7 +299,7 @@ void UIDragPanel::handlePressLogic(const Point &touchPoint) break; case DRAGPANEL_MOVE_TYPE_BOUNCE: - m_bTouchPressed = false; + _touchPressed = false; break; default: @@ -340,39 +308,39 @@ void UIDragPanel::handlePressLogic(const Point &touchPoint) } Point nsp = _renderer->convertToNodeSpace(touchPoint); - m_touchStartNodeSpace = nsp; + _touchStartNodeSpace = nsp; - m_touchStartWorldSpace = touchPoint; + _touchStartWorldSpace = touchPoint; } void UIDragPanel::handleMoveLogic(const Point &touchPoint) { - if (!m_bTouchPressed) + if (!_touchPressed) { return; } // check touch out of drag panel boundary - if (m_bTouchCanceld) + if (_touchCanceld) { return; } - m_bTouchMoved = true; + _touchMoved = true; Point nsp = _renderer->convertToNodeSpace(touchPoint); - Point delta = nsp - m_touchStartNodeSpace; -// Point delta = ccpSub(nsp, m_touchStartNodeSpace); - m_touchStartNodeSpace = nsp; + Point delta = nsp - _touchStartNodeSpace; +// Point delta = ccpSub(nsp, _touchStartNodeSpace); + _touchStartNodeSpace = nsp; // reset berth dir to none - if (!m_bBounceEnable) + if (!_bounceEnable) { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_NONE; + _berthDirection = DRAGPANEL_BERTH_DIR_NONE; } // check will berth (bounce disable) - if (!m_bBounceEnable) + if (!_bounceEnable) { if (checkToBoundaryWithDeltaPosition(delta)) { @@ -382,16 +350,16 @@ void UIDragPanel::handleMoveLogic(const Point &touchPoint) // move moveWithDelta(delta); // check bounce or berth - if (m_bBounceEnable) + if (_bounceEnable) { // bounce if (!hitTest(touchPoint)) { - m_bTouchMoved = false; + _touchMoved = false; if (checkNeedBounce()) { - m_bTouchCanceld = true; + _touchCanceld = true; startBounce(); } } @@ -408,25 +376,25 @@ void UIDragPanel::handleMoveLogic(const Point &touchPoint) void UIDragPanel::handleReleaseLogic(const Point &touchPoint) { - if (!m_bTouchPressed) + if (!_touchPressed) { return; } - m_bTouchPressed = false; - m_bTouchMoved = false; - m_bTouchReleased = true; - m_bTouchCanceld = false; + _touchPressed = false; + _touchMoved = false; + _touchReleased = true; + _touchCanceld = false; // check touch out of drag panel boundary - if (m_bTouchCanceld) + if (_touchCanceld) { return; } if (hitTest(touchPoint)) { - m_touchEndWorldSpace = touchPoint; + _touchEndWorldSpace = touchPoint; startAutoMove(); } } @@ -467,9 +435,9 @@ void UIDragPanel::interceptTouchEvent(int handleState, UIWidget *sender, const P void UIDragPanel::recordSlidTime(float dt) { - if (m_bTouchPressed) + if (_touchPressed) { - m_fSlidTime += dt; + _slidTime += dt; } } @@ -478,8 +446,8 @@ bool UIDragPanel::checkContainInnerRect() { float width = _size.width; float height = _size.height; - float innerWidth = m_pInnerContainer->getSize().width; - float innerHeight = m_pInnerContainer->getSize().height; + float innerWidth = _innerContainer->getSize().width; + float innerHeight = _innerContainer->getSize().height; if (innerWidth <= width && innerHeight <= height) { @@ -492,15 +460,15 @@ bool UIDragPanel::checkContainInnerRect() // move void UIDragPanel::moveWithDelta(const Point &delta) { - Point newPos = m_pInnerContainer->getPosition() + delta; -// Point newPos = ccpAdd(m_pInnerContainer->getPosition(), delta); - m_pInnerContainer->setPosition(newPos); + Point newPos = _innerContainer->getPosition() + delta; +// Point newPos = ccpAdd(_innerContainer->getPosition(), delta); + _innerContainer->setPosition(newPos); } // auto move void UIDragPanel::autoMove() { - if (m_bBounceEnable) + if (_bounceEnable) { if (checkNeedBounce()) { @@ -517,47 +485,47 @@ void UIDragPanel::autoMoveOver() if (checkBerth()) { berthEvent(); - m_eBerthDirection = DRAGPANEL_BERTH_DIR_NONE; + _berthDirection = DRAGPANEL_BERTH_DIR_NONE; } } void UIDragPanel::startAutoMove() { - m_eMoveType = DRAGPANEL_MOVE_TYPE_AUTOMOVE; + _moveType = DRAGPANEL_MOVE_TYPE_AUTOMOVE; actionStop(); - Point delta = m_touchEndWorldSpace - m_touchStartWorldSpace; -// Point delta = ccpSub(m_touchEndWorldSpace, m_touchStartWorldSpace); - delta.x /= m_fSlidTime * 60; - delta.y /= m_fSlidTime * 60; - m_fSlidTime = 0.0; + Point delta = _touchEndWorldSpace - _touchStartWorldSpace; +// Point delta = ccpSub(m_touchEndWorldSpace, _touchStartWorldSpace); + delta.x /= _slidTime * 60; + delta.y /= _slidTime * 60; + _slidTime = 0.0; // bounceEnable is disable - if (!m_bBounceEnable) + if (!_bounceEnable) { if (checkToBoundaryWithDeltaPosition(delta)) { delta = calculateToBoundaryDeltaPosition(delta); } } - actionStartWithWidget(m_pInnerContainer); - moveByWithDuration(m_fAutoMoveDuration, delta); + actionStartWithWidget(_innerContainer); + moveByWithDuration(_autoMoveDuration, delta); } void UIDragPanel::stopAutoMove() { - m_eMoveType = DRAGPANEL_MOVE_TYPE_NONE; + _moveType = DRAGPANEL_MOVE_TYPE_NONE; } void UIDragPanel::setAutoMoveDuration(float duration) { - m_fAutoMoveDuration = duration; + _autoMoveDuration = duration; } void UIDragPanel::setAutoMoveEaseRate(float rate) { - m_fAutoMoveEaseRate = rate; + _autoMoveEaseRate = rate; } // berth @@ -566,10 +534,10 @@ void UIDragPanel::setAutoMoveEaseRate(float rate) bool UIDragPanel::checkToBoundaryWithDeltaPosition(const Point& delta) { - float innerLeft = m_pInnerContainer->getLeftInParent(); - float innerTop = m_pInnerContainer->getTopInParent(); - float innerRight = m_pInnerContainer->getRightInParent(); - float innerBottom = m_pInnerContainer->getBottomInParent(); + float innerLeft = _innerContainer->getLeftInParent(); + float innerTop = _innerContainer->getTopInParent(); + float innerRight = _innerContainer->getRightInParent(); + float innerBottom = _innerContainer->getBottomInParent(); float left = 0; float top = _size.height; @@ -629,10 +597,10 @@ bool UIDragPanel::checkToBoundaryWithDeltaPosition(const Point& delta) Point UIDragPanel::calculateToBoundaryDeltaPosition(const Point& paramDelta) { - float innerLeft = m_pInnerContainer->getLeftInParent(); - float innerTop = m_pInnerContainer->getTopInParent(); - float innerRight = m_pInnerContainer->getRightInParent(); - float innerBottom = m_pInnerContainer->getBottomInParent(); + float innerLeft = _innerContainer->getLeftInParent(); + float innerTop = _innerContainer->getTopInParent(); + float innerRight = _innerContainer->getRightInParent(); + float innerBottom = _innerContainer->getBottomInParent(); float left = 0; float top = _size.height; @@ -683,16 +651,16 @@ Point UIDragPanel::calculateToBoundaryDeltaPosition(const Point& paramDelta) bool UIDragPanel::isBerth() { - return m_eBerthDirection != DRAGPANEL_BERTH_DIR_NONE; + return _berthDirection != DRAGPANEL_BERTH_DIR_NONE; } // check berth bool UIDragPanel::checkBerth() { - float innerLeft = m_pInnerContainer->getLeftInParent(); - float innerTop = m_pInnerContainer->getTopInParent(); - float innerRight = m_pInnerContainer->getRightInParent(); - float innerBottom = m_pInnerContainer->getBottomInParent(); + float innerLeft = _innerContainer->getLeftInParent(); + float innerTop = _innerContainer->getTopInParent(); + float innerRight = _innerContainer->getRightInParent(); + float innerBottom = _innerContainer->getBottomInParent(); float left = 0; float top = _size.height; @@ -701,38 +669,38 @@ bool UIDragPanel::checkBerth() if (innerLeft == left && innerBottom == bottom) // left bottom { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_LEFTBOTTOM; + _berthDirection = DRAGPANEL_BERTH_DIR_LEFTBOTTOM; } else if (innerLeft == left && innerTop == top) // left top { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_LFETTOP; + _berthDirection = DRAGPANEL_BERTH_DIR_LFETTOP; } else if (innerRight == right && innerBottom == bottom) // right bottom { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_RIGHTBOTTOM; + _berthDirection = DRAGPANEL_BERTH_DIR_RIGHTBOTTOM; } else if (innerRight == right && innerTop == top) // right top { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_RIGHTTOP; + _berthDirection = DRAGPANEL_BERTH_DIR_RIGHTTOP; } else if (innerLeft == left) // left { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_LEFT; + _berthDirection = DRAGPANEL_BERTH_DIR_LEFT; } else if (innerRight == right) // right { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_RIGHT; + _berthDirection = DRAGPANEL_BERTH_DIR_RIGHT; } else if (innerTop == top) // top { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_TOP; + _berthDirection = DRAGPANEL_BERTH_DIR_TOP; } else if (innerBottom == bottom) // bottom { - m_eBerthDirection = DRAGPANEL_BERTH_DIR_BOTTOM; + _berthDirection = DRAGPANEL_BERTH_DIR_BOTTOM; } - if (m_eBerthDirection != DRAGPANEL_BERTH_DIR_NONE) + if (_berthDirection != DRAGPANEL_BERTH_DIR_NONE) { return true; } @@ -742,7 +710,7 @@ bool UIDragPanel::checkBerth() void UIDragPanel::berthEvent() { - switch (m_eBerthDirection) + switch (_berthDirection) { case DRAGPANEL_BERTH_DIR_LEFTBOTTOM: berthToLeftBottomEvent(); @@ -783,134 +751,91 @@ void UIDragPanel::berthEvent() void UIDragPanel::berthToLeftBottomEvent() { - if (m_pBerthToLeftBottomListener && m_pfnBerthToLeftBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToLeftBottomListener->*m_pfnBerthToLeftBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_LEFTBOTTOM); } } void UIDragPanel::berthToLeftTopEvent() { - if (m_pBerthToLeftTopListener && m_pfnBerthToLeftTopSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToLeftTopListener->*m_pfnBerthToLeftTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_LFETTOP); } } void UIDragPanel::berthToRightBottomEvent() { - if (m_pBerthToRightBottomListener && m_pfnBerthToRightBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToRightBottomListener->*m_pfnBerthToRightBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM); } } void UIDragPanel::berthToRightTopEvent() { - if (m_pBerthToRightTopListener && m_pfnBerthToRightTopSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToRightTopListener->*m_pfnBerthToRightTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_RIGHTTOP); } } void UIDragPanel::berthToLeftEvent() { - if (m_pBerthToLeftListener && m_pfnBerthToLeftSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToLeftListener->*m_pfnBerthToLeftSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_LEFT); } } void UIDragPanel::berthToTopEvent() { - if (m_pBerthToTopListener && m_pfnBerthToTopSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToTopListener->*m_pfnBerthToTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_TOP); } } void UIDragPanel::berthToRightEvent() { - if (m_pBerthToRightListener && m_pfnBerthToRightSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToRightListener->*m_pfnBerthToRightSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_RIGHT); } } void UIDragPanel::berthToBottomEvent() { - if (m_pBerthToBottomListener && m_pfnBerthToBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBerthToBottomListener->*m_pfnBerthToBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BERTH_BOTTOM); } } -void UIDragPanel::addBerthToLeftBottomEvent(Object *target, SEL_DragPanelBerthToLeftBottomEvent selector) +void UIDragPanel::addEventListener(Object *target, SEL_DragPanelEvent selector) { - m_pBerthToLeftBottomListener = target; - m_pfnBerthToLeftBottomSelector = selector; + _eventLister = target; + _eventSelector = selector; } -void UIDragPanel::addBerthToLeftTopEvent(Object *target, SEL_DragPanelBerthToLeftTopEvent selector) -{ - m_pBerthToLeftTopListener = target; - m_pfnBerthToLeftTopSelector = selector; -} - -void UIDragPanel::addBerthToRightBottomEvent(Object *target, SEL_DragPanelBerthToRightBottomEvent selector) -{ - m_pBerthToRightBottomListener = target; - m_pfnBerthToRightBottomSelector = selector; -} - -void UIDragPanel::addBerthToRightTopEvent(Object *target, SEL_DragPanelBerthToRightTopEvent selector) -{ - m_pBerthToRightTopListener = target; - m_pfnBerthToRightTopSelector = selector; -} - -void UIDragPanel::addBerthToLeftEvent(Object *target, SEL_DragPanelBerthToLeftEvent selector) -{ - m_pBerthToLeftListener = target; - m_pfnBerthToLeftSelector = selector; -} - -void UIDragPanel::addBerthToTopEvent(Object *target, SEL_DragPanelBerthToTopEvent selector) -{ - m_pBerthToTopListener = target; - m_pfnBerthToTopSelector = selector; -} - -void UIDragPanel::addBerthToRightEvent(Object *target, SEL_DragPanelBerthToRightEvent selector) -{ - m_pBerthToRightListener = target; - m_pfnBerthToRightSelector = selector; -} - -void UIDragPanel::addBerthToBottomEvent(Object *target, SEL_DragPanelBerthToBottomEvent selector) -{ - m_pBerthToBottomListener = target; - m_pfnBerthToBottomSelector = selector; -} - - // bounce bool UIDragPanel::isBounceEnable() { - return m_bBounceEnable; + return _bounceEnable; } void UIDragPanel::setBounceEnable(bool bounce) { - m_bBounceEnable = bounce; + _bounceEnable = bounce; } bool UIDragPanel::checkNeedBounce() { - float innerLeft = m_pInnerContainer->getLeftInParent(); - float innerTop = m_pInnerContainer->getTopInParent(); - float innerRight = m_pInnerContainer->getRightInParent(); - float innerBottom = m_pInnerContainer->getBottomInParent(); + float innerLeft = _innerContainer->getLeftInParent(); + float innerTop = _innerContainer->getTopInParent(); + float innerRight = _innerContainer->getRightInParent(); + float innerBottom = _innerContainer->getBottomInParent(); float left = 0; float top = _size.height; @@ -930,27 +855,27 @@ bool UIDragPanel::checkNeedBounce() void UIDragPanel::startBounce() { - if (m_eMoveType == DRAGPANEL_MOVE_TYPE_BOUNCE) + if (_moveType == DRAGPANEL_MOVE_TYPE_BOUNCE) { return; } actionStop(); - m_eMoveType = DRAGPANEL_MOVE_TYPE_BOUNCE; + _moveType = DRAGPANEL_MOVE_TYPE_BOUNCE; bounceToCorner(); } void UIDragPanel::stopBounce() { - m_eMoveType = DRAGPANEL_MOVE_TYPE_NONE; + _moveType = DRAGPANEL_MOVE_TYPE_NONE; } void UIDragPanel::bounceToCorner() { - float innerLeft = m_pInnerContainer->getLeftInParent(); - float innerTop = m_pInnerContainer->getTopInParent(); - float innerRight = m_pInnerContainer->getRightInParent(); - float innerBottom = m_pInnerContainer->getBottomInParent(); + float innerLeft = _innerContainer->getLeftInParent(); + float innerTop = _innerContainer->getTopInParent(); + float innerRight = _innerContainer->getRightInParent(); + float innerBottom = _innerContainer->getBottomInParent(); float width = _size.width; float height = _size.height; @@ -972,7 +897,7 @@ void UIDragPanel::bounceToCorner() to_x = left; to_y = bottom; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM; } else if (innerLeft > left && innerTop < top) // left top { @@ -981,7 +906,7 @@ void UIDragPanel::bounceToCorner() to_x = left; to_y = top; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTTOP; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFTTOP; } else if (innerRight < right && innerBottom > bottom) // right bottom { @@ -990,7 +915,7 @@ void UIDragPanel::bounceToCorner() to_x = right; to_y = bottom; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTBOTTOM; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTBOTTOM; } else if (innerRight < right && innerTop < top) // right top { @@ -999,7 +924,7 @@ void UIDragPanel::bounceToCorner() to_x = right; to_y = top; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTTOP; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHTTOP; } else if (innerLeft > left) // left { @@ -1008,7 +933,7 @@ void UIDragPanel::bounceToCorner() to_x = left; to_y = from_y; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_LEFT; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_LEFT; } else if (innerTop < top) // top { @@ -1017,7 +942,7 @@ void UIDragPanel::bounceToCorner() to_x = from_x; to_y = top; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_TOP; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_TOP; } else if (innerRight < right) // right { @@ -1026,7 +951,7 @@ void UIDragPanel::bounceToCorner() to_x = right; to_y = from_y; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHT; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_RIGHT; } else if (innerBottom > bottom) // bottom { @@ -1035,22 +960,20 @@ void UIDragPanel::bounceToCorner() to_x = from_x; to_y = bottom; - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_BOTTOM; + _bounceDirection = DRAGPANEL_BOUNCE_DIR_BOTTOM; } delta = Point(to_x, to_y) - Point(from_x, from_y); // delta = ccpSub(ccp(to_x, to_y), ccp(from_x, from_y)); - actionStartWithWidget(m_pInnerContainer); - moveByWithDuration(m_fBounceDuration, delta); + actionStartWithWidget(_innerContainer); + moveByWithDuration(_bounceDuration, delta); } void UIDragPanel::bounceOver() { stopBounce(); - bounceOverEvent(); - - switch (m_eBounceDirection) + switch (_bounceDirection) { case DRAGPANEL_BOUNCE_DIR_LEFTBOTTOM: bounceToLeftBottomEvent(); @@ -1088,176 +1011,114 @@ void UIDragPanel::bounceOver() break; } - m_eBounceDirection = DRAGPANEL_BOUNCE_DIR_NONE; -} - -void UIDragPanel::bounceOverEvent() -{ - if (m_pBounceOverListener && m_pfnBounceOverSelector) - { - (m_pBounceOverListener->*m_pfnBounceOverSelector)(this); - } + _bounceDirection = DRAGPANEL_BOUNCE_DIR_NONE; } void UIDragPanel::bounceToLeftBottomEvent() { - if (m_pBounceToLeftBottomListener && m_pfnBounceToLeftBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToLeftBottomListener->*m_pfnBounceToLeftBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM); } } void UIDragPanel::bounceToLeftTopEvent() { - if (m_pBounceToLeftTopListener && m_pfnBounceToLeftTopSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToLeftTopListener->*m_pfnBounceToLeftTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_LEFTTOP); } } void UIDragPanel::bounceToRightBottomEvent() { - if (m_pBounceToRightBottomListener && m_pfnBounceToRightBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToRightBottomListener->*m_pfnBounceToRightBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM); } } void UIDragPanel::bounceToRightTopEvent() { - if (m_pBounceToRightTopListener && m_pfnBounceToRightTopSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToRightTopListener->*m_pfnBounceToRightTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_RIGHTTOP); } } void UIDragPanel::bounceToLeftEvent() { - if (m_pBounceToLeftListener && m_pfnBounceToLeftSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToLeftListener->*m_pfnBounceToLeftSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_LEFT); } } void UIDragPanel::bounceToTopEvent() { - if (m_pBounceToTopListener && m_pfnBounceToTopSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToTopListener->*m_pfnBounceToTopSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_TOP); } } void UIDragPanel::bounceToRightEvent() { - if (m_pBounceToRightListener && m_pfnBounceToRightSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToRightListener->*m_pfnBounceToRightSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_RIGHT); } } void UIDragPanel::bounceToBottomEvent() { - if (m_pBounceToBottomListener && m_pfnBounceToBottomSelector) + if (_eventLister && _eventSelector) { - (m_pBounceToBottomListener->*m_pfnBounceToBottomSelector)(this); + (_eventLister->*_eventSelector)(this, DRAGPANEL_EVENT_BOUNCE_BOTTOM); } } -void UIDragPanel::addBounceOverEvent(Object *target, SEL_DragPanelBounceOverEvent selector) -{ - m_pBounceOverListener = target; - m_pfnBounceOverSelector = selector; -} - -void UIDragPanel::addBounceToLeftBottomEvent(Object *target, SEL_DragPanelBounceToLeftBottomEvent selector) -{ - m_pBounceToLeftBottomListener = target; - m_pfnBounceToLeftBottomSelector = selector; -} - -void UIDragPanel::addBounceToLeftTopEvent(Object *target, SEL_DragPanelBounceToLeftTopEvent selector) -{ - m_pBounceToLeftTopListener = target; - m_pfnBounceToLeftTopSelector = selector; -} - -void UIDragPanel::addBounceToRightBottomEvent(Object *target, SEL_DragPanelBounceToRightBottomEvent selector) -{ - m_pBounceToRightBottomListener = target; - m_pfnBounceToRightBottomSelector = selector; -} - -void UIDragPanel::addBounceToRightTopEvent(Object *target, SEL_DragPanelBounceToRightTopEvent selector) -{ - m_pBounceToRightTopListener = target; - m_pfnBounceToRightTopSelector = selector; -} - -void UIDragPanel::addBounceToLeftEvent(Object *target, SEL_DragPanelBounceToLeftEvent selector) -{ - m_pBounceToLeftListener = target; - m_pfnBounceToLeftSelector = selector; -} - -void UIDragPanel::addBounceToTopEvent(Object *target, SEL_DragPanelBounceToTopEvent selector) -{ - m_pBounceToTopListener = target; - m_pfnBounceToTopSelector = selector; -} - -void UIDragPanel::addBounceToRightEvent(Object *target, SEL_DragPanelBounceToRightEvent selector) -{ - m_pBounceToRightListener = target; - m_pfnBounceToRightSelector = selector; -} - -void UIDragPanel::addBounceToBottomEvent(Object *target, SEL_DragPanelBounceToBottomEvent selector) -{ - m_pBounceToBottomListener = target; - m_pfnBounceToBottomSelector = selector; -} - // widget action void UIDragPanel::actionWithDuration(float duration) { - m_fDuration = duration; + _duration = duration; - if (m_fDuration == 0) + if (_duration == 0) { - m_fDuration = FLT_EPSILON; + _duration = FLT_EPSILON; } - m_elapsed = 0; - m_bFirstTick = true; + _elapsed = 0; + _firstTick = true; } bool UIDragPanel::actionIsDone() { - bool value = (m_elapsed >= m_fDuration); + bool value = (_elapsed >= _duration); return value; } void UIDragPanel::actionStartWithWidget(UIWidget *widget) { - m_bRunningAction = true; - m_pActionWidget = widget; + _runningAction = true; + _actionWidget = widget; } void UIDragPanel::actionStep(float dt) { - if (m_bFirstTick) + if (_firstTick) { - m_bFirstTick = false; - m_elapsed = 0; + _firstTick = false; + _elapsed = 0; } else { - m_elapsed += dt; + _elapsed += dt; } actionUpdate(MAX (0, - MIN(1, m_elapsed / - MAX(m_fDuration, FLT_EPSILON) + MIN(1, _elapsed / + MAX(_duration, FLT_EPSILON) ) ) ); @@ -1265,7 +1126,7 @@ void UIDragPanel::actionStep(float dt) void UIDragPanel::actionUpdate(float dt) { - switch (m_nActionType) + switch (_actionType) { case 1: // move by moveByUpdate(dt); @@ -1282,12 +1143,12 @@ void UIDragPanel::actionUpdate(float dt) void UIDragPanel::actionStop() { - m_bRunningAction = false; + _runningAction = false; } void UIDragPanel::actionDone() { - switch (m_eMoveType) + switch (_moveType) { case DRAGPANEL_MOVE_TYPE_AUTOMOVE: autoMoveOver(); @@ -1306,27 +1167,27 @@ void UIDragPanel::actionDone() void UIDragPanel::moveByWithDuration(float duration, const Point& deltaPosition) { actionWithDuration(duration); - m_positionDelta = deltaPosition; + _positionDelta = deltaPosition; moveByInit(); - m_nActionType = 1; + _actionType = 1; } void UIDragPanel::moveByInit() { - m_previousPosition = m_startPosition = m_pActionWidget->getPosition(); + _previousPosition = _startPosition = _actionWidget->getPosition(); } void UIDragPanel::moveByUpdate(float t) { float easeRate = 0.0f; - switch (m_eMoveType) + switch (_moveType) { case DRAGPANEL_MOVE_TYPE_AUTOMOVE: - easeRate = m_fAutoMoveEaseRate; + easeRate = _autoMoveEaseRate; break; case DRAGPANEL_MOVE_TYPE_BOUNCE: - easeRate = m_fBounceEaseRate; + easeRate = _bounceEaseRate; break; default: @@ -1334,19 +1195,19 @@ void UIDragPanel::moveByUpdate(float t) } t = powf(t, 1 / easeRate); - Point currentPos = m_pActionWidget->getPosition(); - Point diff = currentPos - m_previousPosition; - m_startPosition = m_startPosition + diff; -// Point diff = ccpSub(currentPos, m_previousPosition); -// m_startPosition = ccpAdd( m_startPosition, diff); + Point currentPos = _actionWidget->getPosition(); + Point diff = currentPos - _previousPosition; + _startPosition = _startPosition + diff; +// Point diff = ccpSub(currentPos, _previousPosition); +// _startPosition = ccpAdd( _startPosition, diff); -// Point newPos = ccpAdd( m_startPosition, ccpMult(m_positionDelta, t) ); - Point newPos = m_startPosition + (m_positionDelta * t); +// Point newPos = ccpAdd( _startPosition, ccpMult(_positionDelta, t) ); + Point newPos = _startPosition + (_positionDelta * t); - m_pActionWidget->setPosition(newPos); - m_previousPosition = newPos; + _actionWidget->setPosition(newPos); + _previousPosition = newPos; - switch (m_eMoveType) + switch (_moveType) { case DRAGPANEL_MOVE_TYPE_AUTOMOVE: autoMove(); @@ -1361,16 +1222,16 @@ void UIDragPanel::moveByUpdate(float t) void UIDragPanel::moveToWithDuration(float duration, const Point& position) { actionWithDuration(duration); - m_endPosition = position; + _endPosition = position; moveToInit(); - m_nActionType = 2; + _actionType = 2; } void UIDragPanel::moveToInit() { moveByInit(); - m_positionDelta = m_endPosition - m_pActionWidget->getPosition(); -// m_positionDelta = ccpSub( m_endPosition, m_pActionWidget->getPosition() ); + _positionDelta = _endPosition - _actionWidget->getPosition(); +// _positionDelta = ccpSub( _endPosition, _actionWidget->getPosition() ); } void UIDragPanel::moveToUpdate(float t) @@ -1380,7 +1241,12 @@ void UIDragPanel::moveToUpdate(float t) Layout* UIDragPanel::getInnerContainer() { - return m_pInnerContainer; + return _innerContainer; +} + +const char* UIDragPanel::getDescription() const +{ + return "DragPanel"; } NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.h b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.h index a1ba2a34ae..1538b68d54 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.h +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIDragPanel.h @@ -72,47 +72,31 @@ enum DRAGPANEL_BOUNCE_DIR DRAGPANEL_BOUNCE_DIR_BOTTOM, }; -/** - * dragpanel berth event - */ -typedef void (Object::*SEL_DragPanelBerthToLeftBottomEvent)(Object*); -#define coco_DragPane_BerthToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBerthToLeftBottomEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToLeftTopEvent)(Object*); -#define coco_DragPanel_BerthToLeftTop_selector(_SELECTOR) (SEL_DragPanelBerthToLeftTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToRightBottomEvent)(Object*); -#define coco_DragPanel_BerthToRightBottom_selector(_SELECTOR) (SEL_DragPanelBerthToRightBottomEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToRightTopEvent)(Object*); -#define coco_DragPanel_BerthToRightTop_selector(_SELECTOR) (SEL_DragPanelBerthToRightTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToLeftEvent)(Object*); -#define coco_DragPanel_BerthToLeft_selector(_SELECTOR) (SEL_DragPanelBerthToLeftEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToRightEvent)(Object*); -#define coco_DragPanel_BerthToRight_selector(_SELECTOR) (SEL_DragPanelBerthToRightEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToTopEvent)(Object*); -#define coco_DragPanel_BerthToTop_selector(_SELECTOR) (SEL_DragPanelBerthToTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBerthToBottomEvent)(Object*); -#define coco_DragPanel_BerthToBottom_selector(_SELECTOR) (SEL_DragPanelBerthToBottomEvent)(&_SELECTOR) +typedef enum +{ + DRAGPANEL_EVENT_BERTH_LEFTBOTTOM, + DRAGPANEL_EVENT_BERTH_LFETTOP, + DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM, + DRAGPANEL_EVENT_BERTH_RIGHTTOP, + DRAGPANEL_EVENT_BERTH_LEFT, + DRAGPANEL_EVENT_BERTH_TOP, + DRAGPANEL_EVENT_BERTH_RIGHT, + DRAGPANEL_EVENT_BERTH_BOTTOM, + DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM, + DRAGPANEL_EVENT_BOUNCE_LEFTTOP, + DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM, + DRAGPANEL_EVENT_BOUNCE_RIGHTTOP, + DRAGPANEL_EVENT_BOUNCE_LEFT, + DRAGPANEL_EVENT_BOUNCE_TOP, + DRAGPANEL_EVENT_BOUNCE_RIGHT, + DRAGPANEL_EVENT_BOUNCE_BOTTOM, +}DragPanelEventType; /** - * dragpanel bounce event + * dragpanel event */ -typedef void (Object::*SEL_DragPanelBounceOverEvent)(Object*); -#define coco_DragPanel_BounceOver_selector(_SELECTOR) (SEL_DragPanelBounceOverEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToLeftBottomEvent)(Object*); -#define coco_DragPanel_BounceToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBounceToLeftBottomEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToLeftTopEvent)(Object*); -#define coco_DragPanel_BounceToLeftTop_selector(_SELECTOR) (SEL_DragPanelBounceToLeftTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToRightBottomEvent)(Object*); -#define coco_DragPanel_BounceToRightBottom_selector(_SELECTOR) (SEL_DragPanelBounceToRightBottomEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToRightTopEvent)(Object*); -#define coco_DragPanel_BounceToRightTop_selector(_SELECTOR) (SEL_DragPanelBounceToRightTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToLeftEvent)(Object*); -#define coco_DragPanel_BounceToLeft_selector(_SELECTOR) (SEL_DragPanelBounceToLeftEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToTopEvent)(Object*); -#define coco_DragPanel_BounceToTop_selector(_SELECTOR) (SEL_DragPanelBounceToTopEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToRightEvent)(Object*); -#define coco_DragPanel_BounceToRight_selector(_SELECTOR) (SEL_DragPanelBounceToRightEvent)(&_SELECTOR) -typedef void (Object::*SEL_DragPanelBounceToBottomEvent)(Object*); -#define coco_DragPanel_BounceToBottom_selector(_SELECTOR) (SEL_DragPanelBounceToBottomEvent)(&_SELECTOR) +typedef void (Object::*SEL_DragPanelEvent)(Object*, DragPanelEventType); +#define dragpaneleventselector(_SELECTOR)(SEL_DragPanelEvent)(&_SELECTOR) class UIDragPanel : public Layout, public UIScrollInterface { @@ -180,17 +164,10 @@ public: bool isBerth(); /** - * berth event by direction + * event */ - void addBerthToLeftBottomEvent(Object* target, SEL_DragPanelBerthToLeftBottomEvent selector); - void addBerthToLeftTopEvent(Object* target, SEL_DragPanelBerthToLeftTopEvent selector); - void addBerthToRightBottomEvent(Object* target, SEL_DragPanelBerthToRightBottomEvent selector); - void addBerthToRightTopEvent(Object* target, SEL_DragPanelBerthToRightTopEvent selector); - void addBerthToLeftEvent(Object* target, SEL_DragPanelBerthToLeftEvent selector); - void addBerthToTopEvent(Object* target, SEL_DragPanelBerthToTopEvent selector); - void addBerthToRightEvent(Object* target, SEL_DragPanelBerthToRightEvent selector); - void addBerthToBottomEvent(Object* target, SEL_DragPanelBerthToBottomEvent selector); - + void addEventListener(Object* target, SEL_DragPanelEvent selector); + /** * get and set bounce enable */ @@ -204,18 +181,6 @@ public: * set bounce ease rate */ void setBounceEaseRate(float rate); - /** - * bounce event by dircetion - */ - void addBounceOverEvent(Object* target, SEL_DragPanelBounceOverEvent selector); - void addBounceToLeftBottomEvent(Object* target, SEL_DragPanelBounceToLeftBottomEvent selector); - void addBounceToLeftTopEvent(Object* target, SEL_DragPanelBounceToLeftTopEvent selector); - void addBounceToRightBottomEvent(Object* target, SEL_DragPanelBounceToRightBottomEvent selector); - void addBounceToRightTopEvent(Object* target, SEL_DragPanelBounceToRightTopEvent selector); - void addBounceToLeftEvent(Object* target, SEL_DragPanelBounceToLeftEvent selector); - void addBounceToTopEvent(Object* target, SEL_DragPanelBounceToTopEvent selector); - void addBounceToRightEvent(Object* target, SEL_DragPanelBounceToRightEvent selector); - void addBounceToBottomEvent(Object* target, SEL_DragPanelBounceToBottomEvent selector); /** * Gets inner container of dragpanel. @@ -226,6 +191,11 @@ public: */ Layout* getInnerContainer(); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; + protected: virtual bool init(); virtual void initRenderer(); @@ -286,7 +256,6 @@ protected: void bounceToCorner(); void bounceOver(); // bounce event - void bounceOverEvent(); void bounceToLeftBottomEvent(); void bounceToRightBottomEvent(); void bounceToLeftTopEvent(); @@ -318,94 +287,59 @@ protected: /************/ virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);}; protected: - Layout* m_pInnerContainer; + Layout* _innerContainer; /* DRAGPANEL_DIR m_eDirection; DRAGPANEL_MOVE_DIR m_eMoveDirection; */ - bool m_bTouchPressed; - bool m_bTouchMoved; - bool m_bTouchReleased; - bool m_bTouchCanceld; // check touch out of drag panel boundary + bool _touchPressed; + bool _touchMoved; + bool _touchReleased; + bool _touchCanceld; // check touch out of drag panel boundary - Point m_touchStartNodeSpace; - Point m_touchStartWorldSpace; - Point m_touchEndWorldSpace; + Point _touchStartNodeSpace; + Point _touchStartWorldSpace; + Point _touchEndWorldSpace; - float m_fSlidTime; + float _slidTime; // move type - DRAGPANEL_MOVE_TYPE m_eMoveType; + DRAGPANEL_MOVE_TYPE _moveType; // auto move - float m_fAutoMoveDuration; - float m_fAutoMoveEaseRate; + float _autoMoveDuration; + float _autoMoveEaseRate; + + // event + Object* _eventLister; + SEL_DragPanelEvent _eventSelector; // berth - DRAGPANEL_BERTH_DIR m_eBerthDirection; - - // berth event - Object* m_pBerthToLeftListener; - SEL_DragPanelBerthToLeftEvent m_pfnBerthToLeftSelector; - Object* m_pBerthToRightListener; - SEL_DragPanelBerthToRightEvent m_pfnBerthToRightSelector; - Object* m_pBerthToTopListener; - SEL_DragPanelBerthToTopEvent m_pfnBerthToTopSelector; - Object* m_pBerthToBottomListener; - SEL_DragPanelBerthToBottomEvent m_pfnBerthToBottomSelector; - Object* m_pBerthToLeftBottomListener; - SEL_DragPanelBerthToLeftBottomEvent m_pfnBerthToLeftBottomSelector; - Object* m_pBerthToLeftTopListener; - SEL_DragPanelBerthToLeftTopEvent m_pfnBerthToLeftTopSelector; - Object* m_pBerthToRightBottomListener; - SEL_DragPanelBerthToRightBottomEvent m_pfnBerthToRightBottomSelector; - Object* m_pBerthToRightTopListener; - SEL_DragPanelBerthToRightTopEvent m_pfnBerthToRightTopSelector; - + DRAGPANEL_BERTH_DIR _berthDirection; + // bounce - bool m_bBounceEnable; - DRAGPANEL_BOUNCE_DIR m_eBounceDirection; - float m_fBounceDuration; - float m_fBounceEaseRate; - - // bounce event - Object* m_pBounceOverListener; - SEL_DragPanelBounceOverEvent m_pfnBounceOverSelector; - Object* m_pBounceToLeftBottomListener; - SEL_DragPanelBounceToLeftBottomEvent m_pfnBounceToLeftBottomSelector; - Object* m_pBounceToLeftTopListener; - SEL_DragPanelBounceToLeftTopEvent m_pfnBounceToLeftTopSelector; - Object* m_pBounceToRightBottomListener; - SEL_DragPanelBounceToRightBottomEvent m_pfnBounceToRightBottomSelector; - Object* m_pBounceToRightTopListener; - SEL_DragPanelBounceToRightTopEvent m_pfnBounceToRightTopSelector; - Object* m_pBounceToLeftListener; - SEL_DragPanelBounceToLeftEvent m_pfnBounceToLeftSelector; - Object* m_pBounceToTopListener; - SEL_DragPanelBounceToTopEvent m_pfnBounceToTopSelector; - Object* m_pBounceToRightListener; - SEL_DragPanelBounceToRightEvent m_pfnBounceToRightSelector; - Object* m_pBounceToBottomListener; - SEL_DragPanelBounceToBottomEvent m_pfnBounceToBottomSelector; + bool _bounceEnable; + DRAGPANEL_BOUNCE_DIR _bounceDirection; + float _bounceDuration; + float _bounceEaseRate; + float _runningAction; + int _actionType; - float m_bRunningAction; - int m_nActionType; + UIWidget* _actionWidget; - UIWidget* m_pActionWidget; + float _duration; + float _elapsed; + bool _firstTick; - float m_fDuration; - float m_elapsed; - bool m_bFirstTick; + Point _positionDelta; + Point _startPosition; + Point _previousPosition; - Point m_positionDelta; - Point m_startPosition; - Point m_previousPosition; - - Point m_endPosition; + Point _endPosition; }; NS_CC_EXT_END diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.cpp b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.cpp index ba292aed22..27775474c5 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.cpp @@ -42,10 +42,8 @@ UIListView::UIListView() , _bePressed(false) , _slidTime(0.0f) , _childFocusCancelOffset(5.0f) -, _initChildListener(NULL) -, _initChildSelector(NULL) -, _updateChildListener(NULL) -, _updateChildSelector(NULL) +, _eventListener(NULL) +, _eventSelector(NULL) , _childPool(NULL) , _updatePool(NULL) , _dataLength(0) @@ -1431,30 +1429,30 @@ void UIListView::updateChild() void UIListView::initChildEvent() { - if (_initChildListener && _initChildSelector) + if (_eventListener && _eventSelector) { - (_initChildListener->*_initChildSelector)(this); + (_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_INIT_CHILD); } } void UIListView::updateChildEvent() { - if (_updateChildListener && _updateChildSelector) + if (_eventListener && _eventSelector) { - (_updateChildListener->*_updateChildSelector)(this); + (_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_UPDATE_CHILD); } } -void UIListView::addInitChildEvent(Object *target, SEL_ListViewInitChildEvent seletor) +void UIListView::addEventListenter(Object *target, SEL_ListViewEvent selector) { - _initChildListener = target; - _initChildSelector = seletor; + _eventListener = target; + _eventSelector = selector; } -void UIListView::addUpdateChildEvent(Object *target, SEL_ListViewUpdateChildEvent selector) +const char* UIListView::getDescription() const { - _updateChildListener = target; - _updateChildSelector = selector; + return "ListView"; } + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.h b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.h index 24a4a9edc8..658dd4482c 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.h +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIListView.h @@ -53,13 +53,17 @@ typedef enum LISTVIEW_MOVE_DIR LISTVIEW_MOVE_DIR_RIGHT, }ListViewMoveDirection; +typedef enum +{ + LISTVIEW_EVENT_INIT_CHILD, + LISTVIEW_EVENT_UPDATE_CHILD, +}ListViewEventType; + /** * list view event */ -typedef void (cocos2d::Object::*SEL_ListViewInitChildEvent)(cocos2d::Object*); -typedef void (cocos2d::Object::*SEL_ListViewUpdateChildEvent)(cocos2d::Object*); -#define coco_ListView_InitChild_selector(_SELECTOR) (SEL_ListViewInitChildEvent)(&_SELECTOR) -#define coco_ListView_UpdateChild_selector(_SELECTOR) (SEL_ListViewUpdateChildEvent)(&_SELECTOR) +typedef void (Object::*SEL_ListViewEvent)(Object*, ListViewEventType); +#define listvieweventselector(_SELECTOR)(SEL_ListViewEvent)(&_SELECTOR) class UIListView : public Layout { @@ -124,13 +128,9 @@ public: * add event call-back function */ /** - * add init child event + * add event */ - void addInitChildEvent(cocos2d::Object* target, SEL_ListViewInitChildEvent seletor); - /** - * add udpate child event - */ - void addUpdateChildEvent(cocos2d::Object* target, SEL_ListViewUpdateChildEvent selector); + void addEventListenter(cocos2d::Object* target, SEL_ListViewEvent selector); /* gui mark */ /** @@ -139,6 +139,10 @@ public: /**/ virtual void update(float dt); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual bool init(); @@ -209,10 +213,8 @@ protected: Point _moveChildPoint; float _childFocusCancelOffset; - cocos2d::Object* _initChildListener; - SEL_ListViewInitChildEvent _initChildSelector; - cocos2d::Object* _updateChildListener; - SEL_ListViewUpdateChildEvent _updateChildSelector; + Object* _eventListener; + SEL_ListViewEvent _eventSelector; Array* _childPool; Array* _updatePool; diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp index e6a215d5d3..28716b8db9 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.cpp @@ -43,8 +43,8 @@ _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDir(0), _childFocusCancelOffset(5.0f), -_pageTurningListener(NULL), -_pageTurningSelector(NULL) +_eventListener(NULL), +_eventSelector(NULL) { } @@ -548,16 +548,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const Po void UIPageView::pageTurningEvent() { - if (_pageTurningListener && _pageTurningSelector) + if (_eventListener && _eventSelector) { - (_pageTurningListener->*_pageTurningSelector)(this); + (_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING); } } -void UIPageView::addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector) +void UIPageView::addEventListener(Object *target, SEL_PageViewEvent selector) { - _pageTurningListener = target; - _pageTurningSelector = selector; + _eventListener = target; + _eventSelector = selector; } int UIPageView::getCurPageIndex() const @@ -565,4 +565,9 @@ int UIPageView::getCurPageIndex() const return _curPageIdx; } +const char* UIPageView::getDescription() const +{ + return "PageView"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.h b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.h index 6db0a85930..974f35019b 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.h +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIPageView.h @@ -30,8 +30,13 @@ NS_CC_EXT_BEGIN -typedef void (Object::*SEL_PageViewPageTurningEvent)(Object*); -#define coco_PageView_PageTurning_selector(_SELECTOR) (SEL_PageViewPageTurningEvent)(&_SELECTOR) +typedef enum +{ + PAGEVIEW_EVENT_TURNING, +}PageViewEventType; + +typedef void (Object::*SEL_PageViewEvent)(Object*, PageViewEventType); +#define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR) typedef enum { PAGEVIEW_TOUCHLEFT, @@ -110,8 +115,8 @@ public: */ int getCurPageIndex() const; - //Add call back function called when page turning. - void addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector); + // event + void addEventListener(Object *target, SEL_PageViewEvent selector); //override "removeChild" method of widget. virtual bool removeChild(UIWidget* widget); @@ -134,6 +139,10 @@ public: //override "update" method of widget. virtual void update(float dt); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual bool addChild(UIWidget* widget); virtual bool init(); @@ -170,8 +179,8 @@ protected: float _autoScrollSpeed; int _autoScrollDir; float _childFocusCancelOffset; - Object* _pageTurningListener; - SEL_PageViewPageTurningEvent _pageTurningSelector; + Object* _eventListener; + SEL_PageViewEvent _eventSelector; }; NS_CC_EXT_END diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.cpp b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.cpp index 8a8e341ad6..1a64d69778 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.cpp @@ -28,6 +28,7 @@ NS_CC_EXT_BEGIN UIScrollView::UIScrollView(): +_innerContainer(NULL), _direction(SCROLLVIEW_DIR_VERTICAL), _moveDirection(SCROLLVIEW_MOVE_DIR_NONE), _touchStartLocation(0.0f), @@ -48,15 +49,8 @@ _bePressed(false), _slidTime(0.0f), _moveChildPoint(Point::ZERO), _childFocusCancelOffset(5.0f), -_scrollToTopListener(NULL), -_scrollToTopSelector(NULL), -_scrollToBottomListener(NULL), -_scrollToBottomSelector(NULL), -_scrollToLeftListener(NULL), -_scrollToLeftSelector(NULL), -_scrollToRightListener(NULL), -_scrollToRightSelector(NULL), -_innerContainer(NULL) +_eventListener(NULL), +_eventSelector(NULL) { } @@ -609,58 +603,40 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const Point & void UIScrollView::scrollToTopEvent() { - if (_scrollToTopListener && _scrollToTopSelector) + if (_eventListener && _eventSelector) { - (_scrollToTopListener->*_scrollToTopSelector)(this); + (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); } } void UIScrollView::scrollToBottomEvent() { - if (_scrollToBottomListener && _scrollToBottomSelector) + if (_eventListener && _eventSelector) { - (_scrollToBottomListener->*_scrollToBottomSelector)(this); + (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); } } void UIScrollView::scrollToLeftEvent() { - if (_scrollToLeftListener && _scrollToLeftSelector) + if (_eventListener && _eventSelector) { - (_scrollToLeftListener->*_scrollToLeftSelector)(this); + (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); } } void UIScrollView::scrollToRightEvent() { - if (_scrollToRightListener && _scrollToRightSelector) + if (_eventListener && _eventSelector) { - (_scrollToRightListener->*_scrollToRightSelector)(this); + (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); } } -void UIScrollView::addScrollToTopEvent(Object *target, SEL_ScrollToTopEvent selector) +void UIScrollView::addEventListener(Object *target, SEL_ScrollViewEvent selector) { - _scrollToTopListener = target; - _scrollToTopSelector = selector; -} - -void UIScrollView::addScrollToBottomEvent(Object *target, SEL_ScrollToBottomEvent selector) -{ - _scrollToBottomListener = target; - _scrollToBottomSelector = selector; -} - -void UIScrollView::addScrollToLeftEvent(Object *target, SEL_ScrollToLeftEvent selector) -{ - _scrollToLeftListener = target; - _scrollToLeftSelector = selector; -} - -void UIScrollView::addScrollToRightEvent(Object *target, SEL_ScrollToRightEvent selector) -{ - _scrollToRightListener = target; - _scrollToRightSelector = selector; + _eventListener = target; + _eventSelector = selector; } void UIScrollView::setDirection(SCROLLVIEW_DIR dir) @@ -698,4 +674,9 @@ LayoutExecutant* UIScrollView::getLayoutExecutant() const return _innerContainer->getLayoutExecutant(); } +const char* UIScrollView::getDescription() const +{ + return "ScrollView"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.h b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.h index 42feb83edf..f2ef9157ee 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.h +++ b/extensions/CocoStudio/GUI/UIWidgets/ScrollWidget/UIScrollView.h @@ -46,14 +46,16 @@ enum SCROLLVIEW_MOVE_DIR SCROLLVIEW_MOVE_DIR_RIGHT, }; -typedef void (Object::*SEL_ScrollToTopEvent)(Object*); -typedef void (Object::*SEL_ScrollToBottomEvent)(Object*); -typedef void (Object::*SEL_ScrollToLeftEvent)(Object*); -typedef void (Object::*SEL_ScrollToRightEvent)(Object*); -#define coco_ScrollToTopSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToTopEvent)(&_SELECTOR) -#define coco_ScrollToBottomSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToBottomEvent)(&_SELECTOR) -#define coco_ScrollToLeftSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToLeftEvent)(&_SELECTOR) -#define coco_ScrollToRightSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToRightEvent)(&_SELECTOR) +typedef enum +{ + SCROLLVIEW_EVENT_SCROLL_TO_TOP, + SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM, + SCROLLVIEW_EVENT_SCROLL_TO_LEFT, + SCROLLVIEW_EVENT_SCROLL_TO_RIGHT, +}ScrollviewEventType; + +typedef void (Object::*SEL_ScrollViewEvent)(Object*, ScrollviewEventType); +#define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR) class UIScrollView : public Layout , public UIScrollInterface @@ -130,24 +132,9 @@ public: const Size& getInnerContainerSize() const; /** - * Add call back function called when scrollview scrolled to top. + * Add call back function called scrollview event triggered */ - void addScrollToTopEvent(Object* target, SEL_ScrollToTopEvent selector); - - /** - * Add call back function called when scrollview scrolled to bottom. - */ - void addScrollToBottomEvent(Object* target, SEL_ScrollToBottomEvent selector); - - /** - * Add call back function called when scrollview scrolled to left. - */ - void addScrollToLeftEvent(Object* target, SEL_ScrollToLeftEvent selector); - - /** - * Add call back function called when scrollview scrolled to right. - */ - void addScrollToRightEvent(Object* target, SEL_ScrollToRightEvent selector); + void addEventListener(Object* target, SEL_ScrollViewEvent selector); //override "setLayoutExecutant" method of widget. virtual void setLayoutExecutant(LayoutExecutant* exe); @@ -183,6 +170,11 @@ public: virtual void onTouchLongClicked(const Point &touchPoint); virtual void update(float dt); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual bool init(); virtual void initRenderer(); @@ -212,6 +204,8 @@ protected: virtual void onSizeChanged(); virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);}; protected: + Layout* _innerContainer; + SCROLLVIEW_DIR _direction; SCROLLVIEW_MOVE_DIR _moveDirection; float _touchStartLocation; @@ -237,16 +231,9 @@ protected: Point _moveChildPoint; float _childFocusCancelOffset; - Object* _scrollToTopListener; - SEL_ScrollToTopEvent _scrollToTopSelector; - Object* _scrollToBottomListener; - SEL_ScrollToBottomEvent _scrollToBottomSelector; - Object* _scrollToLeftListener; - SEL_ScrollToLeftEvent _scrollToLeftSelector; - Object* _scrollToRightListener; - SEL_ScrollToRightEvent _scrollToRightSelector; + Object* _eventListener; + SEL_ScrollViewEvent _eventSelector; - Layout* _innerContainer; }; NS_CC_EXT_END diff --git a/extensions/CocoStudio/GUI/UIWidgets/UIButton.cpp b/extensions/CocoStudio/GUI/UIWidgets/UIButton.cpp index b456613e9e..7273378c0f 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UIButton.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UIButton.cpp @@ -431,54 +431,6 @@ void UIButton::setAnchorPoint(const Point &pt) _titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y))); } -void UIButton::setNormalSpriteFrame(SpriteFrame *frame) -{ - if (!frame) - { - return; - } - if (_scale9Enabled) - { - dynamic_cast(_buttonNormalRenderer)->setSpriteFrame(frame); - } - else - { - dynamic_cast(_buttonNormalRenderer)->setDisplayFrame(frame); - } -} - -void UIButton::setPressedSpriteFrame(SpriteFrame *frame) -{ - if (!frame) - { - return; - } - if (_scale9Enabled) - { - dynamic_cast(_buttonClickedRenderer)->setSpriteFrame(frame); - } - else - { - dynamic_cast(_buttonClickedRenderer)->setDisplayFrame(frame); - } -} - -void UIButton::setDisabledSpriteFrame(SpriteFrame *frame) -{ - if (!frame) - { - return; - } - if (_scale9Enabled) - { - dynamic_cast(_buttonDisableRenderer)->setSpriteFrame(frame); - } - else - { - dynamic_cast(_buttonDisableRenderer)->setDisplayFrame(frame); - } -} - void UIButton::onSizeChanged() { normalTextureScaleChangedWithSize(); @@ -657,4 +609,9 @@ void UIButton::setColor(const Color3B &color) setTitleColor(_titleColor); } +const char* UIButton::getDescription() const +{ + return "Button"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UIButton.h b/extensions/CocoStudio/GUI/UIWidgets/UIButton.h index ace2829c3a..f44e897a90 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UIButton.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UIButton.h @@ -171,9 +171,10 @@ public: void setTitleFontName(const char* fontName); const char* getTitleFontName() const; - virtual void setNormalSpriteFrame(SpriteFrame* frame); - virtual void setPressedSpriteFrame(SpriteFrame* frame); - virtual void setDisabledSpriteFrame(SpriteFrame* frame); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual bool init(); virtual void initRenderer(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.cpp b/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.cpp index ea8671f02b..588ff138e1 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.cpp @@ -287,7 +287,7 @@ void UICheckBox::unSelectedEvent() } } -void UICheckBox::addSelectedStateEvent(Object *target, SEL_SelectedStateEvent selector) +void UICheckBox::addEventListener(Object *target, SEL_SelectedStateEvent selector) { _selectedStateEventListener = target; _selectedStateEventSelector = selector; @@ -456,4 +456,9 @@ void UICheckBox::frontCrossDisabledTextureScaleChangedWithSize() } } +const char* UICheckBox::getDescription() const +{ + return "CheckBox"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.h b/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.h index 8b9658148d..89f7473f05 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UICheckBox.h @@ -134,7 +134,7 @@ public: virtual void setAnchorPoint(const Point &pt); //add a call back function would called when checkbox is selected or unselected. - void addSelectedStateEvent(Object* target,SEL_SelectedStateEvent selector); + void addEventListener(Object* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX); @@ -157,6 +157,10 @@ public: //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer(); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual bool init(); virtual void initRenderer(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UIImageView.cpp b/extensions/CocoStudio/GUI/UIWidgets/UIImageView.cpp index a8175661f1..23db5afef3 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UIImageView.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UIImageView.cpp @@ -368,4 +368,9 @@ void UIImageView::imageTextureScaleChangedWithSize() } } +const char* UIImageView::getDescription() const +{ + return "ImageView"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UIImageView.h b/extensions/CocoStudio/GUI/UIWidgets/UIImageView.h index 725e94f72f..89e73d3fc4 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UIImageView.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UIImageView.h @@ -107,6 +107,11 @@ public: void checkDoubleClick(float dt); virtual const Size& getContentSize() const; virtual Node* getVirtualRenderer(); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual void initRenderer(); virtual void onSizeChanged(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabel.cpp b/extensions/CocoStudio/GUI/UIWidgets/UILabel.cpp index 9c1104f3a1..0bc0da834d 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabel.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabel.cpp @@ -221,7 +221,11 @@ void UILabel::labelScaleChangedWithSize() _labelRenderer->setScaleX(scaleX); _labelRenderer->setScaleY(scaleY); } - +} + +const char* UILabel::getDescription() const +{ + return "Label"; } NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabel.h b/extensions/CocoStudio/GUI/UIWidgets/UILabel.h index 4b6e4804c9..68b764595e 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabel.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabel.h @@ -117,6 +117,11 @@ public: //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer(); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; + void setTextAreaSize(const Size &size); void setTextHorizontalAlignment(TextHAlignment alignment); void setTextVerticalAlignment(TextVAlignment alignment); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.cpp b/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.cpp index 779a8bc9ec..c4ba1922a7 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.cpp @@ -167,4 +167,9 @@ void UILabelAtlas::labelAtlasScaleChangedWithSize() } } +const char* UILabelAtlas::getDescription() const +{ + return "LabelAtlase"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.h b/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.h index 7c1be4a670..6ff0b65a1e 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabelAtlas.h @@ -87,6 +87,11 @@ public: //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer(); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual void initRenderer(); virtual void onSizeChanged(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.cpp b/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.cpp index 0484fa2432..c5a687015c 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.cpp @@ -126,4 +126,10 @@ void UILabelBMFont::labelBMFontScaleChangedWithSize() } } +const char* UILabelBMFont::getDescription() const +{ + return "LabelBMFont"; +} + + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.h b/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.h index f85a3ee335..757a4c33b1 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UILabelBMFont.h @@ -58,6 +58,11 @@ public: virtual void setAnchorPoint(const Point &pt); virtual const Size& getContentSize() const; virtual Node* getVirtualRenderer(); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual void initRenderer(); virtual void onSizeChanged(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.cpp b/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.cpp index 8873e87403..6f71980dc5 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.cpp @@ -331,4 +331,9 @@ void UILoadingBar::setScale9Scale() dynamic_cast(_barRenderer)->setPreferredSize(Size(width, _barRendererTextureSize.height)); } +const char* UILoadingBar::getDescription() const +{ + return "LoadingBar"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.h b/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.h index f62dfba722..5f38f56eda 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UILoadingBar.h @@ -117,6 +117,10 @@ public: //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer(); + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual void initRenderer(); virtual void onSizeChanged(); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UISlider.cpp b/extensions/CocoStudio/GUI/UIWidgets/UISlider.cpp index cc70352f13..022646033f 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UISlider.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UISlider.cpp @@ -410,7 +410,7 @@ float UISlider::getPercentWithBallPos(float px) return (((px-(-_barLength/2.0f))/_barLength)*100.0f); } -void UISlider::addPercentEvent(Object *target, SEL_SlidPercentChangedEvent selector) +void UISlider::addEventListener(Object *target, SEL_SlidPercentChangedEvent selector) { _slidPercentListener = target; _slidPercentSelector = selector; @@ -535,4 +535,10 @@ void UISlider::onPressStateChangedToDisabled() _slidBallPressedRenderer->setVisible(false); _slidBallDisabledRenderer->setVisible(true); } + +const char* UISlider::getDescription() const +{ + return "Slider"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UISlider.h b/extensions/CocoStudio/GUI/UIWidgets/UISlider.h index db4749adf5..39b912fbe6 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UISlider.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UISlider.h @@ -158,7 +158,7 @@ public: /** * Add call back function called when slider's percent has changed to slider. */ - void addPercentEvent(Object* target,SEL_SlidPercentChangedEvent selector); + void addEventListener(Object* target,SEL_SlidPercentChangedEvent selector); //override "onTouchBegan" method of widget. virtual bool onTouchBegan(const Point &touchPoint); @@ -180,6 +180,11 @@ public: //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore); + + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; protected: virtual void initRenderer(); float getPercentWithBallPos(float location); diff --git a/extensions/CocoStudio/GUI/UIWidgets/UITextField.cpp b/extensions/CocoStudio/GUI/UIWidgets/UITextField.cpp index 1afc92be9b..2703a0557f 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UITextField.cpp +++ b/extensions/CocoStudio/GUI/UIWidgets/UITextField.cpp @@ -271,18 +271,12 @@ bool UICCTextField::getDeleteBackward() UITextField::UITextField(): +_textFieldRenderer(NULL), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), -_attachWithIMEListener(NULL), -_detachWithIMEListener(NULL), -_insertTextListener(NULL), -_deleteBackwardListener(NULL), -_attachWithIMESelector(NULL), -_detachWithIMESelector(NULL), -_insertTextSelector(NULL), -_deleteBackwardSelector(NULL), -_textFieldRenderer(NULL) +_eventListener(NULL), +_eventSelector(NULL) { } @@ -475,58 +469,40 @@ void UITextField::setDeleteBackward(bool deleteBackward) void UITextField::attachWithIMEEvent() { - if (_attachWithIMEListener && _attachWithIMESelector) + if (_eventListener && _eventSelector) { - (_attachWithIMEListener->*_attachWithIMESelector)(this); + (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); } } void UITextField::detachWithIMEEvent() { - if (_detachWithIMEListener && _detachWithIMESelector) + if (_eventListener && _eventSelector) { - (_detachWithIMEListener->*_detachWithIMESelector)(this); + (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); } } void UITextField::insertTextEvent() { - if (_insertTextListener && _insertTextSelector) + if (_eventListener && _eventSelector) { - (_insertTextListener->*_insertTextSelector)(this); + (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INDERT_TEXT); } } void UITextField::deleteBackwardEvent() { - if (_deleteBackwardListener && _deleteBackwardSelector) + if (_eventListener && _eventSelector) { - (_deleteBackwardListener->*_deleteBackwardSelector)(this); + (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); } } -void UITextField::addAttachWithIMEEvent(Object *target, SEL_TextFieldAttachWithIMEEvent selecor) +void UITextField::addEventListener(Object *target, SEL_TextFieldEvent selecor) { - _attachWithIMEListener = target; - _attachWithIMESelector = selecor; -} - -void UITextField::addDetachWithIMEEvent(Object *target, SEL_TextFieldDetachWithIMEEvent selecor) -{ - _detachWithIMEListener = target; - _detachWithIMESelector = selecor; -} - -void UITextField::addInsertTextEvent(Object *target, SEL_TextFieldInsertTextEvent selecor) -{ - _insertTextListener = target; - _insertTextSelector = selecor; -} - -void UITextField::addDeleteBackwardEvent(Object *target, SEL_TextFieldDeleteBackwardEvent selecor) -{ - _deleteBackwardListener = target; - _deleteBackwardSelector = selecor; + _eventListener = target; + _eventSelector = selecor; } void UITextField::setAnchorPoint(const Point &pt) @@ -584,4 +560,9 @@ Node* UITextField::getVirtualRenderer() return _textFieldRenderer; } +const char* UITextField::getDescription() const +{ + return "TextField"; +} + NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/GUI/UIWidgets/UITextField.h b/extensions/CocoStudio/GUI/UIWidgets/UITextField.h index 80ffa71e31..5efc920b80 100644 --- a/extensions/CocoStudio/GUI/UIWidgets/UITextField.h +++ b/extensions/CocoStudio/GUI/UIWidgets/UITextField.h @@ -70,6 +70,8 @@ public: bool getInsertText(); void setDeleteBackward(bool deleteBackward); bool getDeleteBackward(); + + protected: bool m_bMaxLengthEnabled; int m_nMaxLength; @@ -82,14 +84,16 @@ protected: }; -typedef void (Object::*SEL_TextFieldAttachWithIMEEvent)(Object*); -#define coco_TextField_AttachWithIME_selector(_SELECTOR) (SEL_TextFieldAttachWithIMEEvent)(&_SELECTOR) -typedef void (Object::*SEL_TextFieldDetachWithIMEEvent)(Object*); -#define coco_TextField_DetachWithIME_selector(_SELECTOR) (SEL_TextFieldDetachWithIMEEvent)(&_SELECTOR) -typedef void (Object::*SEL_TextFieldInsertTextEvent)(Object*); -#define coco_TextField_InsertText_selector(_SELECTOR) (SEL_TextFieldInsertTextEvent)(&_SELECTOR) -typedef void (Object::*SEL_TextFieldDeleteBackwardEvent)(Object*); -#define coco_TextField_DeleteBackward_selector(_SELECTOR) (SEL_TextFieldDeleteBackwardEvent)(&_SELECTOR) +typedef enum +{ + TEXTFIELD_EVENT_ATTACH_WITH_IME, + TEXTFIELD_EVENT_DETACH_WITH_IME, + TEXTFIELD_EVENT_INDERT_TEXT, + TEXTFIELD_EVENT_DELETE_BACKWARD, +}TextFiledEventType; + +typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType); +#define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR) //class UITextField : public UIWidget class UITextField : public UIWidget @@ -124,14 +128,14 @@ public: void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); - void addAttachWithIMEEvent(Object* target, SEL_TextFieldAttachWithIMEEvent selecor); - void addDetachWithIMEEvent(Object* target, SEL_TextFieldDetachWithIMEEvent selecor); - void addInsertTextEvent(Object* target, SEL_TextFieldInsertTextEvent selecor); - void addDeleteBackwardEvent(Object* target, SEL_TextFieldDeleteBackwardEvent selecor); + void addEventListener(Object* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const Point &pt); virtual void setColor(const Color3B &color); virtual void setOpacity(int opacity); - + /** + * Returns the "class name" of widget. + */ + virtual const char* getDescription() const; /*compatibel*/ /** * These methods will be removed @@ -150,21 +154,15 @@ protected: virtual void onSizeChanged(); void textfieldRendererScaleChangedWithSize(); protected: + UICCTextField* _textFieldRenderer; + float _touchWidth; float _touchHeight; bool _useTouchArea; - Object* _attachWithIMEListener; - Object* _detachWithIMEListener; - Object* _insertTextListener; - Object* _deleteBackwardListener; + Object* _eventListener; + SEL_TextFieldEvent _eventSelector; - SEL_TextFieldAttachWithIMEEvent _attachWithIMESelector; - SEL_TextFieldDetachWithIMEEvent _detachWithIMESelector; - SEL_TextFieldInsertTextEvent _insertTextSelector; - SEL_TextFieldDeleteBackwardEvent _deleteBackwardSelector; - - UICCTextField* _textFieldRenderer; }; NS_CC_EXT_END diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 025f058e99..252102fcab 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -86,10 +86,10 @@ static size_t writeHeaderData(void *ptr, size_t size, size_t nmemb, void *stream } -static int processGetTask(HttpRequest *request, write_callback callback, void *stream, int32_t *errorCode, write_callback headerCallback, void *headerStream); -static int processPostTask(HttpRequest *request, write_callback callback, void *stream, int32_t *errorCode, write_callback headerCallback, void *headerStream); -static int processPutTask(HttpRequest *request, write_callback callback, void *stream, int32_t *errorCode, write_callback headerCallback, void *headerStream); -static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, int32_t *errorCode, write_callback headerCallback, void *headerStream); +static int processGetTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); +static int processPostTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); +static int processPutTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); +static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); // int processDownloadTask(HttpRequest *task, write_callback callback, void *stream, int32_t *errorCode); @@ -137,7 +137,7 @@ static void networkThread(void) request->release(); // ok, refcount = 1 now, only HttpResponse hold it. - int32_t responseCode = -1; + long responseCode = -1; int retValue = 0; // Process the request -> get response packet @@ -320,7 +320,7 @@ public: } /// @param responseCode Null not allowed - bool perform(int *responseCode) + bool perform(long *responseCode) { if (CURLE_OK != curl_easy_perform(_curl)) return false; @@ -336,7 +336,7 @@ public: }; //Process Get Request -static int processGetTask(HttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream) +static int processGetTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) @@ -346,7 +346,7 @@ static int processGetTask(HttpRequest *request, write_callback callback, void *s } //Process POST Request -static int processPostTask(HttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream) +static int processPostTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) @@ -358,7 +358,7 @@ static int processPostTask(HttpRequest *request, write_callback callback, void * } //Process PUT Request -static int processPutTask(HttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream) +static int processPutTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) @@ -370,7 +370,7 @@ static int processPutTask(HttpRequest *request, write_callback callback, void *s } //Process DELETE Request -static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream) +static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index d8359a5684..3855d5afe3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -54,7 +54,7 @@ bool UICheckBoxTest::init() "cocosgui/check_box_active_disable.png"); checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addSelectedStateEvent(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); + checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); // checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent)); m_pUiLayer->addWidget(checkBox); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.cpp index a9f3dc4c76..e80ff2fd01 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.cpp @@ -57,14 +57,7 @@ bool UIDragPanelTest::init() (backgroundSize.width - dragPanel->getSize().width) / 2, (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - dragPanel->getSize().height) / 2)); - dragPanel->addBerthToLeftBottomEvent(this, coco_DragPane_BerthToLeftBottom_selector(UIDragPanelTest::berthToLeftBottomEvent)); - dragPanel->addBerthToLeftTopEvent(this, coco_DragPanel_BerthToLeftTop_selector(UIDragPanelTest::berthToLeftTopEvent)); - dragPanel->addBerthToRightBottomEvent(this, coco_DragPanel_BerthToRightBottom_selector(UIDragPanelTest::berthToRightBottomEvent)); - dragPanel->addBerthToRightTopEvent(this, coco_DragPanel_BerthToRightTop_selector(UIDragPanelTest::berthToRightTopEvent)); - dragPanel->addBerthToLeftEvent(this, coco_DragPanel_BerthToLeft_selector(UIDragPanelTest::berthToLeftEvent)); - dragPanel->addBerthToTopEvent(this, coco_DragPanel_BerthToTop_selector(UIDragPanelTest::berthToTopEvent)); - dragPanel->addBerthToRightEvent(this, coco_DragPanel_BerthToRight_selector(UIDragPanelTest::berthToRightEvent)); - dragPanel->addBerthToBottomEvent(this, coco_DragPanel_BerthToBottom_selector(UIDragPanelTest::berthToBottomEvent)); + dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest::dragPanelEvent)); UIImageView* imageView = UIImageView::create(); imageView->setTouchEnabled(true); @@ -82,44 +75,45 @@ bool UIDragPanelTest::init() return false; } -void UIDragPanelTest::berthToLeftBottomEvent(Object *pSender) +void UIDragPanelTest::dragPanelEvent(Object *pSender, DragPanelEventType type) { - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Bottom")->getCString()); -} - -void UIDragPanelTest::berthToLeftTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Top")->getCString()); -} - -void UIDragPanelTest::berthToRightBottomEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Bottom")->getCString()); -} - -void UIDragPanelTest::berthToRightTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Top")->getCString()); -} - -void UIDragPanelTest::berthToLeftEvent(Object* pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left")->getCString()); -} - -void UIDragPanelTest::berthToTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Top")->getCString()); -} - -void UIDragPanelTest::berthToRightEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right")->getCString()); -} - -void UIDragPanelTest::berthToBottomEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Bottom")->getCString()); + switch (type) + { + case DRAGPANEL_EVENT_BERTH_LEFTBOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Bottom")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_LFETTOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Bottom")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_RIGHTTOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_LEFT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_TOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_RIGHT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right")->getCString()); + break; + + case DRAGPANEL_EVENT_BERTH_BOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Bottom")->getCString()); + break; + + default: + break; + } } // UIDragPanelTest_Bounce @@ -171,14 +165,7 @@ bool UIDragPanelTest_Bounce::init() (backgroundSize.width - dragPanel->getSize().width) / 2, (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - dragPanel->getSize().height) / 2)); - dragPanel->addBounceToLeftBottomEvent(this, coco_DragPanel_BounceToLeftBottom_selector(UIDragPanelTest_Bounce::bounceToLeftBottomEvent)); - dragPanel->addBounceToLeftTopEvent(this, coco_DragPanel_BounceToLeftTop_selector(UIDragPanelTest_Bounce::bounceToLeftTopEvent)); - dragPanel->addBounceToRightBottomEvent(this, coco_DragPanel_BounceToRightBottom_selector(UIDragPanelTest_Bounce::bounceToRightBottomEvent)); - dragPanel->addBounceToRightTopEvent(this, coco_DragPanel_BounceToRightTop_selector(UIDragPanelTest_Bounce::bounceToRightTopEvent)); - dragPanel->addBounceToLeftEvent(this, coco_DragPanel_BounceToLeft_selector(UIDragPanelTest_Bounce::bounceToLeftEvent)); - dragPanel->addBounceToTopEvent(this, coco_DragPanel_BounceToTop_selector(UIDragPanelTest_Bounce::bounceToTopEvent)); - dragPanel->addBounceToRightEvent(this, coco_DragPanel_BounceToRight_selector(UIDragPanelTest_Bounce::bounceToRightEvent)); - dragPanel->addBounceToBottomEvent(this, coco_DragPanel_BounceToBottom_selector(UIDragPanelTest_Bounce::bounceToBottomEvent)); + dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest_Bounce::dragPanelEvent)); UIImageView* imageView = UIImageView::create(); imageView->setTouchEnabled(true); @@ -197,42 +184,43 @@ bool UIDragPanelTest_Bounce::init() return false; } -void UIDragPanelTest_Bounce::bounceToLeftBottomEvent(Object *pSender) +void UIDragPanelTest_Bounce::dragPanelEvent(Object *pSender, DragPanelEventType type) { - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Bottom")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToLeftTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Top")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToRightBottomEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Bottom")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToRightTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Top")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToLeftEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToTopEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Top")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToRightEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right")->getCString()); -} - -void UIDragPanelTest_Bounce::bounceToBottomEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Bottom")->getCString()); + switch (type) + { + case DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Bottom")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_LEFTTOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Bottom")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_RIGHTTOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_LEFT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_TOP: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Top")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_RIGHT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right")->getCString()); + break; + + case DRAGPANEL_EVENT_BOUNCE_BOTTOM: + m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Bottom")->getCString()); + break; + + default: + break; + } } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.h index 11793ada27..76f8469154 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.h @@ -33,14 +33,7 @@ public: UIDragPanelTest(); ~UIDragPanelTest(); bool init(); - void berthToLeftBottomEvent(Object* pSender); - void berthToLeftTopEvent(Object* pSender); - void berthToRightBottomEvent(Object* pSender); - void berthToRightTopEvent(Object* pSender); - void berthToLeftEvent(Object* pSender); - void berthToTopEvent(Object* pSender); - void berthToRightEvent(Object* pSender); - void berthToBottomEvent(Object* pSender); + void dragPanelEvent(Object* pSender, DragPanelEventType type); protected: UI_SCENE_CREATE_FUNC(UIDragPanelTest) @@ -53,14 +46,7 @@ public: UIDragPanelTest_Bounce(); ~UIDragPanelTest_Bounce(); bool init(); - void bounceToLeftBottomEvent(Object* pSender); - void bounceToRightBottomEvent(Object* pSender); - void bounceToLeftTopEvent(Object* pSender); - void bounceToRightTopEvent(Object* pSender); - void bounceToLeftEvent(Object* pSender); - void bounceToTopEvent(Object* pSender); - void bounceToRightEvent(Object* pSender); - void bounceToBottomEvent(Object* pSender); + void dragPanelEvent(Object* pSender, DragPanelEventType type); protected: UI_SCENE_CREATE_FUNC(UIDragPanelTest_Bounce) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index efb20975e2..6681c744ee 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -90,8 +90,7 @@ bool UIListViewTest_Vertical::init() listView->addChild(layout); } - listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Vertical::initChildEvent)); - listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Vertical::updateChildEvent)); + listView->addEventListenter(this, listvieweventselector(UIListViewTest_Vertical::listViewEvent)); listView->initChildWithDataLength(m_array->count()); m_pUiLayer->addWidget(listView); @@ -101,33 +100,44 @@ bool UIListViewTest_Vertical::init() return false; } -void UIListViewTest_Vertical::initChildEvent(Object *pSender) +void UIListViewTest_Vertical::listViewEvent(Object *pSender, ListViewEventType type) { - String* ccstr = static_cast(m_array->getObjectAtIndex(m_nCount)); - UIListView* list = dynamic_cast(pSender); - - Layout* layout = dynamic_cast(list->getUpdateChild()); - UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); - textButton->setTitleText(ccstr->getCString()); - - m_nCount++; -} - -void UIListViewTest_Vertical::updateChildEvent(Object *pSender) -{ - UIListView* list = dynamic_cast(pSender); - int index = list->getUpdateDataIndex(); - - if (index < 0 || index >= list->getDataLength()) + switch (type) { - list->setUpdateSuccess(false); + case LISTVIEW_EVENT_INIT_CHILD: + { + String* ccstr = static_cast(m_array->getObjectAtIndex(m_nCount)); + UIListView* list = dynamic_cast(pSender); + + Layout* layout = dynamic_cast(list->getUpdateChild()); + UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); + textButton->setTitleText(ccstr->getCString()); + + m_nCount++; + } + break; + + case LISTVIEW_EVENT_UPDATE_CHILD: + { + UIListView* list = dynamic_cast(pSender); + int index = list->getUpdateDataIndex(); + + if (index < 0 || index >= list->getDataLength()) + { + list->setUpdateSuccess(false); + } + + String* ccstr = static_cast(m_array->getObjectAtIndex(index)); + Layout* layout = dynamic_cast(list->getUpdateChild()); + UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); + textButton->setTitleText(ccstr->getCString()); + list->setUpdateSuccess(true); + } + break; + + default: + break; } - - String* ccstr = static_cast(m_array->getObjectAtIndex(index)); - Layout* layout = dynamic_cast(list->getUpdateChild()); - UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); - textButton->setTitleText(ccstr->getCString()); - list->setUpdateSuccess(true); } // UIListViewTest_Horizontal @@ -211,8 +221,7 @@ bool UIListViewTest_Horizontal::init() listView->addChild(layout); } - listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Horizontal::initChildEvent)); - listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Horizontal::updateChildEvent)); + listView->addEventListenter(this, listvieweventselector(UIListViewTest_Horizontal::listViewEvent)); listView->initChildWithDataLength(m_array->count()); m_pUiLayer->addWidget(listView); @@ -222,31 +231,42 @@ bool UIListViewTest_Horizontal::init() return false; } -void UIListViewTest_Horizontal::initChildEvent(Object *pSender) +void UIListViewTest_Horizontal::listViewEvent(Object *pSender, ListViewEventType type) { - String* ccstr = static_cast(m_array->getObjectAtIndex(m_nCount)); - UIListView* list = dynamic_cast(pSender); - - Layout* layout = dynamic_cast(list->getUpdateChild()); - UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); - textButton->setTitleText(ccstr->getCString()); - - m_nCount++; -} - -void UIListViewTest_Horizontal::updateChildEvent(Object *pSender) -{ - UIListView* list = dynamic_cast(pSender); - int index = list->getUpdateDataIndex(); - - if (index < 0 || index >= list->getDataLength()) + switch (type) { - list->setUpdateSuccess(false); + case LISTVIEW_EVENT_INIT_CHILD: + { + String* ccstr = static_cast(m_array->getObjectAtIndex(m_nCount)); + UIListView* list = dynamic_cast(pSender); + + Layout* layout = dynamic_cast(list->getUpdateChild()); + UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); + textButton->setTitleText(ccstr->getCString()); + + m_nCount++; + } + break; + + case LISTVIEW_EVENT_UPDATE_CHILD: + { + UIListView* list = dynamic_cast(pSender); + int index = list->getUpdateDataIndex(); + + if (index < 0 || index >= list->getDataLength()) + { + list->setUpdateSuccess(false); + } + + String* ccstr = static_cast(m_array->getObjectAtIndex(index)); + Layout* layout = dynamic_cast(list->getUpdateChild()); + UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); + textButton->setTitleText(ccstr->getCString()); + list->setUpdateSuccess(true); + } + break; + + default: + break; } - - String* ccstr = static_cast(m_array->getObjectAtIndex(index)); - Layout* layout = dynamic_cast(list->getUpdateChild()); - UIButton* textButton = dynamic_cast(layout->getChildByName("TextButton")); - textButton->setTitleText(ccstr->getCString()); - list->setUpdateSuccess(true); -} \ No newline at end of file +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h index bc170a6c34..b2725e33ee 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h @@ -32,9 +32,8 @@ class UIListViewTest_Vertical : public UIScene public: UIListViewTest_Vertical(); ~UIListViewTest_Vertical(); - bool init(); - void initChildEvent(Object* pSender); - void updateChildEvent(Object* pSender); + bool init(); + void listViewEvent(Object* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical) @@ -50,8 +49,7 @@ public: UIListViewTest_Horizontal(); ~UIListViewTest_Horizontal(); bool init(); - void initChildEvent(Object* pSender); - void updateChildEvent(Object* pSender); + void listViewEvent(Object* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index faaf4e7927..22b97ef9e6 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -79,8 +79,7 @@ bool UIPageViewTest::init() pageView->addPage(layout); } - - pageView->addPageTurningEvent(this, coco_PageView_PageTurning_selector(UIPageViewTest::pageTurningEvent)); + pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); m_pUiLayer->addWidget(pageView); @@ -89,10 +88,19 @@ bool UIPageViewTest::init() return false; } -void UIPageViewTest::pageTurningEvent(Object *pSender) +void UIPageViewTest::pageViewEvent(Object *pSender, PageViewEventType type) { - UIPageView* pageView = dynamic_cast(pSender); - CCLOG("page = %d", pageView->getCurPageIndex()); - - m_pDisplayValueLabel->setText(CCString::createWithFormat("page = %d", pageView->getCurPageIndex() + 1)->getCString()); -} \ No newline at end of file + switch (type) + { + case PAGEVIEW_EVENT_TURNING: + { + UIPageView* pageView = dynamic_cast(pSender); + + m_pDisplayValueLabel->setText(CCString::createWithFormat("page = %d", pageView->getCurPageIndex() + 1)->getCString()); + } + break; + + default: + break; + } +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 3ae0e4e96d..a24e099a4d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -34,7 +34,7 @@ public: ~UIPageViewTest(); bool init(); - void pageTurningEvent(Object* pSender); + void pageViewEvent(Object* pSender, PageViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIPageViewTest) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index 920449e71a..f1ed704289 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -2,6 +2,7 @@ #include "cocos-ext.h" #include "UIScene.h" #include "UISceneManager.h" +#include "../ExtensionsTest.h" UIScene::UIScene() : m_pSceneTitle(NULL) @@ -40,13 +41,16 @@ bool UIScene::init() UIButton *right_button = dynamic_cast(m_pUiLayer->getWidgetByName("right_Button")); right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback)); - // exit button - UIButton* exit_button = UIButton::create(); - exit_button->setTouchEnabled(true); - exit_button->loadTextures("CloseNormal.png", "CloseSelected.png", ""); - exit_button->setPosition(Point(m_pUiLayer->getContentSize().width - exit_button->getContentSize().width, exit_button->getContentSize().height)); - exit_button->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback)); - m_pUiLayer->addWidget(exit_button); + + UILabel* mainMenuLabel = UILabel::create(); + mainMenuLabel->setText("MainMenu"); + mainMenuLabel->setFontSize(20); + mainMenuLabel->setTouchScaleChangeEnabled(true); + mainMenuLabel->setPosition(Point(430,30)); + mainMenuLabel->setTouchEnabled(true); + mainMenuLabel->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback)); + m_pUiLayer->addWidget(mainMenuLabel); + return true; } @@ -57,12 +61,10 @@ void UIScene::menuCloseCallback(Object* pSender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { - CCDirector::getInstance()->end(); + auto scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif } void UIScene::previousCallback(Object* sender, TouchEventType type) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 1e53c27f34..2749e061ab 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -52,7 +52,7 @@ bool UISliderTest::init() slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosgui/sliderProgress.png"); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); + slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; @@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init() slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setSize(Size(250, 10)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); + slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 61279c8458..3e85c987b4 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -51,10 +51,7 @@ bool UITextFieldTest::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest::attachWithIMEEvent)); - textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest::detachWithIMEEvent)); - textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest::insertTextEvent)); - textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest::deleteBackwardEvent)); + textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -62,31 +59,40 @@ bool UITextFieldTest::init() return false; } -void UITextFieldTest::attachWithIMEEvent(Object *pSender) +void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type) { - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString()); -} - -void UITextFieldTest::detachWithIMEEvent(Object* pSender) -{ - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString()); -} - -void UITextFieldTest::insertTextEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words")->getCString()); -} - -void UITextFieldTest::deleteBackwardEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word")->getCString()); + switch (type) + { + case TEXTFIELD_EVENT_ATTACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.225, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString()); + } + break; + + case TEXTFIELD_EVENT_DETACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString()); + } + break; + + case TEXTFIELD_EVENT_INDERT_TEXT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words")->getCString()); + break; + + case TEXTFIELD_EVENT_DELETE_BACKWARD: + m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word")->getCString()); + break; + + default: + break; + } } // UITextFieldTest_MaxLength @@ -133,10 +139,7 @@ bool UITextFieldTest_MaxLength::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_MaxLength::attachWithIMEEvent)); - textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_MaxLength::detachWithIMEEvent)); - textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_MaxLength::insertTextEvent)); - textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_MaxLength::deleteBackwardEvent)); + textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -144,33 +147,46 @@ bool UITextFieldTest_MaxLength::init() return false; } -void UITextFieldTest_MaxLength::attachWithIMEEvent(Object *pSender) +void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventType type) { - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); -} - -void UITextFieldTest_MaxLength::detachWithIMEEvent(Object* pSender) -{ - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString()); -} - -void UITextFieldTest_MaxLength::insertTextEvent(Object *pSender) -{ - UITextField* textField = dynamic_cast(pSender); - m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString()); -} - -void UITextFieldTest_MaxLength::deleteBackwardEvent(Object *pSender) -{ - UITextField* textField = dynamic_cast(pSender); - m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString()); + switch (type) + { + case TEXTFIELD_EVENT_ATTACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.225, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); + } + break; + + case TEXTFIELD_EVENT_DETACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString()); + } + break; + + case TEXTFIELD_EVENT_INDERT_TEXT: + { + UITextField* textField = dynamic_cast(pSender); + m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString()); + } + break; + + case TEXTFIELD_EVENT_DELETE_BACKWARD: + { + UITextField* textField = dynamic_cast(pSender); + m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString()); + } + break; + + default: + break; + } } // UITextFieldTest_Password @@ -217,10 +233,7 @@ bool UITextFieldTest_Password::init() textField->setFontSize(30); textField->setPlaceHolder("input password here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_Password::attachWithIMEEvent)); - textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_Password::detachWithIMEEvent)); - textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_Password::insertTextEvent)); - textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_Password::deleteBackwardEvent)); + textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -228,29 +241,38 @@ bool UITextFieldTest_Password::init() return false; } -void UITextFieldTest_Password::attachWithIMEEvent(Object *pSender) +void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventType type) { - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.225, - Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString()); -} - -void UITextFieldTest_Password::detachWithIMEEvent(Object* pSender) -{ - UITextField* textField = dynamic_cast(pSender); - Size screenSize = CCDirector::getInstance()->getWinSize(); - textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); - m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString()); -} - -void UITextFieldTest_Password::insertTextEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words password")->getCString()); -} - -void UITextFieldTest_Password::deleteBackwardEvent(Object *pSender) -{ - m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word password")->getCString()); + switch (type) + { + case TEXTFIELD_EVENT_ATTACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.225, + Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString()); + } + break; + + case TEXTFIELD_EVENT_DETACH_WITH_IME: + { + UITextField* textField = dynamic_cast(pSender); + Size screenSize = CCDirector::getInstance()->getWinSize(); + textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); + m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString()); + } + break; + + case TEXTFIELD_EVENT_INDERT_TEXT: + m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words password")->getCString()); + break; + + case TEXTFIELD_EVENT_DELETE_BACKWARD: + m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word password")->getCString()); + break; + + default: + break; + } } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h index 3ab1dedae1..10674258f1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h @@ -33,10 +33,7 @@ public: UITextFieldTest(); ~UITextFieldTest(); bool init(); - void attachWithIMEEvent(Object* pSender); - void detachWithIMEEvent(Object* pSender); - void insertTextEvent(Object* pSender); - void deleteBackwardEvent(Object* pSender); + void textFieldEvent(Object* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest) @@ -49,10 +46,7 @@ public: UITextFieldTest_MaxLength(); ~UITextFieldTest_MaxLength(); bool init(); - void attachWithIMEEvent(Object* pSender); - void detachWithIMEEvent(Object* pSender); - void insertTextEvent(Object* pSender); - void deleteBackwardEvent(Object* pSender); + void textFieldEvent(Object* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength) @@ -65,10 +59,7 @@ public: UITextFieldTest_Password(); ~UITextFieldTest_Password(); bool init(); - void attachWithIMEEvent(Object* pSender); - void detachWithIMEEvent(Object* pSender); - void insertTextEvent(Object* pSender); - void deleteBackwardEvent(Object* pSender); + void textFieldEvent(Object* pSender, TextFiledEventType type); protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_Password) diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 59c7ced335..4fd8113038 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -e974dbfed177959540281eb3f323ce8ef53b6b82 \ No newline at end of file +aa56b980468fda5b70dcbf37c09caf09b0b133a0 \ No newline at end of file diff --git a/scripting/javascript/bindings/js/jsb_deprecated.js b/scripting/javascript/bindings/js/jsb_deprecated.js index 2257f0fb5f..89efd00284 100644 --- a/scripting/javascript/bindings/js/jsb_deprecated.js +++ b/scripting/javascript/bindings/js/jsb_deprecated.js @@ -60,4 +60,8 @@ var cc = cc || {}; return cc.TMXTiledMap.prototype.getPropertiesForGID.apply(this, arguments); }; + cc.Menu.prototype.setHandlerPriority = function() { + cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now."); + }; + })(); diff --git a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj index 8f34754a1c..26b32e1539 100644 --- a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj +++ b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj @@ -613,7 +613,7 @@ SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; - VALID_ARCHS = "armv6 armv7 i386"; + VALID_ARCHS = "armv6 armv7 armv7s i386"; }; name = Debug; }; @@ -664,6 +664,7 @@ TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; VALIDATE_PRODUCT = YES; + VALID_ARCHS = "armv6 armv7 armv7s i386"; }; name = Release; };