diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index d4449e9706..8454acf0a1 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a30cd2dad1df734bd988309d3b344ff946601cb4 \ No newline at end of file +b803d542a8eac86722010a38dd782612565198b7 \ No newline at end of file diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 8c09f89269..81eb450db1 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -67,18 +67,18 @@ public: UNKOWN }; - typedef enum + enum class TextAlign { - kAlignCenter = 0x33, ///< Horizontal center and vertical center. - kAlignTop = 0x13, ///< Horizontal center and vertical top. - kAlignTopRight = 0x12, ///< Horizontal right and vertical top. - kAlignRight = 0x32, ///< Horizontal right and vertical center. - kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom. - kAlignBottom = 0x23, ///< Horizontal center and vertical bottom. - kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom. - kAlignLeft = 0x31, ///< Horizontal left and vertical center. - kAlignTopLeft = 0x11, ///< Horizontal left and vertical top. - }ETextAlign; + CENTER = 0x33, ///< Horizontal center and vertical center. + TOP = 0x13, ///< Horizontal center and vertical top. + TOP_RIGHT = 0x12, ///< Horizontal right and vertical top. + RIGHT = 0x32, ///< Horizontal right and vertical center. + BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. + BOTTOM = 0x23, ///< Horizontal center and vertical bottom. + BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom. + LEFT = 0x31, ///< Horizontal left and vertical center. + TOP_LEFT = 0x11, ///< Horizontal left and vertical top. + }; /** @brief Load the image from the specified path. @@ -120,7 +120,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TextAlign::CENTER, const char * pFontName = 0, int nSize = 0); @@ -130,7 +130,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TextAlign::CENTER, const char * pFontName = 0, int nSize = 0, float textTintR = 1, diff --git a/cocos2dx/platform/android/CCImage.cpp b/cocos2dx/platform/android/CCImage.cpp index 42878d1ae3..d0668b24c6 100644 --- a/cocos2dx/platform/android/CCImage.cpp +++ b/cocos2dx/platform/android/CCImage.cpp @@ -62,7 +62,7 @@ public: bool getBitmapFromJavaShadowStroke( const char *text, int nWidth, int nHeight, - Image::ETextAlign eAlignMask, + Image::TextAlign eAlignMask, const char * pFontName, float fontSize, float textTintR = 1.0, @@ -120,7 +120,7 @@ public: } - bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) + bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize ); } @@ -148,7 +148,7 @@ bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, - ETextAlign eAlignMask/* = kAlignCenter*/, + TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { @@ -182,7 +182,7 @@ bool Image::initWithStringShadowStroke( const char * pText, int nWidth , int nHeight , - ETextAlign eAlignMask , + TextAlign eAlignMask , const char * pFontName , int nSize , float textTintR, diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 3a81c61c7c..3704650f8b 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -172,7 +172,7 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize #define ALIGN_CENTER 3 #define ALIGN_BOTTOM 2 -static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo) +static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo) { bool bRet = false; do @@ -221,7 +221,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig if (constrainSize.height > dim.height) { // vertical alignment - unsigned int vAlignment = (eAlign >> 4) & 0x0F; + unsigned int vAlignment = ((int)eAlign >> 4) & 0x0F; if (vAlignment == ALIGN_TOP) { startH = 0; @@ -297,7 +297,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig UIGraphicsPushContext(context); // measure text size with specified font and determine the rectangle to draw text in - unsigned uHoriFlag = eAlign & 0x0f; + unsigned uHoriFlag = (int)eAlign & 0x0f; UITextAlignment align = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight : (3 == uHoriFlag) ? UITextAlignmentCenter : UITextAlignmentLeft); @@ -543,7 +543,7 @@ bool Image::initWithString( const char * pText, int nWidth /* = 0 */, int nHeight /* = 0 */, - ETextAlign eAlignMask /* = kAlignCenter */, + TextAlign eAlignMask /* = kAlignCenter */, const char * pFontName /* = nil */, int nSize /* = 0 */) { @@ -554,7 +554,7 @@ bool Image::initWithStringShadowStroke( const char * pText, int nWidth , int nHeight , - ETextAlign eAlignMask , + TextAlign eAlignMask , const char * pFontName , int nSize , float textTintR, diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index fb2146ed30..b88f95cfb6 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -240,11 +240,11 @@ public: /** * compute the start pos of every line */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) { + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); } @@ -252,12 +252,12 @@ public: return 0; } - int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){ + int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){ int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f); - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) { //vertical bottom return borderHeight - txtHeight + baseLinePos; } @@ -313,7 +313,7 @@ public: return family_name; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) { + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { if (libError) { return false; } @@ -428,7 +428,7 @@ bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, - ETextAlign eAlignMask/* = kAlignCenter*/, + TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { diff --git a/cocos2dx/platform/mac/CCImage.mm b/cocos2dx/platform/mac/CCImage.mm index 424d400232..80a1402727 100644 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -308,7 +308,7 @@ static bool _isValidFontName(const char *fontName) return ret; } -static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor) +static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor) { bool bRet = false; @@ -344,8 +344,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig // alignment, linebreak - unsigned uHoriFlag = eAlign & 0x0f; - unsigned uVertFlag = (eAlign >> 4) & 0x0f; + unsigned uHoriFlag = (int)eAlign & 0x0f; + unsigned uVertFlag = ((int)eAlign >> 4) & 0x0f; NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment : (3 == uHoriFlag) ? NSCenterTextAlignment : NSLeftTextAlignment; @@ -859,7 +859,7 @@ bool Image::initWithString( const char * pText, int nWidth, int nHeight, - ETextAlign eAlignMask, + TextAlign eAlignMask, const char * pFontName, int nSize) { diff --git a/cocos2dx/platform/nacl/CCImage.cpp b/cocos2dx/platform/nacl/CCImage.cpp index 81eb6538f3..c29109f8d4 100644 --- a/cocos2dx/platform/nacl/CCImage.cpp +++ b/cocos2dx/platform/nacl/CCImage.cpp @@ -214,7 +214,7 @@ public: * while -1 means fail * */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, FT_UInt unicode, + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, FT_UInt unicode, int iLineIndex) { int iRet; @@ -223,11 +223,11 @@ public: return -1; } - if (eAlignMask == Image::kAlignCenter) { + if (eAlignMask == Image::TextAlign::CENTER) { iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2 - SHIFT6(face->glyph->metrics.horiBearingX ); - } else if (eAlignMask == Image::kAlignRight) { + } else if (eAlignMask == Image::TextAlign::RIGHT) { iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) - SHIFT6(face->glyph->metrics.horiBearingX ); } else { @@ -237,17 +237,17 @@ public: return iRet; } - int computeLineStartY(FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight) + int computeLineStartY(FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight) { int iRet = 0; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || - eAlignMask == Image::kAlignRight ) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || + eAlignMask == Image::TextAlign::RIGHT ) { //vertical center iRet = (borderHeight - txtHeight)/2; - } else if (eAlignMask == Image::kAlignBottomRight || - eAlignMask == Image::kAlignBottom || - eAlignMask == Image::kAlignBottomLeft ) { + } else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || + eAlignMask == Image::TextAlign::BOTTOM || + eAlignMask == Image::TextAlign::BOTTOM_LEFT ) { //vertical bottom iRet = borderHeight - txtHeight; } @@ -310,7 +310,7 @@ public: return true; } - bool renderLines(FT_Face face, Image::ETextAlign eAlignMask, int iCurYCursor) + bool renderLines(FT_Face face, Image::TextAlign eAlignMask, int iCurYCursor) { size_t lines = vLines.size(); for (size_t i = 0; i < lines; i++) @@ -328,7 +328,7 @@ public: return true; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { FT_Error iError; if (libError) diff --git a/cocos2dx/platform/tizen/CCImage.cpp b/cocos2dx/platform/tizen/CCImage.cpp index 5dcb778522..fc9af7ad3a 100644 --- a/cocos2dx/platform/tizen/CCImage.cpp +++ b/cocos2dx/platform/tizen/CCImage.cpp @@ -240,11 +240,11 @@ public: /** * compute the start pos of every line */ - int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) { + int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TO_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); } @@ -252,12 +252,12 @@ public: return 0; } - int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){ + int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){ int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f); - if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) { //vertical bottom return borderHeight - txtHeight + baseLinePos; } @@ -313,7 +313,7 @@ public: return family_name; } - bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) { + bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { if (libError) { return false; } diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index f53f375c0d..15d3e2aae5 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -240,7 +240,7 @@ public: return true; } - int drawText(const char * pszText, SIZE& tSize, Image::ETextAlign eAlign) + int drawText(const char * pszText, SIZE& tSize, Image::TextAlign eAlign) { int nRet = 0; wchar_t * pwszBuffer = 0; @@ -249,8 +249,8 @@ public: CC_BREAK_IF(! pszText); DWORD dwFmt = DT_WORDBREAK; - DWORD dwHoriFlag = eAlign & 0x0f; - DWORD dwVertFlag = (eAlign & 0xf0) >> 4; + DWORD dwHoriFlag = (int)eAlign & 0x0f; + DWORD dwVertFlag = ((int)eAlign & 0xf0) >> 4; switch (dwHoriFlag) { @@ -370,7 +370,7 @@ bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, - ETextAlign eAlignMask/* = kAlignCenter*/, + TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 05c388c9ee..b80433d8c3 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -459,22 +459,22 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin #endif bool bRet = false; - Image::ETextAlign eAlign; + Image::TextAlign eAlign; if (Label::VAlignment::TOP == textDefinition._vertAlignment) { - eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignTop - : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::TOP + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::TOP_LEFT : Image::TextAlign::TOP_RIGHT; } else if (Label::VAlignment::CENTER == textDefinition._vertAlignment) { - eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignCenter - : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::CENTER + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::LEFT : Image::TextAlign::RIGHT; } else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment) { - eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignBottom - : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::BOTTOM + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOM_LEFT : Image::TextAlign::BOTTOM_RIGHT; } else { diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h index 1abbc7ef8e..fee975c2ab 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h @@ -37,15 +37,6 @@ NS_CC_BEGIN * @{ */ -typedef enum -{ - ccTouchSelectorBeganBit = 1 << 0, - ccTouchSelectorMovedBit = 1 << 1, - ccTouchSelectorEndedBit = 1 << 2, - ccTouchSelectorCancelledBit = 1 << 3, - ccTouchSelectorAllBits = ( ccTouchSelectorBeganBit | ccTouchSelectorMovedBit | ccTouchSelectorEndedBit | ccTouchSelectorCancelledBit), -} ccTouchSelectorFlag; - enum { CCTOUCHBEGAN, diff --git a/extensions/Android.mk b/extensions/Android.mk index 187b362b84..04b7079066 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -102,7 +102,8 @@ spine/SlotData.cpp \ spine/extension.cpp \ spine/CCSkeletonAnimation.cpp \ spine/CCSkeleton.cpp \ -spine/spine-cocos2dx.cpp +spine/spine-cocos2dx.cpp \ +CCDeprecated-ext.cpp LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index fe00781dfb..e1e5a06ec5 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -134,7 +134,7 @@ bool AssetsManager::checkUpdate() if (res != 0) { - sendErrorMessage(kNetwork); + sendErrorMessage(ErrorCode::NETWORK); CCLOG("can not get version file content, error code is %d", res); curl_easy_cleanup(_curl); return false; @@ -143,7 +143,7 @@ bool AssetsManager::checkUpdate() string recordedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION); if (recordedVersion == _version) { - sendErrorMessage(kNoNewVersion); + sendErrorMessage(ErrorCode::NO_NEW_VERSION); CCLOG("there is not new version"); // Set resource search path. setSearchPath(); @@ -173,7 +173,7 @@ void AssetsManager::downloadAndUncompress() // Uncompress zip file. if (! uncompress()) { - sendErrorMessage(AssetsManager::kUncompress); + sendErrorMessage(ErrorCode::UNCOMPRESS); break; } @@ -403,7 +403,7 @@ bool AssetsManager::downLoad() FILE *fp = fopen(outFileName.c_str(), "wb"); if (! fp) { - sendErrorMessage(kCreateFile); + sendErrorMessage(ErrorCode::CREATE_FILE); CCLOG("can not create file %s", outFileName.c_str()); return false; } @@ -420,7 +420,7 @@ bool AssetsManager::downLoad() curl_easy_cleanup(_curl); if (res != 0) { - sendErrorMessage(kNetwork); + sendErrorMessage(ErrorCode::NETWORK); CCLOG("error when download package"); fclose(fp); return false; diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index 46f50ebe71..b150e073e0 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -44,19 +44,19 @@ class AssetsManagerDelegateProtocol; class AssetsManager { public: - enum ErrorCode + enum class ErrorCode { // Error caused by creating a file to store downloaded data - kCreateFile, + CREATE_FILE, /** Error caused by network -- network unavaivable -- timeout -- ... */ - kNetwork, + NETWORK, /** There is not a new version */ - kNoNewVersion, + NO_NEW_VERSION, /** Error caused in uncompressing stage -- can not open zip file -- can not read file global information @@ -64,7 +64,7 @@ public: -- can not create a directory -- ... */ - kUncompress, + UNCOMPRESS, }; /* @brief Creates a AssetsManager with new package url, version code url and storage path. diff --git a/extensions/CCBReader/CCBSelectorResolver.h b/extensions/CCBReader/CCBSelectorResolver.h index 2eb6ae06d8..370286cd51 100644 --- a/extensions/CCBReader/CCBSelectorResolver.h +++ b/extensions/CCBReader/CCBSelectorResolver.h @@ -25,7 +25,7 @@ class CCBSelectorResolver { virtual ~CCBSelectorResolver() {}; virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0; virtual SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; }; - virtual SEL_CCControlHandler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0; + virtual Control::Handler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0; }; diff --git a/extensions/CCBReader/CCControlButtonLoader.cpp b/extensions/CCBReader/CCControlButtonLoader.cpp index d477a7decf..3b71ee5d78 100644 --- a/extensions/CCBReader/CCControlButtonLoader.cpp +++ b/extensions/CCBReader/CCControlButtonLoader.cpp @@ -32,11 +32,11 @@ void ControlButtonLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, co void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { - ((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateNormal); + ((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { - ((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateHighlighted); + ((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) { - ((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateDisabled); + ((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); } @@ -44,11 +44,11 @@ void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, c void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) { - ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateNormal); + ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { - ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateHighlighted); + ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) { - ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateDisabled); + ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); } @@ -56,11 +56,11 @@ void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) { - ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateNormal); + ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { - ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateHighlighted); + ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) { - ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateDisabled); + ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); } @@ -85,15 +85,15 @@ void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, con void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(pSpriteFrame != NULL) { - ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateNormal); + ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL); } } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { if(pSpriteFrame != NULL) { - ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateHighlighted); + ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED); } } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { if(pSpriteFrame != NULL) { - ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateDisabled); + ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED); } } else { ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, pCCBReader); @@ -102,11 +102,11 @@ void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pPare void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) { - ((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateNormal); + ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { - ((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateHighlighted); + ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) { - ((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateDisabled); + ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, pCCBReader); } diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 1090787909..22ccb69fb3 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -811,7 +811,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP if(target != NULL) { if(selectorName.length() > 0) { - SEL_CCControlHandler selControlHandler = 0; + Control::Handler selControlHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); @@ -832,7 +832,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP blockControlData->mSELControlHandler = selControlHandler; blockControlData->mTarget = target; - blockControlData->mControlEvents = controlEvents; + blockControlData->mControlEvents = (Control::EventType)controlEvents; return blockControlData; } diff --git a/extensions/CCBReader/CCNodeLoader.h b/extensions/CCBReader/CCNodeLoader.h index be45ea67d2..2d468f189a 100644 --- a/extensions/CCBReader/CCNodeLoader.h +++ b/extensions/CCBReader/CCNodeLoader.h @@ -5,6 +5,7 @@ #include "cocos2d.h" #include "CCBReader.h" #include "CCBValue.h" +#include "../GUI/CCControlExtension/CCControl.h" NS_CC_EXT_BEGIN @@ -35,9 +36,9 @@ struct BlockData { }; struct BlockControlData { - SEL_CCControlHandler mSELControlHandler; + Control::Handler mSELControlHandler; Object * mTarget; - int mControlEvents; + Control::EventType mControlEvents; }; /* Forward declaration. */ diff --git a/extensions/CCBReader/CCScrollViewLoader.cpp b/extensions/CCBReader/CCScrollViewLoader.cpp index 12a636eab5..4380dcba10 100644 --- a/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/extensions/CCBReader/CCScrollViewLoader.cpp @@ -47,7 +47,7 @@ void ScrollViewLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const void ScrollViewLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_DIRECTION) == 0) { - ((ScrollView *)pNode)->setDirection(ScrollViewDirection(pIntegerLabeled)); + ((ScrollView *)pNode)->setDirection(ScrollView::Direction(pIntegerLabeled)); } else { NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } diff --git a/extensions/CCDeprecated-ext.cpp b/extensions/CCDeprecated-ext.cpp new file mode 100644 index 0000000000..efa1e560b8 --- /dev/null +++ b/extensions/CCDeprecated-ext.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "cocos-ext.h" + + NS_CC_EXT_BEGIN + +const Control::EventType CCControlEventTouchDown = Control::EventType::TOUCH_DOWN; +const Control::EventType CCControlEventTouchDragInside = Control::EventType::DRAG_INSIDE; +const Control::EventType CCControlEventTouchDragOutside = Control::EventType::DRAG_OUTSIDE; +const Control::EventType CCControlEventTouchDragEnter = Control::EventType::DRAG_ENTER; +const Control::EventType CCControlEventTouchDragExit = Control::EventType::DRAG_EXIT; +const Control::EventType CCControlEventTouchUpInside = Control::EventType::TOUCH_UP_INSIDE; +const Control::EventType CCControlEventTouchUpOutside = Control::EventType::TOUCH_UP_OUTSIDE; +const Control::EventType CCControlEventTouchCancel = Control::EventType::TOUCH_CANCEL; +const Control::EventType CCControlEventValueChanged = Control::EventType::VALUE_CHANGED; + +const Control::State CCControlStateNormal = Control::State::NORMAL; +const Control::State CCControlStateHighlighted = Control::State::HIGH_LIGHTED; +const Control::State CCControlStateDisabled = Control::State::DISABLED; +const Control::State CCControlStateSelected = Control::State::SELECTED; + +const EditBox::KeyboardReturnType kKeyboardReturnTypeDefault = EditBox::KeyboardReturnType::DEFAULT; +const EditBox::KeyboardReturnType kKeyboardReturnTypeDone = EditBox::KeyboardReturnType::DONE; +const EditBox::KeyboardReturnType kKeyboardReturnTypeSend = EditBox::KeyboardReturnType::SEND; +const EditBox::KeyboardReturnType kKeyboardReturnTypeSearch = EditBox::KeyboardReturnType::SEARCH; +const EditBox::KeyboardReturnType kKeyboardReturnTypeGo = EditBox::KeyboardReturnType::GO; + +const EditBox::InputMode kEditBoxInputModeAny = EditBox::InputMode::ANY; +const EditBox::InputMode kEditBoxInputModeEmailAddr = EditBox::InputMode::EMAIL_ADDRESS; +const EditBox::InputMode kEditBoxInputModeNumeric = EditBox::InputMode::NUMERIC; +const EditBox::InputMode kEditBoxInputModePhoneNumber = EditBox::InputMode::PHONE_NUMBER; +const EditBox::InputMode kEditBoxInputModeUrl = EditBox::InputMode::URL; +const EditBox::InputMode kEditBoxInputModeDecimal = EditBox::InputMode::DECIMAL; +const EditBox::InputMode kEditBoxInputModeSingleLine = EditBox::InputMode::SINGLE_LINE; + +const EditBox::InputFlag kEditBoxInputFlagPassword = EditBox::InputFlag::PASSWORD; +const EditBox::InputFlag kEditBoxInputFlagSensitive = EditBox::InputFlag::SENSITIVE; +const EditBox::InputFlag kEditBoxInputFlagInitialCapsWord = EditBox::InputFlag::INITIAL_CAPS_WORD; +const EditBox::InputFlag kEditBoxInputFlagInitialCapsSentence = EditBox::InputFlag::INITIAL_CAPS_SENTENCE; +const EditBox::InputFlag kEditBoxInputFlagInitialCapsAllCharacters = EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS; + + +const ScrollView::Direction kCCScrollViewDirectionNone = ScrollView::Direction::NONE; +const ScrollView::Direction kCCScrollViewDirectionHorizontal = ScrollView::Direction::HORIZONTAL; +const ScrollView::Direction kCCScrollViewDirectionVertical = ScrollView::Direction::VERTICAL; +const ScrollView::Direction kCCScrollViewDirectionBoth = ScrollView::Direction::BOTH; + +const TableView::VerticalFillOrder kCCTableViewFillTopDown = TableView::VerticalFillOrder::TOP_DOWN; +const TableView::VerticalFillOrder kCCTableViewFillBottomUp = TableView::VerticalFillOrder::BOTTOM_UP; + + +NS_CC_EXT_END diff --git a/extensions/CCDeprecated-ext.h b/extensions/CCDeprecated-ext.h index 8c93828447..f5da5f3376 100644 --- a/extensions/CCDeprecated-ext.h +++ b/extensions/CCDeprecated-ext.h @@ -117,54 +117,72 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentTimeline CCAttachmentTimeline; CC_DEPRECATED_ATTRIBUTE typedef AtlasAttachmentLoader CCAtlasAttachmentLoader; CC_DEPRECATED_ATTRIBUTE typedef VertexIndex CCVertexIndex; CC_DEPRECATED_ATTRIBUTE typedef RegionAttachment CCRegionAttachment; -CC_DEPRECATED_ATTRIBUTE typedef ScrollViewDirection CCScrollViewDirection; -CC_DEPRECATED_ATTRIBUTE typedef TableViewVerticalFillOrder CCTableViewVerticalFillOrder; + CC_DEPRECATED_ATTRIBUTE typedef ControlStepperPart CCControlStepperPart; -CC_DEPRECATED_ATTRIBUTE typedef ControlEvent CCControlEvent; -CC_DEPRECATED_ATTRIBUTE typedef ControlState CCControlState; CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMap CCNodeLoaderMap; CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMapEntry CCNodeLoaderMapEntry; CC_DEPRECATED_ATTRIBUTE typedef EventRegistry CCEventRegistry; CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType; -#define kCCTableViewFillTopDown kTableViewFillTopDown -#define kCCTableViewFillBottomUp kTableViewFillBottomUp -#define kCCScrollViewDirectionNone kScrollViewDirectionNone -#define kCCScrollViewDirectionHorizontal kScrollViewDirectionHorizontal -#define kCCScrollViewDirectionVertical kScrollViewDirectionVertical -#define kCCScrollViewDirectionBoth kScrollViewDirectionBoth -#define kCCKeyboardReturnTypeDefault kKeyboardReturnTypeDefault -#define kCCKeyboardReturnTypeDone kKeyboardReturnTypeDone -#define kCCKeyboardReturnTypeSend kKeyboardReturnTypeSend -#define kCCKeyboardReturnTypeSearch kKeyboardReturnTypeSearch -#define kCCKeyboardReturnTypeGo kKeyboardReturnTypeGo +CC_DEPRECATED_ATTRIBUTE typedef ScrollView::Direction CCScrollViewDirection; +CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionNone; +CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionHorizontal; +CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionVertical; +CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionBoth; -#define kCCEditBoxInputModeAny kEditBoxInputModeAny -#define kCCEditBoxInputModeEmailAddr kEditBoxInputModeEmailAddr -#define kCCEditBoxInputModeNumeric kEditBoxInputModeNumeric -#define kCCEditBoxInputModePhoneNumber kEditBoxInputModePhoneNumber -#define kCCEditBoxInputModeUrl kEditBoxInputModeUrl -#define kCCEditBoxInputModeDecimal kEditBoxInputModeDecimal -#define kCCEditBoxInputModeSingleLine kEditBoxInputModeSingleLine + +CC_DEPRECATED_ATTRIBUTE typedef TableView::VerticalFillOrder CCTableViewVerticalFillOrder; +CC_DEPRECATED_ATTRIBUTE extern const TableView::VerticalFillOrder kCCTableViewFillTopDown; +CC_DEPRECATED_ATTRIBUTE extern const TableView::VerticalFillOrder kCCTableViewFillBottomUp; + + +CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeDefault; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeDone; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeSend; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeSearch; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeGo; + +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeAny; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeEmailAddr; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeNumeric; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModePhoneNumber; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeUrl; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeDecimal; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeSingleLine; + +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagPassword; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagSensitive; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsWord; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsSentence; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsAllCharacters; + +CC_DEPRECATED_ATTRIBUTE typedef EditBox::KeyboardReturnType KeyboardReturnType; +CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputMode EditBoxInputMode; +CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputFlag EditBoxInputFlag; #define kCCControlStepperPartMinus kControlStepperPartMinus #define kCCControlStepperPartPlus kControlStepperPartPlus #define kCCControlStepperPartNone kControlStepperPartNone -#define CCControlEventTouchDown ControlEventTouchDown -#define CCControlEventTouchDragInside ControlEventTouchDragInside -#define CCControlEventTouchDragOutside ControlEventTouchDragOutside -#define CCControlEventTouchDragEnter ControlEventTouchDragEnter -#define CCControlEventTouchDragExit ControlEventTouchDragExit -#define CCControlEventTouchUpInside ControlEventTouchUpInside -#define CCControlEventTouchUpOutside ControlEventTouchUpOutside -#define CCControlEventTouchCancel ControlEventTouchCancel -#define CCControlEventValueChanged ControlEventValueChanged +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDown; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragInside; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragOutside; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragEnter; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragExit; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpInside; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpOutside; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchCancel; +CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventValueChanged; +CC_DEPRECATED_ATTRIBUTE typedef Control::EventType CCControlEvent; + +CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateNormal; +CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateHighlighted; +CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateDisabled; +CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateSelected; +CC_DEPRECATED_ATTRIBUTE typedef Control::State CCControlState; + +CC_DEPRECATED_ATTRIBUTE typedef Control::Handler SEL_CCControlHandler; -#define CCControlStateNormal ControlStateNormal -#define CCControlStateHighlighted ControlStateHighlighted -#define CCControlStateDisabled ControlStateDisabled -#define CCControlStateSelected ControlStateSelected #define kCCCreateFile kCreateFile #define kCCNetwork kNetwork diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 00a33c9053..b32ee30225 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -32,12 +32,13 @@ #include "touch_dispatcher/CCTouchDispatcher.h" #include "menu_nodes/CCMenu.h" #include "touch_dispatcher/CCTouch.h" +#include "CCInvocation.h" NS_CC_EXT_BEGIN Control::Control() : _isOpacityModifyRGB(false) -, _state(ControlStateNormal) +, _state(State::NORMAL) , _hasVisibleParents(false) , _enabled(false) , _selected(false) @@ -69,7 +70,7 @@ bool Control::init() //this->setTouchEnabled(true); //_isTouchEnabled=true; // Initialise instance variables - _state=ControlStateNormal; + _state=Control::State::NORMAL; setEnabled(true); setSelected(false); setHighlighted(false); @@ -108,17 +109,17 @@ void Control::onExit() Layer::onExit(); } -void Control::sendActionsForControlEvents(ControlEvent controlEvents) +void Control::sendActionsForControlEvents(EventType controlEvents) { // For each control events for (int i = 0; i < kControlEventTotalNumber; i++) { // If the given controlEvents bitmask contains the curent event - if ((controlEvents & (1 << i))) + if (((int)controlEvents & (1 << i))) { // Call invocations // - Array* invocationList = this->dispatchListforControlEvent(1<dispatchListforControlEvent((Control::EventType)(1<addTargetWithActionForControlEvent(target, action, 1<addTargetWithActionForControlEvent(target, action, (EventType)(1<addObject(invocation); } -void Control::removeTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents) +void Control::removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents) { // For each control events for (int i = 0; i < kControlEventTotalNumber; i++) { // If the given controlEvents bitmask contains the curent event - if ((controlEvents & (1 << i))) + if (((int)controlEvents & (1 << i))) { - this->removeTargetWithActionForControlEvent(target, action, 1 << i); + this->removeTargetWithActionForControlEvent(target, action, (EventType)(1 << i)); } } } -void Control::removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent) +void Control::removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent) { // Retrieve all invocations for the given control event // @@ -264,15 +265,15 @@ bool Control::isTouchInside(Touch* touch) return bBox.containsPoint(touchLocation); } -Array* Control::dispatchListforControlEvent(ControlEvent controlEvent) +Array* Control::dispatchListforControlEvent(EventType controlEvent) { - Array* invocationList = (Array*)_dispatchTable->objectForKey(controlEvent); + Array* invocationList = (Array*)_dispatchTable->objectForKey((int)controlEvent); // If the invocation list does not exist for the dispatch table, we create it if (invocationList == NULL) { invocationList = Array::createWithCapacity(1); - _dispatchTable->setObject(invocationList, controlEvent); + _dispatchTable->setObject(invocationList, (int)controlEvent); } return invocationList; } @@ -285,9 +286,9 @@ void Control::setEnabled(bool bEnabled) { _enabled = bEnabled; if(_enabled) { - _state = ControlStateNormal; + _state = Control::State::NORMAL; } else { - _state = ControlStateDisabled; + _state = Control::State::DISABLED; } this->needsLayout(); diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 61173936b9..021ae6d99f 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -30,12 +30,13 @@ #ifndef __CCCONTROL_H__ #define __CCCONTROL_H__ -#include "CCInvocation.h" #include "CCControlUtils.h" #include "cocos2d.h" NS_CC_EXT_BEGIN + + class Invocation; /** @@ -48,30 +49,6 @@ class Invocation; /** Number of kinds of control event. */ #define kControlEventTotalNumber 9 -/** Kinds of possible events for the control objects. */ -enum -{ - ControlEventTouchDown = 1 << 0, // A touch-down event in the control. - ControlEventTouchDragInside = 1 << 1, // An event where a finger is dragged inside the bounds of the control. - ControlEventTouchDragOutside = 1 << 2, // An event where a finger is dragged just outside the bounds of the control. - ControlEventTouchDragEnter = 1 << 3, // An event where a finger is dragged into the bounds of the control. - ControlEventTouchDragExit = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds. - ControlEventTouchUpInside = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control. - ControlEventTouchUpOutside = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control. - ControlEventTouchCancel = 1 << 7, // A system event canceling the current touches for the control. - ControlEventValueChanged = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values. -}; -typedef unsigned int ControlEvent; - -/** The possible state for a control. */ -enum -{ - ControlStateNormal = 1 << 0, // The normal, or default state of a control¡ªthat is, enabled but neither selected nor highlighted. - ControlStateHighlighted = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property. - ControlStateDisabled = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property. - ControlStateSelected = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property. -}; -typedef unsigned int ControlState; /* * @class @@ -88,6 +65,31 @@ typedef unsigned int ControlState; class Control : public LayerRGBA { public: + /** Kinds of possible events for the control objects. */ + enum class EventType + { + TOUCH_DOWN = 1 << 0, // A touch-down event in the control. + DRAG_INSIDE = 1 << 1, // An event where a finger is dragged inside the bounds of the control. + DRAG_OUTSIDE = 1 << 2, // An event where a finger is dragged just outside the bounds of the control. + DRAG_ENTER = 1 << 3, // An event where a finger is dragged into the bounds of the control. + DRAG_EXIT = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds. + TOUCH_UP_INSIDE = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control. + TOUCH_UP_OUTSIDE = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control. + TOUCH_CANCEL = 1 << 7, // A system event canceling the current touches for the control. + VALUE_CHANGED = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values. + }; + + typedef void (Object::*Handler)(Object*, EventType); + + /** The possible state for a control. */ + enum class State + { + NORMAL = 1 << 0, // The normal, or default state of a control¡ªthat is, enabled but neither selected nor highlighted. + HIGH_LIGHTED = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property. + DISABLED = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property. + SELECTED = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property. + }; + static Control* create(); Control(); @@ -118,7 +120,7 @@ public: * @param controlEvents A bitmask whose set flags specify the control events for * which action messages are sent. See "CCControlEvent" for bitmask constants. */ - virtual void sendActionsForControlEvents(ControlEvent controlEvents); + virtual void sendActionsForControlEvents(EventType controlEvents); /** * Adds a target and action for a particular event (or events) to an internal @@ -133,7 +135,7 @@ public: * @param controlEvents A bitmask specifying the control events for which the * action message is sent. See "CCControlEvent" for bitmask constants. */ - virtual void addTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents); + virtual void addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents); /** * Removes a target and action for a particular event (or events) from an @@ -147,7 +149,7 @@ public: * @param controlEvents A bitmask specifying the control events associated with * target and action. See "CCControlEvent" for bitmask constants. */ - virtual void removeTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents); + virtual void removeTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents); /** * Returns a point corresponding to the touh location converted into the @@ -187,7 +189,7 @@ protected: * @return an Invocation object able to construct messages using a given * target-action pair. */ - Invocation* invocationWithTargetAndActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent); + Invocation* invocationWithTargetAndActionForControlEvent(Object* target, Handler action, EventType controlEvent); /** * Returns the Invocation list for the given control event. If the list does @@ -199,7 +201,7 @@ protected: * @return the Invocation list for the given control event. */ // - Array* dispatchListforControlEvent(ControlEvent controlEvent); + Array* dispatchListforControlEvent(EventType controlEvent); /** * Adds a target and action for a particular event to an internal dispatch @@ -214,7 +216,7 @@ protected: * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ - void addTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent); + void addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent); /** * Removes a target and action for a particular event from an internal dispatch @@ -228,7 +230,7 @@ protected: * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ - void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent); + void removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent); protected: bool _enabled; @@ -249,7 +251,7 @@ protected: bool _isOpacityModifyRGB; /** The current control state constant. */ - CC_SYNTHESIZE_READONLY(ControlState, _state, State); + CC_SYNTHESIZE_READONLY(State, _state, State); }; // end of GUI group diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 56df39b0af..7f3a521612 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -125,10 +125,10 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b String* tempString = String::create(label->getString()); //tempString->autorelease(); - setTitleForState(tempString, ControlStateNormal); - setTitleColorForState(rgbaLabel->getColor(), ControlStateNormal); - setTitleLabelForState(node, ControlStateNormal); - setBackgroundSpriteForState(backgroundSprite, ControlStateNormal); + setTitleForState(tempString, Control::State::NORMAL); + setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL); + setTitleLabelForState(node, Control::State::NORMAL); + setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL); setLabelAnchorPoint(Point(0.5f, 0.5f)); @@ -204,11 +204,11 @@ void ControlButton::setHighlighted(bool enabled) { if (enabled == true) { - _state = ControlStateHighlighted; + _state = Control::State::HIGH_LIGHTED; } else { - _state = ControlStateNormal; + _state = Control::State::NORMAL; } Control::setHighlighted(enabled); @@ -289,27 +289,27 @@ void ControlButton::setLabelAnchorPoint(Point labelAnchorPoint) } } -String* ControlButton::getTitleForState(ControlState state) +String* ControlButton::getTitleForState(State state) { if (_titleDispatchTable != NULL) { - String* title=(String*)_titleDispatchTable->objectForKey(state); + String* title=(String*)_titleDispatchTable->objectForKey((int)state); if (title) { return title; } - return (String*)_titleDispatchTable->objectForKey(ControlStateNormal); + return (String*)_titleDispatchTable->objectForKey((int)Control::State::NORMAL); } return String::create(""); } -void ControlButton::setTitleForState(String* title, ControlState state) +void ControlButton::setTitleForState(String* title, State state) { - _titleDispatchTable->removeObjectForKey(state); + _titleDispatchTable->removeObjectForKey((int)state); if (title) { - _titleDispatchTable->setObject(title, state); + _titleDispatchTable->setObject(title, (int)state); } // If the current state if equal to the given state we update the layout @@ -320,20 +320,20 @@ void ControlButton::setTitleForState(String* title, ControlState state) } -Color3B ControlButton::getTitleColorForState(ControlState state) const +Color3B ControlButton::getTitleColorForState(State state) const { Color3B returnColor = Color3B::WHITE; do { CC_BREAK_IF(NULL == _titleColorDispatchTable); - Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey(state); + Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey((int)state); if (colorObject) { returnColor = colorObject->value; break; } - colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey(ControlStateNormal); + colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey((int)Control::State::NORMAL); if (colorObject) { returnColor = colorObject->value; @@ -343,13 +343,13 @@ Color3B ControlButton::getTitleColorForState(ControlState state) const return returnColor; } -void ControlButton::setTitleColorForState(Color3B color, ControlState state) +void ControlButton::setTitleColorForState(Color3B color, State state) { //Color3B* colorValue=&color; - _titleColorDispatchTable->removeObjectForKey(state); + _titleColorDispatchTable->removeObjectForKey((int)state); Color3bObject* pColor3bObject = new Color3bObject(color); pColor3bObject->autorelease(); - _titleColorDispatchTable->setObject(pColor3bObject, state); + _titleColorDispatchTable->setObject(pColor3bObject, (int)state); // If the current state if equal to the given state we update the layout if (getState() == state) @@ -358,26 +358,26 @@ void ControlButton::setTitleColorForState(Color3B color, ControlState state) } } -Node* ControlButton::getTitleLabelForState(ControlState state) +Node* ControlButton::getTitleLabelForState(State state) { - Node* titleLabel = (Node*)_titleLabelDispatchTable->objectForKey(state); + Node* titleLabel = (Node*)_titleLabelDispatchTable->objectForKey((int)state); if (titleLabel) { return titleLabel; } - return (Node*)_titleLabelDispatchTable->objectForKey(ControlStateNormal); + return (Node*)_titleLabelDispatchTable->objectForKey((int)Control::State::NORMAL); } -void ControlButton::setTitleLabelForState(Node* titleLabel, ControlState state) +void ControlButton::setTitleLabelForState(Node* titleLabel, State state) { - Node* previousLabel = (Node*)_titleLabelDispatchTable->objectForKey(state); + Node* previousLabel = (Node*)_titleLabelDispatchTable->objectForKey((int)state); if (previousLabel) { removeChild(previousLabel, true); - _titleLabelDispatchTable->removeObjectForKey(state); + _titleLabelDispatchTable->removeObjectForKey((int)state); } - _titleLabelDispatchTable->setObject(titleLabel, state); + _titleLabelDispatchTable->setObject(titleLabel, (int)state); titleLabel->setVisible(false); titleLabel->setAnchorPoint(Point(0.5f, 0.5f)); addChild(titleLabel, 1); @@ -389,7 +389,7 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, ControlState state) } } -void ControlButton::setTitleTTFForState(const char * fntFile, ControlState state) +void ControlButton::setTitleTTFForState(const char * fntFile, State state) { String * title = this->getTitleForState(state); if (!title) @@ -399,7 +399,7 @@ void ControlButton::setTitleTTFForState(const char * fntFile, ControlState state this->setTitleLabelForState(LabelTTF::create(title->getCString(), fntFile, 12), state); } -const char * ControlButton::getTitleTTFForState(ControlState state) +const char * ControlButton::getTitleTTFForState(State state) { LabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); LabelTTF* labelTTF = dynamic_cast(label); @@ -413,7 +413,7 @@ const char * ControlButton::getTitleTTFForState(ControlState state) } } -void ControlButton::setTitleTTFSizeForState(float size, ControlState state) +void ControlButton::setTitleTTFSizeForState(float size, State state) { LabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); if(label) @@ -426,7 +426,7 @@ void ControlButton::setTitleTTFSizeForState(float size, ControlState state) } } -float ControlButton::getTitleTTFSizeForState(ControlState state) +float ControlButton::getTitleTTFSizeForState(State state) { LabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); LabelTTF* labelTTF = dynamic_cast(label); @@ -440,7 +440,7 @@ float ControlButton::getTitleTTFSizeForState(ControlState state) } } -void ControlButton::setTitleBMFontForState(const char * fntFile, ControlState state) +void ControlButton::setTitleBMFontForState(const char * fntFile, State state) { String * title = this->getTitleForState(state); if (!title) @@ -450,7 +450,7 @@ void ControlButton::setTitleBMFontForState(const char * fntFile, ControlState st this->setTitleLabelForState(LabelBMFont::create(title->getCString(), fntFile), state); } -const char * ControlButton::getTitleBMFontForState(ControlState state) +const char * ControlButton::getTitleBMFontForState(State state) { LabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); LabelBMFont* labelBMFont = dynamic_cast(label); @@ -465,29 +465,29 @@ const char * ControlButton::getTitleBMFontForState(ControlState state) } -Scale9Sprite* ControlButton::getBackgroundSpriteForState(ControlState state) +Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state) { - Scale9Sprite* backgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(state); + Scale9Sprite* backgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)state); if (backgroundSprite) { return backgroundSprite; } - return (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(ControlStateNormal); + return (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)Control::State::NORMAL); } -void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, ControlState state) +void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, State state) { Size oldPreferredSize = _preferredSize; - Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(state); + Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)state); if (previousBackgroundSprite) { removeChild(previousBackgroundSprite, true); - _backgroundSpriteDispatchTable->removeObjectForKey(state); + _backgroundSpriteDispatchTable->removeObjectForKey((int)state); } - _backgroundSpriteDispatchTable->setObject(sprite, state); + _backgroundSpriteDispatchTable->setObject(sprite, (int)state); sprite->setVisible(false); sprite->setAnchorPoint(Point(0.5f, 0.5f)); addChild(sprite); @@ -510,7 +510,7 @@ void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, ControlSta } } -void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, ControlState state) +void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state) { Scale9Sprite * sprite = Scale9Sprite::createWithSpriteFrame(spriteFrame); this->setBackgroundSpriteForState(sprite, state); @@ -647,7 +647,7 @@ bool ControlButton::ccTouchBegan(Touch *pTouch, Event *pEvent) _isPushed = true; this->setHighlighted(true); - sendActionsForControlEvents(ControlEventTouchDown); + sendActionsForControlEvents(Control::EventType::TOUCH_DOWN); return true; } @@ -666,21 +666,21 @@ void ControlButton::ccTouchMoved(Touch *pTouch, Event *pEvent) if (isTouchMoveInside && !isHighlighted()) { setHighlighted(true); - sendActionsForControlEvents(ControlEventTouchDragEnter); + sendActionsForControlEvents(Control::EventType::DRAG_ENTER); } else if (isTouchMoveInside && isHighlighted()) { - sendActionsForControlEvents(ControlEventTouchDragInside); + sendActionsForControlEvents(Control::EventType::DRAG_INSIDE); } else if (!isTouchMoveInside && isHighlighted()) { setHighlighted(false); - sendActionsForControlEvents(ControlEventTouchDragExit); + sendActionsForControlEvents(Control::EventType::DRAG_EXIT); } else if (!isTouchMoveInside && !isHighlighted()) { - sendActionsForControlEvents(ControlEventTouchDragOutside); + sendActionsForControlEvents(Control::EventType::DRAG_OUTSIDE); } } void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent) @@ -691,11 +691,11 @@ void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent) if (isTouchInside(pTouch)) { - sendActionsForControlEvents(ControlEventTouchUpInside); + sendActionsForControlEvents(Control::EventType::TOUCH_UP_INSIDE); } else { - sendActionsForControlEvents(ControlEventTouchUpOutside); + sendActionsForControlEvents(Control::EventType::TOUCH_UP_OUTSIDE); } } @@ -749,7 +749,7 @@ void ControlButton::ccTouchCancelled(Touch *pTouch, Event *pEvent) { _isPushed = false; setHighlighted(false); - sendActionsForControlEvents(ControlEventTouchCancel); + sendActionsForControlEvents(Control::EventType::TOUCH_CANCEL); } ControlButton* ControlButton::create() diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 43cac17ccf..303e2f0751 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -82,7 +82,7 @@ public: * * @return The title for the specified state. */ - virtual String* getTitleForState(ControlState state); + virtual String* getTitleForState(State state); /** * Sets the title string to use for the specified state. @@ -93,7 +93,7 @@ public: * @param state The state that uses the specified title. The values are described * in "CCControlState". */ - virtual void setTitleForState(String* title, ControlState state); + virtual void setTitleForState(String* title, State state); /** * Returns the title color used for a state. @@ -104,7 +104,7 @@ public: * @return The color of the title for the specified state. */ - virtual Color3B getTitleColorForState(ControlState state) const; + virtual Color3B getTitleColorForState(State state) const; /** * Sets the color of the title to use for the specified state. @@ -113,7 +113,7 @@ public: * @param state The state that uses the specified color. The values are described * in "CCControlState". */ - virtual void setTitleColorForState(Color3B color, ControlState state); + virtual void setTitleColorForState(Color3B color, State state); /** * Returns the title label used for a state. @@ -121,7 +121,7 @@ public: * @param state The state that uses the title label. Possible values are described * in "CCControlState". */ - virtual Node* getTitleLabelForState(ControlState state); + virtual Node* getTitleLabelForState(State state); /** * Sets the title label to use for the specified state. @@ -132,13 +132,13 @@ public: * @param state The state that uses the specified title. The values are described * in "CCControlState". */ - virtual void setTitleLabelForState(Node* label, ControlState state); + virtual void setTitleLabelForState(Node* label, State state); - virtual void setTitleTTFForState(const char * fntFile, ControlState state); - virtual const char * getTitleTTFForState(ControlState state); + virtual void setTitleTTFForState(const char * fntFile, State state); + virtual const char * getTitleTTFForState(State state); - virtual void setTitleTTFSizeForState(float size, ControlState state); - virtual float getTitleTTFSizeForState(ControlState state); + virtual void setTitleTTFSizeForState(float size, State state); + virtual float getTitleTTFSizeForState(State state); /** * Sets the font of the label, changes the label to a LabelBMFont if neccessary. @@ -146,8 +146,8 @@ public: * @param state The state that uses the specified fntFile. The values are described * in "CCControlState". */ - virtual void setTitleBMFontForState(const char * fntFile, ControlState state); - virtual const char * getTitleBMFontForState(ControlState state); + virtual void setTitleBMFontForState(const char * fntFile, State state); + virtual const char * getTitleBMFontForState(State state); /** * Returns the background sprite used for a state. @@ -155,7 +155,7 @@ public: * @param state The state that uses the background sprite. Possible values are * described in "CCControlState". */ - virtual Scale9Sprite* getBackgroundSpriteForState(ControlState state); + virtual Scale9Sprite* getBackgroundSpriteForState(State state); /** * Sets the background sprite to use for the specified button state. @@ -164,7 +164,7 @@ public: * @param state The state that uses the specified image. The values are described * in "CCControlState". */ - virtual void setBackgroundSpriteForState(Scale9Sprite* sprite, ControlState state); + virtual void setBackgroundSpriteForState(Scale9Sprite* sprite, State state); /** * Sets the background spriteFrame to use for the specified button state. @@ -173,16 +173,16 @@ public: * @param state The state that uses the specified image. The values are described * in "CCControlState". */ - virtual void setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, ControlState state); + virtual void setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state); //set the margins at once (so we only have to do one call of needsLayout) virtual void setMargins(int marginH, int marginV); // Overrides - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) override; - virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) override; - virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) override; - virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) override; + virtual bool ccTouchBegan(Touch *pTouch, cocos2d::Event *pEvent) override; + virtual void ccTouchMoved(Touch *pTouch, cocos2d::Event *pEvent) override; + virtual void ccTouchEnded(Touch *pTouch, cocos2d::Event *pEvent) override; + virtual void ccTouchCancelled(Touch *pTouch, cocos2d::Event *pEvent) override; virtual GLubyte getOpacity(void) const override; virtual void setOpacity(GLubyte var) override; virtual const Color3B& getColor(void) const override; diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index 75258f1809..9d17616dbe 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -92,8 +92,8 @@ bool ControlColourPicker::init() _colourPicker->initWithTargetAndPos(spriteSheet, Point(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events - _huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), ControlEventValueChanged); - _colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), ControlEventValueChanged); + _huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), Control::EventType::VALUE_CHANGED); + _colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), Control::EventType::VALUE_CHANGED); // Set defaults updateHueAndControlPicker(); @@ -146,7 +146,7 @@ void ControlColourPicker::setEnabled(bool enabled) } -//need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to ControlEventValueChanged) +//need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to Control::EventType::VALUE_CHANGED) void ControlColourPicker::updateControlPicker() { _huePicker->setHue(_hsv.h); @@ -161,7 +161,7 @@ void ControlColourPicker::updateHueAndControlPicker() } -void ControlColourPicker::hueSliderValueChanged(Object * sender, ControlEvent controlEvent) +void ControlColourPicker::hueSliderValueChanged(Object * sender, Control::EventType controlEvent) { _hsv.h = ((ControlHuePicker*)sender)->getHue(); @@ -171,11 +171,11 @@ void ControlColourPicker::hueSliderValueChanged(Object * sender, ControlEvent co Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f))); // Send Control callback - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); updateControlPicker(); } -void ControlColourPicker::colourSliderValueChanged(Object * sender, ControlEvent controlEvent) +void ControlColourPicker::colourSliderValueChanged(Object * sender, Control::EventType controlEvent) { _hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation(); _hsv.v=((ControlSaturationBrightnessPicker*)sender)->getBrightness(); @@ -187,7 +187,7 @@ void ControlColourPicker::colourSliderValueChanged(Object * sender, ControlEvent Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f))); // Send Control callback - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } //ignore all touches, handled by children diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/extensions/GUI/CCControlExtension/CCControlColourPicker.h index 47750a7e64..24fbdb2cb6 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -61,8 +61,8 @@ public: virtual void setEnabled(bool bEnabled); //virtual ~ControlColourPicker(); - void hueSliderValueChanged(Object * sender, ControlEvent controlEvent); - void colourSliderValueChanged(Object * sender, ControlEvent controlEvent); + void hueSliderValueChanged(Object * sender, Control::EventType controlEvent); + void colourSliderValueChanged(Object * sender, Control::EventType controlEvent); protected: void updateControlPicker(); diff --git a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp index 59c297e468..8212d5fe9f 100644 --- a/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlHuePicker.cpp @@ -147,7 +147,7 @@ void ControlHuePicker::updateSliderPosition(Point location) setHue(angleDeg); // send Control callback - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } bool ControlHuePicker::checkSliderPosition(Point location) @@ -186,7 +186,7 @@ void ControlHuePicker::ccTouchMoved(Touch* touch, Event* event) //small modification: this allows changing of the colour, even if the touch leaves the bounding area // updateSliderPosition(touchLocation); -// sendActionsForControlEvents(ControlEventValueChanged); +// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); // Check the touch position on the slider checkSliderPosition(touchLocation); } diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp index 2679618f88..fdc957e608 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -126,7 +126,7 @@ void ControlPotentiometer::setValue(float value) _progressTimer->setPercentage(percent * 100.0f); _thumbSprite->setRotation(percent * 360.0f); - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } float ControlPotentiometer::getValue() diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 5e99396b45..9e6ebdd3d4 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -174,7 +174,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location) if (dist <= _background->getBoundingBox().size.width*0.5f) { updateSliderPosition(location); - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); return true; } return false; @@ -203,7 +203,7 @@ void ControlSaturationBrightnessPicker::ccTouchMoved(Touch* touch, Event* event) //small modification: this allows changing of the colour, even if the touch leaves the bounding area // updateSliderPosition(touchLocation); -// sendActionsForControlEvents(ControlEventValueChanged); +// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); // Check the touch position on the slider checkSliderPosition(touchLocation); } diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 8120df768c..a93026d8f8 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -149,7 +149,7 @@ void ControlSlider::setEnabled(bool enabled) this->needsLayout(); - this->sendActionsForControlEvents(ControlEventValueChanged); + this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } void ControlSlider::setMinimumValue(float minimumValue) diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.cpp b/extensions/GUI/CCControlExtension/CCControlStepper.cpp index a292fa6475..6913ea55ae 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.cpp +++ b/extensions/GUI/CCControlExtension/CCControlStepper.cpp @@ -213,7 +213,7 @@ void ControlStepper::setValueWithSendingEvent(double value, bool send) if (send) { - this->sendActionsForControlEvents(ControlEventValueChanged); + this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } } diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.h b/extensions/GUI/CCControlExtension/CCControlStepper.h index 81e2db70ec..41886163d4 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.h +++ b/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -75,7 +75,7 @@ public: /** Update the layout of the stepper with the given touch location. */ void updateLayoutUsingTouchLocation(Point location); - /** Set the numeric value of the stepper. If send is true, the ControlEventValueChanged is sent. */ + /** Set the numeric value of the stepper. If send is true, the Control::EventType::VALUE_CHANGED is sent. */ void setValue(double value, bool send); /** Start the autorepeat increment/decrement. */ diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 6ea3789b62..a159ada59f 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -366,7 +366,7 @@ void ControlSwitch::setOn(bool isOn, bool animated) _switchSprite->setSliderXPosition((_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition()); } - sendActionsForControlEvents(ControlEventValueChanged); + sendActionsForControlEvents(Control::EventType::VALUE_CHANGED); } void ControlSwitch::setEnabled(bool enabled) diff --git a/extensions/GUI/CCControlExtension/CCInvocation.cpp b/extensions/GUI/CCControlExtension/CCInvocation.cpp index 88e27e78fd..8638946a26 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.cpp +++ b/extensions/GUI/CCControlExtension/CCInvocation.cpp @@ -28,7 +28,7 @@ NS_CC_EXT_BEGIN -Invocation* Invocation::create(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent) +Invocation* Invocation::create(Object* target, Control::Handler action, Control::EventType controlEvent) { Invocation* pRet = new Invocation(target, action, controlEvent); if (pRet != NULL) @@ -38,7 +38,7 @@ Invocation* Invocation::create(Object* target, SEL_CCControlHandler action, Cont return pRet; } -Invocation::Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent) +Invocation::Invocation(Object* target, Control::Handler action, Control::EventType controlEvent) { _target=target; _action=action; diff --git a/extensions/GUI/CCControlExtension/CCInvocation.h b/extensions/GUI/CCControlExtension/CCInvocation.h index dd2b321d04..f066d645a5 100644 --- a/extensions/GUI/CCControlExtension/CCInvocation.h +++ b/extensions/GUI/CCControlExtension/CCInvocation.h @@ -32,6 +32,7 @@ #include "cocoa/CCObject.h" #include "../../ExtensionMacros.h" +#include "CCControl.h" NS_CC_EXT_BEGIN @@ -42,24 +43,20 @@ NS_CC_EXT_BEGIN * @{ */ -typedef unsigned int ControlEvent; - -typedef void (Object::*SEL_CCControlHandler)(Object*, ControlEvent); - -#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR) +#define cccontrol_selector(_SELECTOR) (Control::Handler)(&_SELECTOR) class Invocation : public Object { public: - static Invocation* create(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent); - Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent); + static Invocation* create(Object* target, Control::Handler action, Control::EventType controlEvent); + Invocation(Object* target, Control::Handler action, Control::EventType controlEvent); void invoke(Object* sender); protected: - CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, _action, Action); + CC_SYNTHESIZE_READONLY(Control::Handler, _action, Action); CC_SYNTHESIZE_READONLY(Object*, _target, Target); - CC_SYNTHESIZE_READONLY(ControlEvent, _controlEvent, ControlEvent); + CC_SYNTHESIZE_READONLY(Control::EventType, _controlEvent, ControlEvent); }; // end of GUI group diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index b30452d431..e87c8e2629 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -31,9 +31,9 @@ NS_CC_EXT_BEGIN EditBox::EditBox(void) : _editBoxImpl(NULL) , _delegate(NULL) -, _editBoxInputMode(kEditBoxInputModeSingleLine) -, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters) -, _keyboardReturnType(kKeyboardReturnTypeDefault) +, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) +, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) +, _keyboardReturnType(KeyboardReturnType::DEFAULT) , _fontSize(-1) , _placeholderFontSize(-1) , _colText(Color3B::WHITE) @@ -51,7 +51,7 @@ EditBox::~EditBox(void) } -void EditBox::touchDownAction(Object *sender, ControlEvent controlEvent) +void EditBox::touchDownAction(Object *sender, Control::EventType controlEvent) { _editBoxImpl->openKeyboard(); } @@ -64,12 +64,12 @@ EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale { if (pPressed9SpriteBg != NULL) { - pRet->setBackgroundSpriteForState(pPressed9SpriteBg, ControlStateHighlighted); + pRet->setBackgroundSpriteForState(pPressed9SpriteBg, Control::State::HIGH_LIGHTED); } if (pDisabled9SpriteBg != NULL) { - pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, ControlStateDisabled); + pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, Control::State::DISABLED); } pRet->autorelease(); } @@ -91,7 +91,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pP this->setZoomOnTouchDown(false); this->setPreferredSize(size); this->setPosition(Point(0, 0)); - this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), ControlEventTouchUpInside); + this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), Control::EventType::TOUCH_UP_INSIDE); return true; } @@ -233,7 +233,7 @@ const char* EditBox::getPlaceHolder(void) return _placeHolder.c_str(); } -void EditBox::setInputMode(EditBoxInputMode inputMode) +void EditBox::setInputMode(EditBox::InputMode inputMode) { _editBoxInputMode = inputMode; if (_editBoxImpl != NULL) @@ -257,7 +257,7 @@ int EditBox::getMaxLength() return _maxLength; } -void EditBox::setInputFlag(EditBoxInputFlag inputFlag) +void EditBox::setInputFlag(EditBox::InputFlag inputFlag) { _editBoxInputFlag = inputFlag; if (_editBoxImpl != NULL) @@ -266,7 +266,7 @@ void EditBox::setInputFlag(EditBoxInputFlag inputFlag) } } -void EditBox::setReturnType(KeyboardReturnType returnType) +void EditBox::setReturnType(EditBox::KeyboardReturnType returnType) { if (_editBoxImpl != NULL) { diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index 905e9fc9f4..2983ace003 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -32,98 +32,6 @@ NS_CC_EXT_BEGIN - -enum KeyboardReturnType { - kKeyboardReturnTypeDefault = 0, - kKeyboardReturnTypeDone, - kKeyboardReturnTypeSend, - kKeyboardReturnTypeSearch, - kKeyboardReturnTypeGo -}; - - -/** - * \brief The EditBoxInputMode defines the type of text that the user is allowed - * to enter. - */ -enum EditBoxInputMode -{ - /** - * The user is allowed to enter any text, including line breaks. - */ - kEditBoxInputModeAny = 0, - - /** - * The user is allowed to enter an e-mail address. - */ - kEditBoxInputModeEmailAddr, - - /** - * The user is allowed to enter an integer value. - */ - kEditBoxInputModeNumeric, - - /** - * The user is allowed to enter a phone number. - */ - kEditBoxInputModePhoneNumber, - - /** - * The user is allowed to enter a URL. - */ - kEditBoxInputModeUrl, - - /** - * The user is allowed to enter a real number value. - * This extends kEditBoxInputModeNumeric by allowing a decimal point. - */ - kEditBoxInputModeDecimal, - - /** - * The user is allowed to enter any text, except for line breaks. - */ - kEditBoxInputModeSingleLine -}; - -/** - * \brief The EditBoxInputFlag defines how the input text is displayed/formatted. - */ -enum EditBoxInputFlag -{ - /** - * Indicates that the text entered is confidential data that should be - * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. - */ - kEditBoxInputFlagPassword = 0, - - /** - * Indicates that the text entered is sensitive data that the - * implementation must never store into a dictionary or table for use - * in predictive, auto-completing, or other accelerated input schemes. - * A credit card number is an example of sensitive data. - */ - kEditBoxInputFlagSensitive, - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each word should be capitalized. - */ - kEditBoxInputFlagInitialCapsWord, - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each sentence should be capitalized. - */ - kEditBoxInputFlagInitialCapsSentence, - - /** - * Capitalize all characters automatically. - */ - kEditBoxInputFlagInitialCapsAllCharacters - -}; - - class EditBox; class EditBoxImpl; @@ -173,6 +81,95 @@ class EditBox , public IMEDelegate { public: + enum class KeyboardReturnType + { + DEFAULT, + DONE, + SEND, + SEARCH, + GO + }; + + /** + * \brief The EditBox::InputMode defines the type of text that the user is allowed + * to enter. + */ + enum class InputMode + { + /** + * The user is allowed to enter any text, including line breaks. + */ + ANY, + + /** + * The user is allowed to enter an e-mail address. + */ + EMAIL_ADDRESS, + + /** + * The user is allowed to enter an integer value. + */ + NUMERIC, + + /** + * The user is allowed to enter a phone number. + */ + PHONE_NUMBER, + + /** + * The user is allowed to enter a URL. + */ + URL, + + /** + * The user is allowed to enter a real number value. + * This extends kEditBoxInputModeNumeric by allowing a decimal point. + */ + DECIMAL, + + /** + * The user is allowed to enter any text, except for line breaks. + */ + SINGLE_LINE, + }; + + /** + * \brief The EditBox::InputFlag defines how the input text is displayed/formatted. + */ + enum class InputFlag + { + /** + * Indicates that the text entered is confidential data that should be + * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. + */ + PASSWORD, + + /** + * Indicates that the text entered is sensitive data that the + * implementation must never store into a dictionary or table for use + * in predictive, auto-completing, or other accelerated input schemes. + * A credit card number is an example of sensitive data. + */ + SENSITIVE, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each word should be capitalized. + */ + INITIAL_CAPS_WORD, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each sentence should be capitalized. + */ + INITIAL_CAPS_SENTENCE, + + /** + * Capitalize all characters automatically. + */ + INTIAL_CAPS_ALL_CHARACTERS, + }; + /** * create a edit box with size. * @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again. @@ -310,9 +307,9 @@ public: /** * Set the input mode of the edit box. - * @param inputMode One of the EditBoxInputMode constants. + * @param inputMode One of the EditBox::InputMode constants. */ - void setInputMode(EditBoxInputMode inputMode); + void setInputMode(InputMode inputMode); /** * Sets the maximum input length of the edit box. @@ -332,15 +329,15 @@ public: /** * Set the input flags that are to be applied to the edit box. - * @param inputFlag One of the EditBoxInputFlag constants. + * @param inputFlag One of the EditBox::InputFlag constants. */ - void setInputFlag(EditBoxInputFlag inputFlag); + void setInputFlag(InputFlag inputFlag); /** * Set the return type that are to be applied to the edit box. - * @param returnType One of the KeyboardReturnType constants. + * @param returnType One of the EditBox::KeyboardReturnType constants. */ - void setReturnType(KeyboardReturnType returnType); + void setReturnType(EditBox::KeyboardReturnType returnType); /* override functions */ virtual void setPosition(const Point& pos); @@ -356,15 +353,15 @@ public: virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info); /* callback funtions */ - void touchDownAction(Object *sender, ControlEvent controlEvent); + void touchDownAction(Object *sender, Control::EventType controlEvent); protected: EditBoxImpl* _editBoxImpl; EditBoxDelegate* _delegate; - EditBoxInputMode _editBoxInputMode; - EditBoxInputFlag _editBoxInputFlag; - KeyboardReturnType _keyboardReturnType; + InputMode _editBoxInputMode; + InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; std::string _text; std::string _placeHolder; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImpl.h b/extensions/GUI/CCEditBox/CCEditBoxImpl.h index 0cb83a847f..27f4de8ab8 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImpl.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImpl.h @@ -44,11 +44,11 @@ public: virtual void setFontColor(const Color3B& color) = 0; virtual void setPlaceholderFont(const char* pFontName, int fontSize) = 0; virtual void setPlaceholderFontColor(const Color3B& color) = 0; - virtual void setInputMode(EditBoxInputMode inputMode) = 0; - virtual void setInputFlag(EditBoxInputFlag inputFlag) = 0; + virtual void setInputMode(EditBox::InputMode inputMode) = 0; + virtual void setInputFlag(EditBox::InputFlag inputFlag) = 0; virtual void setMaxLength(int maxLength) = 0; virtual int getMaxLength() = 0; - virtual void setReturnType(KeyboardReturnType returnType) = 0; + virtual void setReturnType(EditBox::KeyboardReturnType returnType) = 0; virtual bool isEditing() = 0; virtual void setText(const char* pText) = 0; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index 55e12a4206..8afb9b6e0a 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -43,9 +43,9 @@ EditBoxImplAndroid::EditBoxImplAndroid(EditBox* pEditText) : EditBoxImpl(pEditText) , _label(NULL) , _labelPlaceHolder(NULL) -, _editBoxInputMode(kEditBoxInputModeSingleLine) -, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters) -, _keyboardReturnType(kKeyboardReturnTypeDefault) +, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) +, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) +, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) @@ -120,7 +120,7 @@ void EditBoxImplAndroid::setPlaceholderFontColor(const Color3B& color) _labelPlaceHolder->setColor(color); } -void EditBoxImplAndroid::setInputMode(EditBoxInputMode inputMode) +void EditBoxImplAndroid::setInputMode(EditBox::InputMode inputMode) { _editBoxInputMode = inputMode; } @@ -135,12 +135,12 @@ int EditBoxImplAndroid::getMaxLength() return _maxLength; } -void EditBoxImplAndroid::setInputFlag(EditBoxInputFlag inputFlag) +void EditBoxImplAndroid::setInputFlag(EditBox::InputFlag inputFlag) { _editBoxInputFlag = inputFlag; } -void EditBoxImplAndroid::setReturnType(KeyboardReturnType returnType) +void EditBoxImplAndroid::setReturnType(EditBox::KeyboardReturnType returnType) { _keyboardReturnType = returnType; } @@ -162,7 +162,7 @@ void EditBoxImplAndroid::setText(const char* pText) std::string strToShow; - if (kEditBoxInputFlagPassword == _editBoxInputFlag) + if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag) { long length = cc_utf8_strlen(_text.c_str(), -1); for (long i = 0; i < length; i++) @@ -289,9 +289,9 @@ void EditBoxImplAndroid::openKeyboard() showEditTextDialogJNI( _placeHolder.c_str(), _text.c_str(), - _editBoxInputMode, - _editBoxInputFlag, - _keyboardReturnType, + (int)_editBoxInputMode, + (int)_editBoxInputFlag, + (int)_keyboardReturnType, _maxLength, editBoxCallbackFunc, (void*)this ); diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h index a85a6153f9..ae1b06c740 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h @@ -48,11 +48,11 @@ public: virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBoxInputMode inputMode); - virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); - virtual void setReturnType(KeyboardReturnType returnType); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); @@ -71,9 +71,9 @@ public: private: LabelTTF* _label; LabelTTF* _labelPlaceHolder; - EditBoxInputMode _editBoxInputMode; - EditBoxInputFlag _editBoxInputFlag; - KeyboardReturnType _keyboardReturnType; + EditBox::InputMode _editBoxInputMode; + EditBox::InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; std::string _text; std::string _placeHolder; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h index feaba09dc9..b38a45e1a9 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h @@ -79,11 +79,11 @@ public: virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBoxInputMode inputMode); - virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); - virtual void setReturnType(KeyboardReturnType returnType); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm index 73d6312860..0848178220 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -394,26 +394,26 @@ void EditBoxImplIOS::setPlaceholderFontColor(const Color3B& color) _labelPlaceHolder->setColor(color); } -void EditBoxImplIOS::setInputMode(EditBoxInputMode inputMode) +void EditBoxImplIOS::setInputMode(EditBox::InputMode inputMode) { switch (inputMode) { - case kEditBoxInputModeEmailAddr: + case EditBox::InputMode::EMAIL_ADDRESS: _systemControl.textField.keyboardType = UIKeyboardTypeEmailAddress; break; - case kEditBoxInputModeNumeric: + case EditBox::InputMode::NUMERIC: _systemControl.textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; break; - case kEditBoxInputModePhoneNumber: + case EditBox::InputMode::PHONE_NUMBER: _systemControl.textField.keyboardType = UIKeyboardTypePhonePad; break; - case kEditBoxInputModeUrl: + case EditBox::InputMode::URL: _systemControl.textField.keyboardType = UIKeyboardTypeURL; break; - case kEditBoxInputModeDecimal: + case EditBox::InputMode::DECIMAL: _systemControl.textField.keyboardType = UIKeyboardTypeDecimalPad; break; - case kEditBoxInputModeSingleLine: + case EditBox::InputMode::SINGLE_LINE: _systemControl.textField.keyboardType = UIKeyboardTypeDefault; break; default: @@ -432,23 +432,23 @@ int EditBoxImplIOS::getMaxLength() return _maxTextLength; } -void EditBoxImplIOS::setInputFlag(EditBoxInputFlag inputFlag) +void EditBoxImplIOS::setInputFlag(EditBox::InputFlag inputFlag) { switch (inputFlag) { - case kEditBoxInputFlagPassword: + case EditBox::InputFlag::PASSWORD: _systemControl.textField.secureTextEntry = YES; break; - case kEditBoxInputFlagInitialCapsWord: + case EditBox::InputFlag::INITIAL_CAPS_WORD: _systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeWords; break; - case kEditBoxInputFlagInitialCapsSentence: + case EditBox::InputFlag::INITIAL_CAPS_SENTENCE: _systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeSentences; break; - case kEditBoxInputFlagInitialCapsAllCharacters: + case EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS: _systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; break; - case kEditBoxInputFlagSensitive: + case EditBox::InputFlag::SENSITIVE: _systemControl.textField.autocorrectionType = UITextAutocorrectionTypeNo; break; default: @@ -456,22 +456,22 @@ void EditBoxImplIOS::setInputFlag(EditBoxInputFlag inputFlag) } } -void EditBoxImplIOS::setReturnType(KeyboardReturnType returnType) +void EditBoxImplIOS::setReturnType(EditBox::KeyboardReturnType returnType) { switch (returnType) { - case kKeyboardReturnTypeDefault: + case EditBox::KeyboardReturnType::DEFAULT: _systemControl.textField.returnKeyType = UIReturnKeyDefault; break; - case kKeyboardReturnTypeDone: + case EditBox::KeyboardReturnType::DONE: _systemControl.textField.returnKeyType = UIReturnKeyDone; break; - case kKeyboardReturnTypeSend: + case EditBox::KeyboardReturnType::SEND: _systemControl.textField.returnKeyType = UIReturnKeySend; break; - case kKeyboardReturnTypeSearch: + case EditBox::KeyboardReturnType::SEARCH: _systemControl.textField.returnKeyType = UIReturnKeySearch; break; - case kKeyboardReturnTypeGo: + case EditBox::KeyboardReturnType::GO: _systemControl.textField.returnKeyType = UIReturnKeyGo; break; default: diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h b/extensions/GUI/CCEditBox/CCEditBoxImplMac.h index 2a037ed246..bdab898ff2 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.h @@ -78,11 +78,11 @@ public: virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBoxInputMode inputMode); - virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); - virtual void setReturnType(KeyboardReturnType returnType); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm index 30f68f53bb..0dfac0adc0 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm @@ -298,7 +298,7 @@ void EditBoxImplMac::setPlaceholderFontColor(const Color3B& color) // TODO need to be implemented. } -void EditBoxImplMac::setInputMode(EditBoxInputMode inputMode) +void EditBoxImplMac::setInputMode(EditBox::InputMode inputMode) { } @@ -312,12 +312,12 @@ int EditBoxImplMac::getMaxLength() return _maxTextLength; } -void EditBoxImplMac::setInputFlag(EditBoxInputFlag inputFlag) +void EditBoxImplMac::setInputFlag(EditBox::InputFlag inputFlag) { // TODO: NSSecureTextField } -void EditBoxImplMac::setReturnType(KeyboardReturnType returnType) +void EditBoxImplMac::setReturnType(EditBox::KeyboardReturnType returnType) { } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplTizen.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplTizen.cpp index c1e53a59a2..c5d6fda658 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplTizen.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplTizen.cpp @@ -44,8 +44,8 @@ EditBoxImplTizen::EditBoxImplTizen(EditBox* pEditText) : EditBoxImpl(pEditText) , _label(NULL) , _labelPlaceHolder(NULL) -, _editBoxInputMode(kEditBoxInputModeSingleLine) -, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters) +, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) +, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) , _keyboardReturnType(kKeyboardReturnTypeDefault) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) @@ -118,7 +118,7 @@ void EditBoxImplTizen::setPlaceholderFontColor(const Color3B& color) _labelPlaceHolder->setColor(color); } -void EditBoxImplTizen::setInputMode(EditBoxInputMode inputMode) +void EditBoxImplTizen::setInputMode(EditBox::InputMode inputMode) { _editBoxInputMode = inputMode; } @@ -133,12 +133,12 @@ int EditBoxImplTizen::getMaxLength() return _maxLength; } -void EditBoxImplTizen::setInputFlag(EditBoxInputFlag inputFlag) +void EditBoxImplTizen::setInputFlag(EditBox::InputFlag inputFlag) { _editBoxInputFlag = inputFlag; } -void EditBoxImplTizen::setReturnType(KeyboardReturnType returnType) +void EditBoxImplTizen::setReturnType(EditBox::KeyboardReturnType returnType) { _keyboardReturnType = returnType; } @@ -301,7 +301,7 @@ void EditBoxImplTizen::openKeyboard() case kEditBoxInputModeUrl: keypadStyle = KEYPAD_STYLE_URL; break; - case kEditBoxInputModeSingleLine: + case EditBox::InputMode::SINGLE_LINE: bSingleLineEnabled = true; break; default: diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplTizen.h b/extensions/GUI/CCEditBox/CCEditBoxImplTizen.h index 0a69803d64..d369a10aa5 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplTizen.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplTizen.h @@ -49,11 +49,11 @@ public: virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBoxInputMode inputMode); - virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); - virtual void setReturnType(KeyboardReturnType returnType); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); @@ -72,9 +72,9 @@ public: private: LabelTTF* _label; LabelTTF* _labelPlaceHolder; - EditBoxInputMode _editBoxInputMode; - EditBoxInputFlag _editBoxInputFlag; - KeyboardReturnType _keyboardReturnType; + EditBox::InputMode _editBoxInputMode; + EditBox::InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; std::string _text; std::string _placeHolder; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index af35f2f646..1126e4e8b1 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -40,9 +40,9 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) : EditBoxImpl(pEditText) , _label(NULL) , _labelPlaceHolder(NULL) -, _editBoxInputMode(kEditBoxInputModeSingleLine) -, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters) -, _keyboardReturnType(kKeyboardReturnTypeDefault) +, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) +, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) +, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) @@ -113,7 +113,7 @@ void EditBoxImplWin::setPlaceholderFontColor(const Color3B& color) _labelPlaceHolder->setColor(color); } -void EditBoxImplWin::setInputMode(EditBoxInputMode inputMode) +void EditBoxImplWin::setInputMode(EditBox::InputMode inputMode) { _editBoxInputMode = inputMode; } @@ -128,12 +128,12 @@ int EditBoxImplWin::getMaxLength() return _maxLength; } -void EditBoxImplWin::setInputFlag(EditBoxInputFlag inputFlag) +void EditBoxImplWin::setInputFlag(EditBox::InputFlag inputFlag) { _editBoxInputFlag = inputFlag; } -void EditBoxImplWin::setReturnType(KeyboardReturnType returnType) +void EditBoxImplWin::setReturnType(EditBox::KeyboardReturnType returnType) { _keyboardReturnType = returnType; } @@ -155,7 +155,7 @@ void EditBoxImplWin::setText(const char* pText) std::string strToShow; - if (kEditBoxInputFlagPassword == _editBoxInputFlag) + if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag) { long length = cc_utf8_strlen(_text.c_str(), -1); for (long i = 0; i < length; i++) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h index 6df1e864e1..ce09eebf85 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h @@ -48,11 +48,11 @@ public: virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBoxInputMode inputMode); - virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); - virtual void setReturnType(KeyboardReturnType returnType); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); @@ -71,9 +71,9 @@ private: LabelTTF* _label; LabelTTF* _labelPlaceHolder; - EditBoxInputMode _editBoxInputMode; - EditBoxInputFlag _editBoxInputFlag; - KeyboardReturnType _keyboardReturnType; + EditBox::InputMode _editBoxInputMode; + EditBox::InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; std::string _text; std::string _placeHolder; diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 35e3de78d0..0ee866e5d7 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -45,7 +45,7 @@ ScrollView::ScrollView() , _minZoomScale(0.0f) , _maxZoomScale(0.0f) , _delegate(NULL) -, _direction(kScrollViewDirectionBoth) +, _direction(Direction::BOTH) , _dragging(false) , _container(NULL) , _touchMoved(false) @@ -114,7 +114,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) _bounceable = true; _clippingToBounds = true; //_container->setContentSize(Size::ZERO); - _direction = kScrollViewDirectionBoth; + _direction = Direction::BOTH; _container->setPosition(Point(0.0f, 0.0f)); _touchLength = 0.0f; @@ -333,13 +333,13 @@ void ScrollView::relocateContainer(bool animated) newX = oldPoint.x; newY = oldPoint.y; - if (_direction == kScrollViewDirectionBoth || _direction == kScrollViewDirectionHorizontal) + if (_direction == Direction::BOTH || _direction == Direction::HORIZONTAL) { newX = MAX(newX, min.x); newX = MIN(newX, max.x); } - if (_direction == kScrollViewDirectionBoth || _direction == kScrollViewDirectionVertical) + if (_direction == Direction::BOTH || _direction == Direction::VERTICAL) { newY = MIN(newY, max.y); newY = MAX(newY, min.y); @@ -659,11 +659,11 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) moveDistance = newPoint - _touchPoint; float dis = 0.0f; - if (_direction == kScrollViewDirectionVertical) + if (_direction == Direction::VERTICAL) { dis = moveDistance.y; } - else if (_direction == kScrollViewDirectionHorizontal) + else if (_direction == Direction::HORIZONTAL) { dis = moveDistance.x; } @@ -690,10 +690,10 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) { switch (_direction) { - case kScrollViewDirectionVertical: + case Direction::VERTICAL: moveDistance = Point(0.0f, moveDistance.y); break; - case kScrollViewDirectionHorizontal: + case Direction::HORIZONTAL: moveDistance = Point(moveDistance.x, 0.0f); break; default: diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index a7180225ec..3073453606 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -36,13 +36,6 @@ NS_CC_EXT_BEGIN * @{ */ -typedef enum { - kScrollViewDirectionNone = -1, - kScrollViewDirectionHorizontal = 0, - kScrollViewDirectionVertical, - kScrollViewDirectionBoth -} ScrollViewDirection; - class ScrollView; class ScrollViewDelegate @@ -61,6 +54,13 @@ public: class ScrollView : public Layer { public: + enum class Direction + { + NONE = -1, + HORIZONTAL = 0, + VERTICAL, + BOTH + }; /** * Returns an autoreleased scroll view object. * @@ -172,8 +172,8 @@ public: /** * direction allowed to scroll. ScrollViewDirectionBoth by default. */ - ScrollViewDirection getDirection() const { return _direction; } - virtual void setDirection(ScrollViewDirection eDirection) { _direction = eDirection; } + Direction getDirection() const { return _direction; } + virtual void setDirection(Direction eDirection) { _direction = eDirection; } ScrollViewDelegate* getDelegate() { return _delegate; } void setDelegate(ScrollViewDelegate* pDelegate) { _delegate = pDelegate; } @@ -254,7 +254,7 @@ protected: */ ScrollViewDelegate* _delegate; - ScrollViewDirection _direction; + Direction _direction; /** * If YES, the view is being dragged. */ diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 4ee615b252..e11d31805b 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -56,8 +56,8 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/) _cellsUsed = new ArrayForObjectSorting(); _cellsFreed = new ArrayForObjectSorting(); _indices = new std::set(); - _vordering = kTableViewFillBottomUp; - this->setDirection(kScrollViewDirectionVertical); + _vordering = VerticalFillOrder::BOTTOM_UP; + this->setDirection(Direction::VERTICAL); ScrollView::setDelegate(this); return true; @@ -66,13 +66,13 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/) } TableView::TableView() -: _touchedCell(NULL) -, _indices(NULL) -, _cellsUsed(NULL) -, _cellsFreed(NULL) -, _dataSource(NULL) -, _tableViewDelegate(NULL) -, _oldDirection(kScrollViewDirectionNone) +: _touchedCell(nullptr) +, _indices(nullptr) +, _cellsUsed(nullptr) +, _cellsFreed(nullptr) +, _dataSource(nullptr) +, _tableViewDelegate(nullptr) +, _oldDirection(Direction::NONE) { } @@ -84,7 +84,7 @@ TableView::~TableView() CC_SAFE_RELEASE(_cellsFreed); } -void TableView::setVerticalFillOrder(TableViewVerticalFillOrder fillOrder) +void TableView::setVerticalFillOrder(VerticalFillOrder fillOrder) { if (_vordering != fillOrder) { _vordering = fillOrder; @@ -94,14 +94,14 @@ void TableView::setVerticalFillOrder(TableViewVerticalFillOrder fillOrder) } } -TableViewVerticalFillOrder TableView::getVerticalFillOrder() +TableView::VerticalFillOrder TableView::getVerticalFillOrder() { return _vordering; } void TableView::reloadData() { - _oldDirection = kScrollViewDirectionNone; + _oldDirection = Direction::NONE; Object* pObj = NULL; CCARRAY_FOREACH(_cellsUsed, pObj) { @@ -276,7 +276,7 @@ void TableView::_updateContentSize() switch (this->getDirection()) { - case kScrollViewDirectionHorizontal: + case Direction::HORIZONTAL: size = Size(maxPosition, _viewSize.height); break; default: @@ -289,7 +289,7 @@ void TableView::_updateContentSize() if (_oldDirection != _direction) { - if (_direction == kScrollViewDirectionHorizontal) + if (_direction == Direction::HORIZONTAL) { this->setContentOffset(Point(0,0)); } @@ -307,7 +307,7 @@ Point TableView::_offsetFromIndex(unsigned int index) Point offset = this->__offsetFromIndex(index); const Size cellSize = _dataSource->tableCellSizeForIndex(this, index); - if (_vordering == kTableViewFillTopDown) + if (_vordering == VerticalFillOrder::TOP_DOWN) { offset.y = this->getContainer()->getContentSize().height - offset.y - cellSize.height; } @@ -321,7 +321,7 @@ Point TableView::__offsetFromIndex(unsigned int index) switch (this->getDirection()) { - case kScrollViewDirectionHorizontal: + case Direction::HORIZONTAL: offset = Point(_vCellsPositions[index], 0.0f); break; default: @@ -337,7 +337,7 @@ unsigned int TableView::_indexFromOffset(Point offset) int index = 0; const int maxIdx = _dataSource->numberOfCellsInTableView(this)-1; - if (_vordering == kTableViewFillTopDown) + if (_vordering == VerticalFillOrder::TOP_DOWN) { offset.y = this->getContainer()->getContentSize().height - offset.y; } @@ -361,7 +361,7 @@ int TableView::__indexFromOffset(Point offset) float search; switch (this->getDirection()) { - case kScrollViewDirectionHorizontal: + case Direction::HORIZONTAL: search = offset.x; break; default: @@ -433,7 +433,7 @@ void TableView::_updateCellPositions() { cellSize = _dataSource->tableCellSizeForIndex(this, i); switch (this->getDirection()) { - case kScrollViewDirectionHorizontal: + case Direction::HORIZONTAL: currentPos += cellSize.width; break; default: @@ -462,7 +462,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) Point offset = this->getContentOffset() * -1; maxIdx = MAX(uCountOfItems-1, 0); - if (_vordering == kTableViewFillTopDown) + if (_vordering == VerticalFillOrder::TOP_DOWN) { offset.y = offset.y + _viewSize.height/this->getContainer()->getScaleY(); } @@ -472,7 +472,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) startIdx = uCountOfItems - 1; } - if (_vordering == kTableViewFillTopDown) + if (_vordering == VerticalFillOrder::TOP_DOWN) { offset.y -= _viewSize.height/this->getContainer()->getScaleY(); } diff --git a/extensions/GUI/CCScrollView/CCTableView.h b/extensions/GUI/CCScrollView/CCTableView.h index b818ec992e..acbe9359ec 100644 --- a/extensions/GUI/CCScrollView/CCTableView.h +++ b/extensions/GUI/CCScrollView/CCTableView.h @@ -37,11 +37,6 @@ NS_CC_EXT_BEGIN class TableView; class ArrayForObjectSorting; -typedef enum { - kTableViewFillTopDown, - kTableViewFillBottomUp -} TableViewVerticalFillOrder; - /** * Sole purpose of this delegate is to single touch event in this version. */ @@ -137,6 +132,12 @@ public: class TableView : public ScrollView, public ScrollViewDelegate { public: + + enum class VerticalFillOrder + { + TOP_DOWN, + BOTTOM_UP + }; /** * An intialized table view object * @@ -174,8 +175,8 @@ public: /** * determines how cell is ordered and filled in the view. */ - void setVerticalFillOrder(TableViewVerticalFillOrder order); - TableViewVerticalFillOrder getVerticalFillOrder(); + void setVerticalFillOrder(VerticalFillOrder order); + VerticalFillOrder getVerticalFillOrder(); /** * Updates the content of the cell at a given index. @@ -228,7 +229,7 @@ protected: /** * vertical direction of cell filling */ - TableViewVerticalFillOrder _vordering; + VerticalFillOrder _vordering; /** * index set to query the indexes of the cells used. @@ -257,7 +258,7 @@ protected: */ TableViewDelegate* _tableViewDelegate; - ScrollViewDirection _oldDirection; + Direction _oldDirection; int __indexFromOffset(Point offset); unsigned int _indexFromOffset(Point offset); diff --git a/extensions/network/SocketIO.cpp b/extensions/network/SocketIO.cpp index 80a1320269..731f0b2e09 100644 --- a/extensions/network/SocketIO.cpp +++ b/extensions/network/SocketIO.cpp @@ -100,20 +100,19 @@ SIOClientImpl::SIOClientImpl(const std::string& host, int port) : s << host << ":" << port; _uri = s.str(); - _ws = NULL; - + _ws = nullptr; } -SIOClientImpl::~SIOClientImpl() { - - if(_connected) disconnect(); +SIOClientImpl::~SIOClientImpl() +{ + if (_connected) disconnect(); CC_SAFE_DELETE(_clients); CC_SAFE_DELETE(_ws); - } -void SIOClientImpl::handshake() { +void SIOClientImpl::handshake() +{ log("SIOClientImpl::handshake() called"); std::stringstream pre; @@ -135,8 +134,8 @@ void SIOClientImpl::handshake() { return; } -void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) { - +void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) +{ log("SIOClientImpl::handshakeResponse() called"); if (0 != strlen(response->getHttpRequest()->getTag())) @@ -185,18 +184,21 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response int heartbeat = 0, timeout = 0; pos = res.find(":"); - if(pos >= 0) { + if(pos >= 0) + { sid = res.substr(0, pos); res.erase(0, pos+1); } pos = res.find(":"); - if(pos >= 0){ + if(pos >= 0) + { heartbeat = atoi(res.substr(pos+1, res.size()).c_str()); } pos = res.find(":"); - if(pos >= 0){ + if(pos >= 0) + { timeout = atoi(res.substr(pos+1, res.size()).c_str()); } @@ -210,15 +212,15 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response } -void SIOClientImpl::openSocket() { - +void SIOClientImpl::openSocket() +{ log("SIOClientImpl::openSocket() called"); std::stringstream s; s << _uri << "/socket.io/1/websocket/" << _sid; _ws = new WebSocket(); - if(!_ws->init(*this, s.str())) + if (!_ws->init(*this, s.str())) { CC_SAFE_DELETE(_ws); } @@ -226,23 +228,21 @@ void SIOClientImpl::openSocket() { return; } -bool SIOClientImpl::init() { - +bool SIOClientImpl::init() +{ log("SIOClientImpl::init() successful"); return true; - } -void SIOClientImpl::connect() { - +void SIOClientImpl::connect() +{ this->handshake(); - } -void SIOClientImpl::disconnect() { - - if(_ws->getReadyState() == WebSocket::kStateOpen) { - +void SIOClientImpl::disconnect() +{ + if(_ws->getReadyState() == WebSocket::State::OPEN) + { std::string s = "0::"; _ws->send(s); @@ -250,7 +250,6 @@ void SIOClientImpl::disconnect() { log("Disconnect sent"); _ws->close(); - } Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); @@ -258,79 +257,71 @@ void SIOClientImpl::disconnect() { _connected = false; SocketIO::instance()->removeSocket(_uri); - } -SIOClientImpl* SIOClientImpl::create(const std::string& host, int port) { - +SIOClientImpl* SIOClientImpl::create(const std::string& host, int port) +{ SIOClientImpl *s = new SIOClientImpl(host, port); - if(s && s->init()) { - + if (s && s->init()) + { return s; - } - return NULL; - + return nullptr; } -SIOClient* SIOClientImpl::getClient(const std::string& endpoint) { - +SIOClient* SIOClientImpl::getClient(const std::string& endpoint) +{ return static_cast(_clients->objectForKey(endpoint)); - } -void SIOClientImpl::addClient(const std::string& endpoint, SIOClient* client) { - +void SIOClientImpl::addClient(const std::string& endpoint, SIOClient* client) +{ _clients->setObject(client, endpoint); - } -void SIOClientImpl::connectToEndpoint(const std::string& endpoint) { - +void SIOClientImpl::connectToEndpoint(const std::string& endpoint) +{ std::string path = endpoint == "/" ? "" : endpoint; std::string s = "1::" + path; _ws->send(s); - } -void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) { - +void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) +{ _clients->removeObjectForKey(endpoint); - if(_clients->count() == 0 || endpoint == "/") { - + if(_clients->count() == 0 || endpoint == "/") + { log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect"); if(_connected) this->disconnect(); - - } else { - + } + else + { std::string path = endpoint == "/" ? "" : endpoint; std::string s = "0::" + path; _ws->send(s); - } - } -void SIOClientImpl::heartbeat(float dt) { - +void SIOClientImpl::heartbeat(float dt) +{ std::string s = "2::"; _ws->send(s); log("Heartbeat sent"); - } -void SIOClientImpl::send(std::string endpoint, std::string s) { +void SIOClientImpl::send(std::string endpoint, std::string s) +{ std::stringstream pre; std::string path = endpoint == "/" ? "" : endpoint; @@ -342,11 +333,10 @@ void SIOClientImpl::send(std::string endpoint, std::string s) { log("sending message: %s", msg.c_str()); _ws->send(msg); - } -void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::string args) { - +void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::string args) +{ std::stringstream pre; std::string path = endpoint == "/" ? "" : endpoint; @@ -358,33 +348,30 @@ void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::strin log("emitting event with data: %s", msg.c_str()); _ws->send(msg); - } -void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) { - +void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) +{ _connected = true; SocketIO::instance()->addSocket(_uri, this); DictElement* e = NULL; - CCDICT_FOREACH(_clients, e) { - + CCDICT_FOREACH(_clients, e) + { SIOClient *c = static_cast(e->getObject()); c->onOpen(); - } Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false); log("SIOClientImpl::onOpen socket connected!"); - } -void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) { - +void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) +{ log("SIOClientImpl::onMessage received: %s", data.bytes); int control = atoi(&data.bytes[0]); @@ -406,25 +393,26 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d:: payload.erase(0, pos+1); pos = payload.find(":"); - if(pos >= 0) { - + if(pos >= 0) + { endpoint = payload.substr(0, pos); payload.erase(0, pos+1); - - } else { - + } + else + { endpoint = payload; } - if(endpoint == "") endpoint = "/"; + if (endpoint == "") endpoint = "/"; s_data = payload; SIOClient *c = NULL; c = getClient(endpoint); - if(c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL"); + if (c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL"); - switch(control) { + switch(control) + { case 0: log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str()); if(c) c->receivedDisconnect(); @@ -448,11 +436,13 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d:: case 5: log("Event Received with data: %s \n", s_data.c_str()); - if(c) { + if(c) + { eventname = ""; pos = s_data.find(":"); pos2 = s_data.find(","); - if(pos2 > pos) { + if(pos2 > pos) + { s_data = s_data.substr(pos+1, pos2-pos-1); std::remove_copy(s_data.begin(), s_data.end(), std::back_inserter(eventname), '"'); @@ -477,29 +467,25 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d:: return; } -void SIOClientImpl::onClose(cocos2d::extension::WebSocket* ws) { - - if(_clients->count() > 0) { - +void SIOClientImpl::onClose(cocos2d::extension::WebSocket* ws) +{ + if(_clients->count() > 0) + { DictElement *e; - CCDICT_FOREACH(_clients, e) { - + CCDICT_FOREACH(_clients, e) + { SIOClient *c = static_cast(e->getObject()); c->receivedDisconnect(); - } - } this->release(); - } -void SIOClientImpl::onError(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::ErrorCode& error) { - - +void SIOClientImpl::onError(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::ErrorCode& error) +{ } //begin SIOClient methods @@ -512,56 +498,58 @@ SIOClient::SIOClient(const std::string& host, int port, const std::string& path, , _delegate(&delegate) { - } -SIOClient::~SIOClient(void) { - - if(_connected) { +SIOClient::~SIOClient(void) +{ + if (_connected) + { _socket->disconnectFromEndpoint(_path); } - } -void SIOClient::onOpen() { - - if(_path != "/") { - - _socket->connectToEndpoint(_path); - +void SIOClient::onOpen() +{ + if (_path != "/") + { + _socket->connectToEndpoint(_path); } - } -void SIOClient::onConnect() { - +void SIOClient::onConnect() +{ _connected = true; _delegate->onConnect(this); - } -void SIOClient::send(std::string s) { - - if(_connected) { +void SIOClient::send(std::string s) +{ + if (_connected) + { _socket->send(_path, s); - } else { + } + else + { _delegate->onError(this, "Client not yet connected"); } } -void SIOClient::emit(std::string eventname, std::string args) { - - if(_connected) { +void SIOClient::emit(std::string eventname, std::string args) +{ + if(_connected) + { _socket->emit(_path, eventname, args); - } else { + } + else + { _delegate->onError(this, "Client not yet connected"); } } -void SIOClient::disconnect() { - +void SIOClient::disconnect() +{ _connected = false; _socket->disconnectFromEndpoint(_path); @@ -569,31 +557,28 @@ void SIOClient::disconnect() { _delegate->onClose(this); this->release(); - } -void SIOClient::receivedDisconnect() { - +void SIOClient::receivedDisconnect() +{ _connected = false; _delegate->onClose(this); this->release(); - } -void SIOClient::on(const std::string& eventName, SIOEvent e) { - +void SIOClient::on(const std::string& eventName, SIOEvent e) +{ _eventRegistry[eventName] = e; - } -void SIOClient::fireEvent(const std::string& eventName, const std::string& data) { - +void SIOClient::fireEvent(const std::string& eventName, const std::string& data) +{ log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str()); - if(_eventRegistry[eventName]) { - + if(_eventRegistry[eventName]) + { SIOEvent e = _eventRegistry[eventName]; e(this, data); @@ -602,71 +587,75 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data) } log("SIOClient::fireEvent no event with name %s found", eventName.c_str()); - } //begin SocketIO methods -SocketIO *SocketIO::_inst = NULL; - -SocketIO::SocketIO() { +SocketIO *SocketIO::_inst = nullptr; +SocketIO::SocketIO() +{ _sockets = Dictionary::create(); _sockets->retain(); - } -SocketIO::~SocketIO(void) { +SocketIO::~SocketIO(void) +{ CC_SAFE_DELETE(_sockets); delete _inst; } -SocketIO* SocketIO::instance() { - - if(!_inst) - _inst = new SocketIO(); +SocketIO* SocketIO::instance() +{ + if(!_inst) _inst = new SocketIO(); return _inst; - } -SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri) { - +SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri) +{ std::string host = uri; int port = 0; int pos = 0; pos = host.find("//"); - if(pos >= 0) { + if (pos >= 0) + { host.erase(0, pos+2); } pos = host.find(":"); - if(pos >= 0){ + if (pos >= 0) + { port = atoi(host.substr(pos+1, host.size()).c_str()); } pos = host.find("/", 0); std::string path = "/"; - if(pos >= 0){ + if (pos >= 0) + { path += host.substr(pos + 1, host.size()); } pos = host.find(":"); - if(pos >= 0){ + if (pos >= 0) + { host.erase(pos, host.size()); - }else if((pos = host.find("/"))>=0) { + } + else if ((pos = host.find("/"))>=0) + { host.erase(pos, host.size()); } std::stringstream s; s << host << ":" << port; - SIOClientImpl* socket = NULL; - SIOClient *c = NULL; + SIOClientImpl* socket = nullptr; + SIOClient *c = nullptr; socket = SocketIO::instance()->getSocket(s.str()); - if(socket == NULL) { + if(socket == nullptr) + { //create a new socket, new client, connect socket = SIOClientImpl::create(host, port); @@ -675,40 +664,37 @@ SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& socket->addClient(path, c); socket->connect(); - - - - } else { + } + else + { //check if already connected to endpoint, handle c = socket->getClient(path); - if(c == NULL) { - + if(c == NULL) + { c = new SIOClient(host, port, path, socket, delegate); socket->addClient(path, c); socket->connectToEndpoint(path); - } - } return c; - } -SIOClientImpl* SocketIO::getSocket(const std::string& uri) { - +SIOClientImpl* SocketIO::getSocket(const std::string& uri) +{ return static_cast(_sockets->objectForKey(uri)); - } -void SocketIO::addSocket(const std::string& uri, SIOClientImpl* socket) { +void SocketIO::addSocket(const std::string& uri, SIOClientImpl* socket) +{ _sockets->setObject(socket, uri); } -void SocketIO::removeSocket(const std::string& uri) { +void SocketIO::removeSocket(const std::string& uri) +{ _sockets->removeObjectForKey(uri); } diff --git a/extensions/network/WebSocket.cpp b/extensions/network/WebSocket.cpp index b55d2b34cc..df796f5077 100644 --- a/extensions/network/WebSocket.cpp +++ b/extensions/network/WebSocket.cpp @@ -211,14 +211,14 @@ enum WS_MSG { }; WebSocket::WebSocket() -: _readyState(kStateConnecting) +: _readyState(State::CONNECTING) , _port(80) -, _wsHelper(NULL) -, _wsInstance(NULL) -, _wsContext(NULL) -, _delegate(NULL) +, _wsHelper(nullptr) +, _wsInstance(nullptr) +, _wsContext(nullptr) +, _delegate(nullptr) , _SSLConnection(0) -, _wsProtocols(NULL) +, _wsProtocols(nullptr) { } @@ -227,7 +227,8 @@ WebSocket::~WebSocket() close(); CC_SAFE_RELEASE_NULL(_wsHelper); - for (int i = 0; _wsProtocols[i].callback != NULL; ++i) { + for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) + { CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name); } CC_SAFE_DELETE_ARRAY(_wsProtocols); @@ -247,9 +248,7 @@ bool WebSocket::init(const Delegate& delegate, //ws:// pos = host.find("ws://"); - if (pos == 0){ - host.erase(0,5); - } + if (pos == 0) host.erase(0,5); pos = host.find("wss://"); if (pos == 0) @@ -259,15 +258,11 @@ bool WebSocket::init(const Delegate& delegate, } pos = host.find(":"); - if(pos >= 0){ - port = atoi(host.substr(pos+1, host.size()).c_str()); - } + if (pos >= 0) port = atoi(host.substr(pos+1, host.size()).c_str()); pos = host.find("/", 0); std::string path = "/"; - if(pos >= 0){ - path += host.substr(pos + 1, host.size()); - } + if (pos >= 0) path += host.substr(pos + 1, host.size()); pos = host.find(":"); if(pos >= 0){ @@ -299,7 +294,8 @@ bool WebSocket::init(const Delegate& delegate, if (protocols) { int i = 0; - for (std::vector::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i) { + for (std::vector::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i) + { char* name = new char[(*iter).length()+1]; strcpy(name, (*iter).c_str()); _wsProtocols[i].name = name; @@ -323,7 +319,7 @@ bool WebSocket::init(const Delegate& delegate, void WebSocket::send(const std::string& message) { - if (_readyState == kStateOpen) + if (_readyState == State::OPEN) { // In main thread WsMessage* msg = new WsMessage(); @@ -339,9 +335,9 @@ void WebSocket::send(const std::string& message) void WebSocket::send(const unsigned char* binaryMsg, unsigned int len) { - CCASSERT(binaryMsg != NULL && len > 0, "parameter invalid."); + CCASSERT(binaryMsg != nullptr && len > 0, "parameter invalid."); - if (_readyState == kStateOpen) + if (_readyState == State::OPEN) { // In main thread WsMessage* msg = new WsMessage(); @@ -359,13 +355,13 @@ void WebSocket::close() { Director::getInstance()->getScheduler()->unscheduleAllForTarget(_wsHelper); - if (_readyState == kStateClosing || _readyState == kStateClosed) + if (_readyState == State::CLOSING || _readyState == State::CLOSED) { return; } CCLOG("websocket (%p) connection closed by client", this); - _readyState = kStateClosed; + _readyState = State::CLOSED; _wsHelper->joinSubThread(); @@ -381,14 +377,14 @@ WebSocket::State WebSocket::getReadyState() int WebSocket::onSubThreadLoop() { - if (_readyState == kStateClosed || _readyState == kStateClosing) + if (_readyState == State::CLOSED || _readyState == State::CLOSING) { libwebsocket_context_destroy(_wsContext); // return 1 to exit the loop. return 1; } - if (_wsContext && _readyState != kStateClosed && _readyState != kStateClosing) + if (_wsContext && _readyState != State::CLOSED && _readyState != State::CLOSING) { libwebsocket_service(_wsContext, 0); } @@ -424,15 +420,15 @@ void WebSocket::onSubThreadStarted() _wsContext = libwebsocket_create_context(&info); - if(NULL != _wsContext){ - _readyState = kStateConnecting; + if(nullptr != _wsContext) + { + _readyState = State::CONNECTING; std::string name; - for (int i = 0; _wsProtocols[i].callback != NULL; ++i) { + for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) + { name += (_wsProtocols[i].name); - if (_wsProtocols[i+1].callback != NULL) - { - name += ", "; - } + + if (_wsProtocols[i+1].callback != nullptr) name += ", "; } _wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection, _path.c_str(), _host.c_str(), _host.c_str(), @@ -451,8 +447,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, void *user, void *in, size_t len) { //CCLOG("socket callback for %d reason", reason); - CCASSERT(_wsContext == NULL || ctx == _wsContext, "Invalid context."); - CCASSERT(_wsInstance == NULL || wsi == NULL || wsi == _wsInstance, "Invaild websocket instance."); + CCASSERT(_wsContext == nullptr || ctx == _wsContext, "Invalid context."); + CCASSERT(_wsInstance == nullptr || wsi == nullptr || wsi == _wsInstance, "Invaild websocket instance."); switch (reason) { @@ -460,17 +456,17 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, case LWS_CALLBACK_PROTOCOL_DESTROY: case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: { - WsMessage* msg = NULL; + WsMessage* msg = nullptr; if (reason == LWS_CALLBACK_CLIENT_CONNECTION_ERROR - || (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == kStateConnecting) - || (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == kStateConnecting) + || (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == State::CONNECTING) + || (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == State::CONNECTING) ) { msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_ERROR; - _readyState = kStateClosing; + _readyState = State::CLOSING; } - else if (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == kStateClosing) + else if (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == State::CLOSING) { msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_CLOSE; @@ -486,7 +482,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, { WsMessage* msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_OPEN; - _readyState = kStateOpen; + _readyState = State::OPEN; + /* * start the ball rolling, * LWS_CALLBACK_CLIENT_WRITEABLE will come next service @@ -503,8 +500,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, std::list::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin(); int bytesWrite = 0; - for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter) { - + for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter) + { WsMessage* subThreadMsg = *iter; if ( WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what @@ -531,10 +528,12 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], data->len, writeProtocol); - if (bytesWrite < 0) { + if (bytesWrite < 0) + { CCLOGERROR("%s", "libwebsocket_write error..."); } - if (bytesWrite < data->len) { + if (bytesWrite < data->len) + { CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n"); } @@ -562,10 +561,10 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, _wsHelper->quitSubThread(); - if (_readyState != kStateClosed) + if (_readyState != State::CLOSED) { WsMessage* msg = new WsMessage(); - _readyState = kStateClosed; + _readyState = State::CLOSED; msg->what = WS_MSG_TO_UITHREAD_CLOSE; _wsHelper->sendMessageToUIThread(msg); } @@ -637,7 +636,7 @@ void WebSocket::onUIThreadReceiveMessage(WsMessage* msg) case WS_MSG_TO_UITHREAD_ERROR: { // FIXME: The exact error needs to be checked. - WebSocket::ErrorCode err = kErrorConnectionFailure; + WebSocket::ErrorCode err = ErrorCode::CONNECTION_FAILURE; _delegate->onError(this, err); } break; diff --git a/extensions/network/WebSocket.h b/extensions/network/WebSocket.h index d27afe7736..ed1acb1314 100644 --- a/extensions/network/WebSocket.h +++ b/extensions/network/WebSocket.h @@ -63,11 +63,22 @@ public: /** * @brief Errors in websocket */ - enum ErrorCode + enum class ErrorCode { - kErrorTimeout = 0, - kErrorConnectionFailure, - kErrorUnknown + TIME_OUT, + CONNECTION_FAILURE, + UNKNOWN, + }; + + /** + * Websocket state + */ + enum class State + { + CONNECTING, + OPEN, + CLOSING, + CLOSED, }; /** @@ -109,17 +120,6 @@ public: * @brief Closes the connection to server. */ void close(); - - /** - * Websocket state - */ - enum State - { - kStateConnecting = 0, - kStateOpen, - kStateClosing, - kStateClosed - }; /** * @brief Gets current state of connection. diff --git a/extensions/proj.emscripten/Makefile b/extensions/proj.emscripten/Makefile index 32ed729191..1d6c663a08 100644 --- a/extensions/proj.emscripten/Makefile +++ b/extensions/proj.emscripten/Makefile @@ -87,7 +87,8 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \ ../CCArmature/utils/CCTransformHelp.cpp \ ../CCArmature/utils/CCTweenFunction.cpp \ -../CCArmature/utils/CCUtilMath.cpp +../CCArmature/utils/CCUtilMath.cpp \ +../CCDprecated-ext.cpp include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index a905f89298..a882d33953 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -106,7 +106,8 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../Components/CCComAttribute.cpp \ ../Components/CCComAudio.cpp \ ../Components/CCComController.cpp \ -../Components/CCInputDelegate.cpp +../Components/CCInputDelegate.cpp \ +../CCDeprecated-ext.cpp include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk diff --git a/extensions/proj.nacl/Makefile b/extensions/proj.nacl/Makefile index 33e1b93fa5..dd87d3f805 100644 --- a/extensions/proj.nacl/Makefile +++ b/extensions/proj.nacl/Makefile @@ -90,7 +90,8 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../Components/CCComAttribute.cpp \ ../Components/CCComAudio.cpp \ ../Components/CCComController.cpp \ -../Components/CCInputDelegate.cpp +../Components/CCInputDelegate.cpp \ +../CCDprecated-ext.cpp all: diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index d08da80057..03fa7848c0 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -142,6 +142,7 @@ + diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index ff707f1d83..47fcc20bd4 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -357,6 +357,7 @@ network + diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 5ed803826a..bcb045c351 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -204,12 +204,12 @@ void UpdateLayer::createDownloadedDir() void UpdateLayer::onError(AssetsManager::ErrorCode errorCode) { - if (errorCode == AssetsManager::kNoNewVersion) + if (errorCode == AssetsManager::ErrorCode::NO_NEW_VERSION) { pProgressLabel->setString("no new version"); } - if (errorCode == AssetsManager::kNetwork) + if (errorCode == AssetsManager::ErrorCode::NETWORK) { pProgressLabel->setString("network error"); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp index a57d3020ee..244d5a7807 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -17,7 +17,7 @@ SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(Object * pTa return NULL; } -SEL_CCControlHandler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) { +Control::Handler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonIdleClicked", AnimationsTestLayer::onControlButtonIdleClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonWaveClicked", AnimationsTestLayer::onControlButtonWaveClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonJumpClicked", AnimationsTestLayer::onControlButtonJumpClicked); @@ -39,18 +39,18 @@ void AnimationsTestLayer::setAnimationManager(cocos2d::extension::CCBAnimationMa CC_SAFE_RETAIN(mAnimationManager); } -void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, ControlEvent pControlEvent) { +void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Idle", 0.3f); } -void AnimationsTestLayer::onControlButtonWaveClicked(Object *pSender, ControlEvent pControlEvent) { +void AnimationsTestLayer::onControlButtonWaveClicked(Object *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Wave", 0.3f); } -void AnimationsTestLayer::onControlButtonJumpClicked(Object *pSender, ControlEvent pControlEvent) { +void AnimationsTestLayer::onControlButtonJumpClicked(Object *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Jump", 0.3f); } -void AnimationsTestLayer::onControlButtonFunkyClicked(Object *pSender, ControlEvent pControlEvent) { +void AnimationsTestLayer::onControlButtonFunkyClicked(Object *pSender, Control::EventType pControlEvent) { mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Funky", 0.3f); } \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h index d72757d3ce..207af01c91 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -16,13 +16,13 @@ public: virtual ~AnimationsTestLayer(); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp index ca907cb4ca..a0d395531c 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -16,7 +16,7 @@ SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget return NULL; } -SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonClicked", ButtonTestLayer::onControlButtonClicked); return NULL; @@ -28,33 +28,33 @@ bool ButtonTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * p return false; } -void ButtonTestLayer::onControlButtonClicked(cocos2d::Object *pSender, cocos2d::extension::ControlEvent pControlEvent) { +void ButtonTestLayer::onControlButtonClicked(cocos2d::Object *pSender, cocos2d::extension::Control::EventType pControlEvent) { switch(pControlEvent) { - case ControlEventTouchDown: + case Control::EventType::TOUCH_DOWN: this->mControlEventLabel->setString("Touch Down."); break; - case ControlEventTouchDragInside: + case Control::EventType::DRAG_INSIDE: this->mControlEventLabel->setString("Touch Drag Inside."); break; - case ControlEventTouchDragOutside: + case Control::EventType::DRAG_OUTSIDE: this->mControlEventLabel->setString("Touch Drag Outside."); break; - case ControlEventTouchDragEnter: + case Control::EventType::DRAG_ENTER: this->mControlEventLabel->setString("Touch Drag Enter."); break; - case ControlEventTouchDragExit: + case Control::EventType::DRAG_EXIT: this->mControlEventLabel->setString("Touch Drag Exit."); break; - case ControlEventTouchUpInside: + case Control::EventType::TOUCH_UP_INSIDE: this->mControlEventLabel->setString("Touch Up Inside."); break; - case ControlEventTouchUpOutside: + case Control::EventType::TOUCH_UP_OUTSIDE: this->mControlEventLabel->setString("Touch Up Outside."); break; - case ControlEventTouchCancel: + case Control::EventType::TOUCH_CANCEL: this->mControlEventLabel->setString("Touch Cancel."); break; - case ControlEventValueChanged: + case Control::EventType::VALUE_CHANGED: this->mControlEventLabel->setString("Value Changed."); break; default: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index f79a54576b..fb56110015 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -16,10 +16,10 @@ public: virtual ~ButtonTestLayer(); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); private: cocos2d::LabelBMFont * mControlEventLabel; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 8942ac199c..25e7895237 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -72,7 +72,7 @@ SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(Object * return NULL; } -SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); @@ -126,19 +126,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch return bRet; } -void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { /* Create an autorelease NodeLoaderLibrary. */ NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); @@ -179,16 +179,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::e //this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader()); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 9a8cabf042..7a1bdd577f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -29,18 +29,18 @@ class HelloCocosBuilderLayer void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocos2d::extension::NodeLoader * nodeLoader = NULL); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue); virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); - void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); - void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); + void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent); private: cocos2d::Sprite * mBurstSprite; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp index 36bcf964e9..5f53a6d61d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp @@ -20,7 +20,7 @@ SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, return NULL; } -SEL_CCControlHandler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index 8533e38dda..0f0a22d85d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -16,7 +16,7 @@ class MenuTestLayer virtual ~MenuTestLayer(); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onMenuItemAClicked(cocos2d::Object * sender); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp index 6129a5faa8..825c08c27f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp @@ -9,7 +9,7 @@ SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget return NULL; } -SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 3a8f2dc84d..936d89d1d6 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -13,7 +13,7 @@ class TestHeaderLayer CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); void onBackClicked(cocos2d::Object * sender); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp index fecb8219da..c6d7b62f98 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp @@ -18,7 +18,7 @@ SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(Object return NULL; } -SEL_CCControlHandler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { +Control::Handler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h index 37059f41f9..bcf40bb17c 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h @@ -16,7 +16,7 @@ class TimelineCallbackTestLayer virtual ~TimelineCallbackTestLayer(); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index d279cb6907..82c1b93b22 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -102,8 +102,8 @@ ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(cons titleButton->setColor(Color3B(159, 168, 176)); ControlButton *button = ControlButton::create(titleButton, backgroundButton); - button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted); - button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted); + button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); + button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); return button; } @@ -140,8 +140,8 @@ bool ControlButtonTest_Event::init() titleButton->setColor(Color3B(159, 168, 176)); ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton); - controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted); - controlButton->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted); + controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); + controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); controlButton->setAnchorPoint(Point(0.5f, 1)); controlButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); @@ -154,55 +154,55 @@ bool ControlButtonTest_Event::init() addChild(background); // Sets up event handlers - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), ControlEventTouchDown); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), ControlEventTouchDragInside); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), ControlEventTouchDragOutside); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), ControlEventTouchDragEnter); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), ControlEventTouchDragExit); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), ControlEventTouchUpInside); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), ControlEventTouchUpOutside); - controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), ControlEventTouchCancel); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), Control::EventType::TOUCH_DOWN); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), Control::EventType::DRAG_INSIDE); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), Control::EventType::DRAG_OUTSIDE); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), Control::EventType::DRAG_ENTER); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), Control::EventType::DRAG_EXIT); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE); + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL); return true; } return false; } -void ControlButtonTest_Event::touchDownAction(Object *senderz, ControlEvent controlEvent) +void ControlButtonTest_Event::touchDownAction(Object *senderz, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString()); } -void ControlButtonTest_Event::touchDragInsideAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchDragInsideAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Inside")->getCString()); } -void ControlButtonTest_Event::touchDragOutsideAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchDragOutsideAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Outside")->getCString()); } -void ControlButtonTest_Event::touchDragEnterAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchDragEnterAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Enter")->getCString()); } -void ControlButtonTest_Event::touchDragExitAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchDragExitAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Drag Exit")->getCString()); } -void ControlButtonTest_Event::touchUpInsideAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchUpInsideAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Up Inside.")->getCString()); } -void ControlButtonTest_Event::touchUpOutsideAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchUpOutsideAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Up Outside.")->getCString()); } -void ControlButtonTest_Event::touchCancelAction(Object *sender, ControlEvent controlEvent) +void ControlButtonTest_Event::touchCancelAction(Object *sender, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Cancel")->getCString()); } @@ -269,8 +269,8 @@ ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *ti titleButton->setColor(Color3B(159, 168, 176)); ControlButton *button = ControlButton::create(titleButton, backgroundButton); - button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted); - button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted); + button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); + button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); return button; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index dc232b861d..6e4d602107 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -46,14 +46,14 @@ public: ControlButtonTest_Event(); ~ControlButtonTest_Event(); bool init(); - void touchDownAction(Object *sender, ControlEvent controlEvent); - void touchDragInsideAction(Object *sender, ControlEvent controlEvent); - void touchDragOutsideAction(Object *sender, ControlEvent controlEvent); - void touchDragEnterAction(Object *sender, ControlEvent controlEvent); - void touchDragExitAction(Object *sender, ControlEvent controlEvent); - void touchUpInsideAction(Object *sender, ControlEvent controlEvent); - void touchUpOutsideAction(Object *sender, ControlEvent controlEvent); - void touchCancelAction(Object *sender, ControlEvent controlEvent); + void touchDownAction(Object *sender, Control::EventType controlEvent); + void touchDragInsideAction(Object *sender, Control::EventType controlEvent); + void touchDragOutsideAction(Object *sender, Control::EventType controlEvent); + void touchDragEnterAction(Object *sender, Control::EventType controlEvent); + void touchDragExitAction(Object *sender, Control::EventType controlEvent); + void touchUpInsideAction(Object *sender, Control::EventType controlEvent); + void touchUpOutsideAction(Object *sender, Control::EventType controlEvent); + void touchCancelAction(Object *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel) CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index 10098ffd4a..71980db644 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -53,7 +53,7 @@ bool ControlColourPickerTest::init() layer->addChild(colourPicker); // Add the target-action pair - colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPickerTest::colourValueChanged), ControlEventValueChanged); + colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPickerTest::colourValueChanged), Control::EventType::VALUE_CHANGED); layer_width += colourPicker->getContentSize().width; @@ -77,7 +77,7 @@ bool ControlColourPickerTest::init() layer->setAnchorPoint(Point (0.5f, 0.5f)); // Update the color text - colourValueChanged(colourPicker, ControlEventValueChanged); + colourValueChanged(colourPicker, Control::EventType::VALUE_CHANGED); return true; } return false; @@ -89,7 +89,7 @@ ControlColourPickerTest::~ControlColourPickerTest() CC_SAFE_RELEASE(_colorLabel); } -void ControlColourPickerTest::colourValueChanged(Object *sender, ControlEvent controlEvent) +void ControlColourPickerTest::colourValueChanged(Object *sender, Control::EventType controlEvent) { ControlColourPicker* pPicker = (ControlColourPicker*)sender; _colorLabel->setString(String::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString()); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h index b3ed8f1d13..1419606d23 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h @@ -35,7 +35,7 @@ public: virtual ~ControlColourPickerTest(); bool init(); /** Callback for the change value. */ - void colourValueChanged(Object *sender, ControlEvent controlEvent); + void colourValueChanged(Object *sender, Control::EventType controlEvent); CC_SYNTHESIZE_RETAIN(LabelTTF*, _colorLabel, ColorLabel) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp index 226b9a1b17..4ecd88e929 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp @@ -67,7 +67,7 @@ bool ControlPotentiometerTest::init() potentiometer->setPosition(Point(layer_width + 10 + potentiometer->getContentSize().width / 2, 0)); // When the value of the slider will change, the given selector will be call - potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlPotentiometerTest::valueChanged), ControlEventValueChanged); + potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlPotentiometerTest::valueChanged), Control::EventType::VALUE_CHANGED); layer->addChild(potentiometer); @@ -78,13 +78,13 @@ bool ControlPotentiometerTest::init() layer->setAnchorPoint(Point(0.5f, 0.5f)); // Update the value label - this->valueChanged(potentiometer, ControlEventValueChanged); + this->valueChanged(potentiometer, Control::EventType::VALUE_CHANGED); return true; } return false; } -void ControlPotentiometerTest::valueChanged(Object *sender, ControlEvent controlEvent) +void ControlPotentiometerTest::valueChanged(Object *sender, Control::EventType controlEvent) { ControlPotentiometer* pControl = (ControlPotentiometer*)sender; // Change value of label. diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h index cdc2d72b0d..177b3d2a31 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.h @@ -35,7 +35,7 @@ public: bool init(); CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel) - void valueChanged(Object *sender, ControlEvent controlEvent); + void valueChanged(Object *sender, Control::EventType controlEvent); CONTROL_SCENE_CREATE_FUNC(ControlPotentiometerTest) }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 1ea30785f6..8c1ea2c778 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -58,7 +58,7 @@ bool ControlSliderTest::init() slider->setTag(1); // When the value of the slider will change, the given selector will be call - slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), ControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED); ControlSlider *restrictSlider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); restrictSlider->setAnchorPoint(Point(0.5f, 1.0f)); @@ -71,7 +71,7 @@ bool ControlSliderTest::init() restrictSlider->setTag(2); //same with restricted - restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), ControlEventValueChanged); + restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED); addChild(slider); addChild(restrictSlider); @@ -80,7 +80,7 @@ bool ControlSliderTest::init() return false; } -void ControlSliderTest::valueChanged(Object *sender, ControlEvent controlEvent) +void ControlSliderTest::valueChanged(Object *sender, Control::EventType controlEvent) { ControlSlider* pSlider = (ControlSlider*)sender; // Change value of label. diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h index 30356de92c..7aa6650658 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h @@ -31,7 +31,7 @@ public: ControlSliderTest(); virtual ~ControlSliderTest(); bool init(); - void valueChanged(Object *sender, ControlEvent controlEvent); + void valueChanged(Object *sender, Control::EventType controlEvent); protected: LabelTTF* _displayValueLabel; CONTROL_SCENE_CREATE_FUNC(ControlSliderTest) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp index fefb63b5b9..1ba0bb1552 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp @@ -63,7 +63,7 @@ bool ControlStepperTest::init() ControlStepper *stepper = this->makeControlStepper(); stepper->setPosition(Point(layer_width + 10 + stepper->getContentSize().width / 2, 0)); - stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlStepperTest::valueChanged), ControlEventValueChanged); + stepper->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlStepperTest::valueChanged), Control::EventType::VALUE_CHANGED); layer->addChild(stepper); layer_width += stepper->getContentSize().width; @@ -73,7 +73,7 @@ bool ControlStepperTest::init() layer->setAnchorPoint(Point(0.5f, 0.5f)); // Update the value label - this->valueChanged(stepper, ControlEventValueChanged); + this->valueChanged(stepper, Control::EventType::VALUE_CHANGED); return true; } return false; @@ -87,7 +87,7 @@ ControlStepper *ControlStepperTest::makeControlStepper() return ControlStepper::create(minusSprite, plusSprite); } -void ControlStepperTest::valueChanged(Object *sender, ControlEvent controlEvent) +void ControlStepperTest::valueChanged(Object *sender, Control::EventType controlEvent) { ControlStepper* pControl = (ControlStepper*)sender; // Change value of label. diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h index c0fe7c5cbd..1442f335e7 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.h @@ -38,7 +38,7 @@ public: ControlStepper* makeControlStepper(); /** Callback for the change value. */ - void valueChanged(Object *sender, ControlEvent controlEvent); + void valueChanged(Object *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel) CONTROL_SCENE_CREATE_FUNC(ControlStepperTest) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 787678407d..411fc38be3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -70,20 +70,20 @@ bool ControlSwitchTest::init() switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0)); layer->addChild(switchControl); - switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSwitchTest::valueChanged), ControlEventValueChanged); + switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSwitchTest::valueChanged), Control::EventType::VALUE_CHANGED); // Set the layer size layer->setContentSize(Size(layer_width, 0)); layer->setAnchorPoint(Point(0.5f, 0.5f)); // Update the value label - valueChanged(switchControl, ControlEventValueChanged); + valueChanged(switchControl, Control::EventType::VALUE_CHANGED); return true; } return false; } -void ControlSwitchTest::valueChanged(Object* sender, ControlEvent controlEvent) +void ControlSwitchTest::valueChanged(Object* sender, Control::EventType controlEvent) { ControlSwitch* pSwitch = (ControlSwitch*)sender; if (pSwitch->isOn()) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h index 09793af60c..d6443b9fe1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h @@ -32,7 +32,7 @@ public: virtual ~ControlSwitchTest(); bool init(); /** Callback for the change value. */ - void valueChanged(Object* sender, ControlEvent controlEvent); + void valueChanged(Object* sender, Control::EventType controlEvent); LabelTTF *_displayValueLabel; CONTROL_SCENE_CREATE_FUNC(ControlSwitchTest) }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index 51168f33bd..bfc10dab2d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -48,7 +48,7 @@ EditBoxTest::EditBoxTest() _editName->setPlaceHolder("Name:"); _editName->setPlaceholderFontColor(Color3B::WHITE); _editName->setMaxLength(8); - _editName->setReturnType(kKeyboardReturnTypeDone); + _editName->setReturnType(EditBox::KeyboardReturnType::DONE); _editName->setDelegate(this); addChild(_editName); @@ -63,8 +63,8 @@ EditBoxTest::EditBoxTest() _editPassword->setFontColor(Color3B::GREEN); _editPassword->setPlaceHolder("Password:"); _editPassword->setMaxLength(6); - _editPassword->setInputFlag(kEditBoxInputFlagPassword); - _editPassword->setInputMode(kEditBoxInputModeSingleLine); + _editPassword->setInputFlag(EditBox::InputFlag::PASSWORD); + _editPassword->setInputMode(EditBox::InputMode::SINGLE_LINE); _editPassword->setDelegate(this); addChild(_editPassword); @@ -73,7 +73,7 @@ EditBoxTest::EditBoxTest() _editEmail->setPosition(Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); _editEmail->setAnchorPoint(Point(0.5, 1.0f)); _editEmail->setPlaceHolder("Email:"); - _editEmail->setInputMode(kEditBoxInputModeEmailAddr); + _editEmail->setInputMode(EditBox::InputMode::EMAIL_ADDRESS); _editEmail->setDelegate(this); addChild(_editEmail); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index 96b92e2199..f3de679aff 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -201,7 +201,7 @@ void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) // Menu Callbacks void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) { - if (_wsiSendText->getReadyState() == WebSocket::kStateOpen) + if (_wsiSendText->getReadyState() == WebSocket::State::OPEN) { _sendTextStatus->setString("Send Text WS is waiting..."); _wsiSendText->send("Hello WebSocket, I'm a text message."); @@ -216,7 +216,7 @@ void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender) { - if (_wsiSendBinary->getReadyState() == WebSocket::kStateOpen) + if (_wsiSendBinary->getReadyState() == WebSocket::State::OPEN) { _sendBinaryStatus->setString("Send Binary WS is waiting..."); char buf[] = "Hello WebSocket,\0 I'm\0 a\0 binary\0 message\0."; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 14d9f8ca1f..d6fc59f514 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -24,17 +24,17 @@ bool TableViewTestLayer::init() Size winSize = Director::getInstance()->getWinSize(); TableView* tableView = TableView::create(this, Size(250, 60)); - tableView->setDirection(kScrollViewDirectionHorizontal); + tableView->setDirection(ScrollView::Direction::HORIZONTAL); tableView->setPosition(Point(20,winSize.height/2-30)); tableView->setDelegate(this); this->addChild(tableView); tableView->reloadData(); tableView = TableView::create(this, Size(60, 250)); - tableView->setDirection(kScrollViewDirectionVertical); + tableView->setDirection(ScrollView::Direction::VERTICAL); tableView->setPosition(Point(winSize.width-150,winSize.height/2-120)); tableView->setDelegate(this); - tableView->setVerticalFillOrder(kTableViewFillTopDown); + tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN); this->addChild(tableView); tableView->reloadData(); diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 6244072167..510f3b07b9 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -865,7 +865,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl() { ControlSlider * slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); - slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), ControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), Control::EventType::VALUE_CHANGED); slider->setMinimumValue(-3.0f); slider->setMaximumValue(3.0f); @@ -874,7 +874,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl() return slider; } -void SchedulerTimeScale::sliderAction(Object* sender, ControlEvent controlEvent) +void SchedulerTimeScale::sliderAction(Object* sender, Control::EventType controlEvent) { ControlSlider* pSliderCtl = static_cast(sender); float scale; @@ -953,7 +953,7 @@ ControlSlider *TwoSchedulers::sliderCtl() // CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f); ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); //[[UISlider alloc] initWithFrame:frame]; - slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), ControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), Control::EventType::VALUE_CHANGED); // in case the parent view draws with a custom color or gradient, use a transparent color //slider.backgroundColor = [UIColor clearColor]; @@ -966,7 +966,7 @@ ControlSlider *TwoSchedulers::sliderCtl() return slider; } -void TwoSchedulers::sliderAction(Object* sender, ControlEvent controlEvent) +void TwoSchedulers::sliderAction(Object* sender, Control::EventType controlEvent) { float scale; diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h index 34ea78d2bf..383c3ee1ac 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h @@ -228,7 +228,7 @@ public: virtual std::string title(); virtual std::string subtitle(); ControlSlider* sliderCtl(); - void sliderAction(Object* sender, ControlEvent controlEvent); + void sliderAction(Object* sender, Control::EventType controlEvent); ControlSlider* _sliderCtl; }; @@ -241,7 +241,7 @@ public: virtual std::string subtitle(); void onEnter(); ControlSlider* sliderCtl(); - void sliderAction(Object* sender, ControlEvent controlEvent); + void sliderAction(Object* sender, Control::EventType controlEvent); Scheduler *sched1; Scheduler *sched2; ActionManager *actionManager1; diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index 55cd368e61..676082733e 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -593,7 +593,7 @@ ControlSlider* ShaderBlur::createSliderCtl() slider->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 3.0f)); // When the value of the slider will change, the given selector will be call - slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), ControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED); return slider; @@ -623,7 +623,7 @@ bool ShaderBlur::init() return false; } -void ShaderBlur::sliderAction(Object* sender, ControlEvent controlEvent) +void ShaderBlur::sliderAction(Object* sender, Control::EventType controlEvent) { ControlSlider* pSlider = (ControlSlider*)sender; _blurSprite->setBlurSize(pSlider->getValue()); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h index 6ab3ed7559..707793a1c5 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h @@ -91,7 +91,7 @@ public: virtual std::string subtitle(); virtual bool init(); ControlSlider* createSliderCtl(); - void sliderAction(Object* sender, ControlEvent controlEvent); + void sliderAction(Object* sender, Control::EventType controlEvent); protected: SpriteBlur* _blurSprite; ControlSlider* _sliderCtl; diff --git a/scripting/javascript/bindings/js/jsb_cocos2d_extension.js b/scripting/javascript/bindings/js/jsb_cocos2d_extension.js index b5f1411212..3272bc7765 100644 --- a/scripting/javascript/bindings/js/jsb_cocos2d_extension.js +++ b/scripting/javascript/bindings/js/jsb_cocos2d_extension.js @@ -45,7 +45,7 @@ cc.KEYBOARD_RETURNTYPE_SEARCH = 3; cc.KEYBOARD_RETURNTYPE_GO = 4; /** - * The EditBoxInputMode defines the type of text that the user is allowed * to enter. + * The EditBox::InputMode defines the type of text that the user is allowed * to enter. * @constant * @type Number */ diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index d8e2e29f20..523cdcda10 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -29,7 +29,7 @@ SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d:: return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } -SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, +Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; @@ -56,7 +56,7 @@ void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } -void CCBScriptCallbackProxy::controlCallback(Object *pSender, ControlEvent event) { +void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.h b/scripting/javascript/bindings/js_bindings_ccbreader.h index ff4b241619..e81b9d3be2 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.h +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -30,7 +30,7 @@ public: virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); @@ -39,7 +39,7 @@ public: virtual CCBSelectorResolver * createNew(); void menuItemCallback(Object *pSender); - void controlCallback(Object *pSender, cocos2d::extension::ControlEvent event); + void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event); void setCallbackProperty(const char *prop); void setJSOwner(jsval ownr); jsval getJSOwner(); diff --git a/scripting/javascript/bindings/jsb_websocket.cpp b/scripting/javascript/bindings/jsb_websocket.cpp index 9b115ca19e..09a4dc277f 100644 --- a/scripting/javascript/bindings/jsb_websocket.cpp +++ b/scripting/javascript/bindings/jsb_websocket.cpp @@ -365,13 +365,13 @@ void register_jsb_websocket(JSContext *cx, JSObject *global) { JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()")); - JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::kStateConnecting) + JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::State::CONNECTING) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::kStateOpen) + JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::State::OPEN) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::kStateClosing) + JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::State::CLOSING) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); - JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::kStateClosed) + JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::State::CLOSED) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); // make the class enumerable in the registered namespace diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 7e708e27c6..4ae2a7c361 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -fa9c4583d202c4fd4af5f97259eb3cac2bfbdec1 \ No newline at end of file +ab4c02a68cfeccde64ff6b990aba6925d8e7787d \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp index 465275193f..c15252cd48 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp @@ -471,7 +471,7 @@ int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S) { Control* control = (Control*) tolua_tousertype(tolua_S,1,0); LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); - ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,3,0); + int controlevent = (int)tolua_tonumber(tolua_S,3,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) @@ -503,7 +503,7 @@ int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S) #endif { Control* control = (Control*) tolua_tousertype(tolua_S,1,0); - ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,2,0); + int controlevent = (int)tolua_tonumber(tolua_S,2,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) diff --git a/scripting/lua/cocos2dx_support/LuaScrollView.cpp b/scripting/lua/cocos2dx_support/LuaScrollView.cpp index 10c676b50e..62591a4917 100644 --- a/scripting/lua/cocos2dx_support/LuaScrollView.cpp +++ b/scripting/lua/cocos2dx_support/LuaScrollView.cpp @@ -591,7 +591,7 @@ static int tolua_Cocos2d_ScrollView_getDirection00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDirection'", NULL); #endif { - ScrollViewDirection tolua_ret = (ScrollViewDirection) self->getDirection(); + ScrollView::Direction tolua_ret = (ScrollView::Direction) self->getDirection(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } @@ -752,7 +752,7 @@ static int tolua_Cocos2d_ScrollView_setDirection00(lua_State* tolua_S) #endif { LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0); - ScrollViewDirection eDirection = ((ScrollViewDirection) (int) tolua_tonumber(tolua_S,2,0)); + ScrollView::Direction eDirection = ((ScrollView::Direction) (int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDirection'", NULL); #endif @@ -1562,10 +1562,10 @@ TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S) tolua_reg_scrollview_type(tolua_S); tolua_module(tolua_S,NULL,0); tolua_beginmodule(tolua_S,NULL); - tolua_constant(tolua_S,"kScrollViewDirectionNone",kScrollViewDirectionNone); - tolua_constant(tolua_S,"kScrollViewDirectionHorizontal",kScrollViewDirectionHorizontal); - tolua_constant(tolua_S,"kScrollViewDirectionVertical",kScrollViewDirectionVertical); - tolua_constant(tolua_S,"kScrollViewDirectionBoth",kScrollViewDirectionBoth); + tolua_constant(tolua_S,"kScrollViewDirectionNone",(int)ScrollView::Direction::NONE); + tolua_constant(tolua_S,"kScrollViewDirectionHorizontal",(int)ScrollView::Direction::HORIZONTAL); + tolua_constant(tolua_S,"kScrollViewDirectionVertical",(int)ScrollView::Direction::VERTICAL); + tolua_constant(tolua_S,"kScrollViewDirectionBoth",(int)ScrollView::Direction::BOTH); tolua_constant(tolua_S,"kScrollViewScriptScroll",LuaScrollView::kScrollViewScriptScroll); tolua_constant(tolua_S,"kScrollViewScriptZoom",LuaScrollView::kScrollViewScriptZoom); #ifdef __cplusplus diff --git a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp index 2a1a08b24d..7d4d0a8e5d 100644 --- a/scripting/lua/cocos2dx_support/Lua_web_socket.cpp +++ b/scripting/lua/cocos2dx_support/Lua_web_socket.cpp @@ -265,7 +265,7 @@ static int tolua_Cocos2d_WebSocket_getReadyState00(lua_State* tolua_S) LuaWebSocket *self = (LuaWebSocket*)tolua_tousertype(tolua_S,1,0); int tolua_ret = -1; if (NULL != self) { - tolua_ret = self->getReadyState(); + tolua_ret = (int)self->getReadyState(); } tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } @@ -382,10 +382,10 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_reg_Web_Socket_type(tolua_S); tolua_module(tolua_S,NULL,0); tolua_beginmodule(tolua_S,NULL); - tolua_constant(tolua_S,"kStateConnecting",WebSocket::kStateConnecting); - tolua_constant(tolua_S,"kStateOpen",WebSocket::kStateOpen); - tolua_constant(tolua_S,"kStateClosing",WebSocket::kStateClosing); - tolua_constant(tolua_S,"kStateClosed",WebSocket::kStateClosed); + tolua_constant(tolua_S,"kStateConnecting",(int)WebSocket::State::CONNECTING); + tolua_constant(tolua_S,"kStateOpen",(int)WebSocket::State::OPEN); + tolua_constant(tolua_S,"kStateClosing",(int)WebSocket::State::CLOSING); + tolua_constant(tolua_S,"kStateClosed",(int)WebSocket::State::CLOSED); tolua_constant(tolua_S,"kWebSocketScriptHandlerOpen",LuaWebSocket::kWebSocketScriptHandlerOpen); tolua_constant(tolua_S,"kWebSocketScriptHandlerMessage",LuaWebSocket::kWebSocketScriptHandlerMessage); tolua_constant(tolua_S,"kWebSocketScriptHandlerClose",LuaWebSocket::kWebSocketScriptHandlerClose); diff --git a/tools/tolua++/basic.lua b/tools/tolua++/basic.lua index 2aa38bd3a7..ee50a6b941 100644 --- a/tools/tolua++/basic.lua +++ b/tools/tolua++/basic.lua @@ -320,7 +320,7 @@ TOLUA_API int tolua_Cocos2d_open (lua_State* tolua_S);]], [[]]) result = string.gsub(result, '(\"const )(CC%u%w*)', '%1_%2') - local skip_contents = { "CCPointMake", "CCSizeMake", "CCRectMake", "CCLOG", "CCLog", "CCAssert", "CCTexture2DPixelFormat", "CCTextAlignment", "CCVerticalTextAlignment" } + local skip_contents = { "CCPointMake", "CCSizeMake", "CCRectMake", "CCLOG", "CCLog", "CCAssert", "CCTexture2DPixelFormat", "CCTextAlignment", "CCVerticalTextAlignment", "CCControlState", "CCControlEvent" } local function remove_prefix() result = string.gsub(result, '[^_\"k]CC%u%w+', function(m) @@ -343,6 +343,7 @@ TOLUA_API int tolua_Cocos2d_open (lua_State* tolua_S);]], [[]]) result = string.gsub(result, '(tolua_tonumber%(tolua_S,%d,)(kCC)', '%1(int)%2') result = string.gsub(result, '(tolua_constant%(tolua_S,"k%w*",)(k)', '%1(int)%2') + result = string.gsub(result, '(tolua_constant%(tolua_S,"CCControl%w*",)(CCControl)', '%1(int)%2') result = string.gsub(result, "(self%->setEmitterMode%()", "%1(ParticleSystem::Mode)")