From 323af3c8898d3e5cb81caf54f62ddfc5d06cb286 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 25 Jul 2013 22:29:12 +0800 Subject: [PATCH 01/12] issue #2430:use upper letters for enum item in AssetsManager and WebSocket --- cocos2dx/platform/CCImage.h | 10 +++++++++- extensions/AssetsManager/AssetsManager.cpp | 10 +++++----- extensions/AssetsManager/AssetsManager.h | 14 ++++++++++---- extensions/network/WebSocket.cpp | 2 +- extensions/network/WebSocket.h | 10 +++++++--- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 044a2022a2..d67e96bb60 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -57,7 +57,15 @@ public: FORMAT_TIFF, FORMAT_WEBP, FORMAT_RAW_DATA, - FORMAT_UNKOWN + FORMAT_UNKOWN, + + // don't use them + kFmtJpg = FORMAT_JPG, + kFmtPng = FORMAT_PNG, + kFmtTiff = FORMAT_TIFF, + kFmtWebp = FORMAT_WEBP, + kFmtRawData = FORMAT_RAW_DATA, + kFmtUnKnown = FORMAT_UNKOWN }; typedef enum diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index fe00781dfb..3d03fef248 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -134,7 +134,7 @@ bool AssetsManager::checkUpdate() if (res != 0) { - sendErrorMessage(kNetwork); + sendErrorMessage(ERROR_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(ERROR_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(AssetsManager::ERROR_UNCOMPRESS); break; } @@ -403,7 +403,7 @@ bool AssetsManager::downLoad() FILE *fp = fopen(outFileName.c_str(), "wb"); if (! fp) { - sendErrorMessage(kCreateFile); + sendErrorMessage(ERROR_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(ERROR_NETWORK); CCLOG("error when download package"); fclose(fp); return false; diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index 46f50ebe71..1f154bc749 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -47,16 +47,16 @@ public: enum ErrorCode { // Error caused by creating a file to store downloaded data - kCreateFile, + ERROR_CREATE_FILE, /** Error caused by network -- network unavaivable -- timeout -- ... */ - kNetwork, + ERROR_NETWORK, /** There is not a new version */ - kNoNewVersion, + ERROR_NO_NEW_VERSION, /** Error caused in uncompressing stage -- can not open zip file -- can not read file global information @@ -64,7 +64,13 @@ public: -- can not create a directory -- ... */ - kUncompress, + ERROR_UNCOMPRESS, + + // keep compatability + kCreateFile = ERROR_CREATE_FILE, + kNetwork = ERROR_NETWORK, + kNoNewVersion = ERROR_NO_NEW_VERSION, + kUncompress = ERROR_UNCOMPRESS, }; /* @brief Creates a AssetsManager with new package url, version code url and storage path. diff --git a/extensions/network/WebSocket.cpp b/extensions/network/WebSocket.cpp index b55d2b34cc..4bc9dd5e2a 100644 --- a/extensions/network/WebSocket.cpp +++ b/extensions/network/WebSocket.cpp @@ -637,7 +637,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 = ERROR_CONNECTION_FAILURE; _delegate->onError(this, err); } break; diff --git a/extensions/network/WebSocket.h b/extensions/network/WebSocket.h index d27afe7736..af5be2c849 100644 --- a/extensions/network/WebSocket.h +++ b/extensions/network/WebSocket.h @@ -65,9 +65,13 @@ public: */ enum ErrorCode { - kErrorTimeout = 0, - kErrorConnectionFailure, - kErrorUnknown + ERROR_TIME_OUT, + ERROR_CONNECTION_FAILURE, + ERROR_UNKNOWN, + + kErrorTimeout = ERROR_TIME_OUT, + kErrorConnectionFailure = ERROR_CONNECTION_FAILURE, + kErrorUnknown = ERROR_UNKNOWN, }; /** From b36a4f1df0d11169f6c5ecfad9f73c181e0ba9a0 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 25 Jul 2013 23:09:18 +0800 Subject: [PATCH 02/12] issue #2430:use upper letters for enum item in Image --- cocos2dx/platform/CCImage.h | 38 +++++++++++++++++---------- cocos2dx/platform/android/CCImage.cpp | 8 +++--- cocos2dx/platform/ios/CCImage.mm | 6 ++--- cocos2dx/platform/linux/CCImage.cpp | 16 +++++------ cocos2dx/platform/mac/CCImage.mm | 2 +- cocos2dx/platform/nacl/CCImage.cpp | 22 ++++++++-------- cocos2dx/platform/tizen/CCImage.cpp | 14 +++++----- cocos2dx/textures/CCTexture2D.cpp | 14 +++++----- 8 files changed, 65 insertions(+), 55 deletions(-) diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index d67e96bb60..420e9cc75b 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -50,7 +50,7 @@ public: Image(); virtual ~Image(); - enum Format + typedef enum Format { FORMAT_JPG, FORMAT_PNG, @@ -66,19 +66,29 @@ public: kFmtWebp = FORMAT_WEBP, kFmtRawData = FORMAT_RAW_DATA, kFmtUnKnown = FORMAT_UNKOWN - }; + }EImageFormat; - typedef enum + typedef enum 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. + TEXT_ALIGN_CENTER = 0x33, ///< Horizontal center and vertical center. + TEXT_ALIGN_TOP = 0x13, ///< Horizontal center and vertical top. + TEXT_ALIGN_TOP_RIGHT = 0x12, ///< Horizontal right and vertical top. + TEXT_ALIGN_RIGHT = 0x32, ///< Horizontal right and vertical center. + TEXT_ALIGN_BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. + TEXT_ALIGN_BOTTOM = 0x23, ///< Horizontal center and vertical bottom. + TEXT_ALIGN_BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom. + TEXT_ALIGN_LEFT = 0x31, ///< Horizontal left and vertical center. + TEXT_ALIGN_TOP_LEFT = 0x11, ///< Horizontal left and vertical top. + + kAlignCenter = TEXT_ALIGN_CENTER, + kAlignTop = TEXT_ALIGN_TOP, + kAlignTopRight = TEXT_ALIGN_TOP_RIGHT, + kAlignRight = TEXT_ALIGN_RIGHT, + kAlignBottomRight = TEXT_ALIGN_BOTTOM_RIGHT, + kAlignBottom = TEXT_ALIGN_BOTTOM, + kAlignBottomLeft = TEXT_ALIGN_BOTTOM_LEFT, + kAlignLeft = TEXT_ALIGN_LEFT, + kAlignTopLeft = TEXT_ALIGN_TOP_LEFT, }ETextAlign; /** @@ -121,7 +131,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TEXT_ALIGN_CENTER, const char * pFontName = 0, int nSize = 0); @@ -131,7 +141,7 @@ public: const char * pText, int nWidth = 0, int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, + TextAlign eAlignMask = TEXT_ALIGN_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 6a96a2987f..ea7118f75b 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 @@ -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..c0af46dba2 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::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_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::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_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 720f195561..cf7f8894bf 100644 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -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..14ee649563 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::TEXT_ALIGN_CENTER) { iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2 - SHIFT6(face->glyph->metrics.horiBearingX ); - } else if (eAlignMask == Image::kAlignRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_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::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || + eAlignMask == Image::TEXT_ALIGN_RIGHT ) { //vertical center iRet = (borderHeight - txtHeight)/2; - } else if (eAlignMask == Image::kAlignBottomRight || - eAlignMask == Image::kAlignBottom || - eAlignMask == Image::kAlignBottomLeft ) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || + eAlignMask == Image::TEXT_ALIGN_BOTTOM || + eAlignMask == Image::TEXT_ALIGN_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..3c8776be33 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::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; - } else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) { + } else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_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::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; - } else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) { + } else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_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/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index a9e7b790aa..f712467ae4 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::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP_LEFT : Image::TEXT_ALIGN_TOP_RIGHT; } else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_CENTER + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_LEFT : Image::TEXT_ALIGN_RIGHT; } else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment) { - eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom - : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; + eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM + : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM_LEFT : Image::TEXT_ALIGN_BOTTOM_RIGHT; } else { From 0b8de88ddc5d5e854e307e02a6f55c4b0e3ad0cc Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 12:08:18 +0800 Subject: [PATCH 03/12] issue 2430:use enum class --- extensions/AssetsManager/AssetsManager.cpp | 10 +- extensions/AssetsManager/AssetsManager.h | 16 +- extensions/network/SocketIO.cpp | 308 +++++++++--------- extensions/network/WebSocket.cpp | 91 +++--- extensions/network/WebSocket.h | 34 +- .../NetworkTest/WebSocketTest.cpp | 4 +- 6 files changed, 219 insertions(+), 244 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index 3d03fef248..e1e5a06ec5 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -134,7 +134,7 @@ bool AssetsManager::checkUpdate() if (res != 0) { - sendErrorMessage(ERROR_NETWORK); + 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(ERROR_NO_NEW_VERSION); + 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::ERROR_UNCOMPRESS); + sendErrorMessage(ErrorCode::UNCOMPRESS); break; } @@ -403,7 +403,7 @@ bool AssetsManager::downLoad() FILE *fp = fopen(outFileName.c_str(), "wb"); if (! fp) { - sendErrorMessage(ERROR_CREATE_FILE); + 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(ERROR_NETWORK); + 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 1f154bc749..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 - ERROR_CREATE_FILE, + CREATE_FILE, /** Error caused by network -- network unavaivable -- timeout -- ... */ - ERROR_NETWORK, + NETWORK, /** There is not a new version */ - ERROR_NO_NEW_VERSION, + NO_NEW_VERSION, /** Error caused in uncompressing stage -- can not open zip file -- can not read file global information @@ -64,13 +64,7 @@ public: -- can not create a directory -- ... */ - ERROR_UNCOMPRESS, - - // keep compatability - kCreateFile = ERROR_CREATE_FILE, - kNetwork = ERROR_NETWORK, - kNoNewVersion = ERROR_NO_NEW_VERSION, - kUncompress = ERROR_UNCOMPRESS, + UNCOMPRESS, }; /* @brief Creates a AssetsManager with new package url, version code url and storage path. 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 4bc9dd5e2a..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 = ERROR_CONNECTION_FAILURE; + WebSocket::ErrorCode err = ErrorCode::CONNECTION_FAILURE; _delegate->onError(this, err); } break; diff --git a/extensions/network/WebSocket.h b/extensions/network/WebSocket.h index af5be2c849..ed1acb1314 100644 --- a/extensions/network/WebSocket.h +++ b/extensions/network/WebSocket.h @@ -63,15 +63,22 @@ public: /** * @brief Errors in websocket */ - enum ErrorCode + enum class ErrorCode { - ERROR_TIME_OUT, - ERROR_CONNECTION_FAILURE, - ERROR_UNKNOWN, - - kErrorTimeout = ERROR_TIME_OUT, - kErrorConnectionFailure = ERROR_CONNECTION_FAILURE, - kErrorUnknown = ERROR_UNKNOWN, + TIME_OUT, + CONNECTION_FAILURE, + UNKNOWN, + }; + + /** + * Websocket state + */ + enum class State + { + CONNECTING, + OPEN, + CLOSING, + CLOSED, }; /** @@ -113,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/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index 8f171be431..0dbb9dfa9c 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."; From f55d73194e247bdfcd523d18f42cadeb0518adfe Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 14:37:26 +0800 Subject: [PATCH 04/12] issue 2430:use enum class for Control enum values --- .../project.pbxproj.REMOVED.git-id | 2 +- extensions/CCBReader/CCBSelectorResolver.h | 2 +- .../CCBReader/CCControlButtonLoader.cpp | 30 +++--- extensions/CCBReader/CCNodeLoader.cpp | 4 +- extensions/CCBReader/CCNodeLoader.h | 5 +- extensions/CCDeprecated-ext.cpp | 44 +++++++++ extensions/CCDeprecated-ext.h | 34 ++++--- .../GUI/CCControlExtension/CCControl.cpp | 37 ++++---- extensions/GUI/CCControlExtension/CCControl.h | 68 +++++++------- .../CCControlExtension/CCControlButton.cpp | 94 +++++++++---------- .../GUI/CCControlExtension/CCControlButton.h | 38 ++++---- .../CCControlColourPicker.cpp | 14 +-- .../CCControlColourPicker.h | 4 +- .../CCControlExtension/CCControlHuePicker.cpp | 4 +- .../CCControlPotentiometer.cpp | 2 +- .../CCControlSaturationBrightnessPicker.cpp | 4 +- .../CCControlExtension/CCControlSlider.cpp | 2 +- .../CCControlExtension/CCControlStepper.cpp | 2 +- .../GUI/CCControlExtension/CCControlStepper.h | 2 +- .../CCControlExtension/CCControlSwitch.cpp | 2 +- .../GUI/CCControlExtension/CCInvocation.cpp | 4 +- .../GUI/CCControlExtension/CCInvocation.h | 15 ++- extensions/GUI/CCEditBox/CCEditBox.cpp | 8 +- extensions/GUI/CCEditBox/CCEditBox.h | 2 +- .../AnimationsTest/AnimationsTestLayer.cpp | 8 +- .../AnimationsTest/AnimationsTestLayer.h | 8 +- .../ButtonTest/ButtonTestLayer.cpp | 20 ++-- .../ButtonTest/ButtonTestLayer.h | 2 +- .../HelloCocosBuilderLayer.cpp | 14 +-- .../HelloCocosBuilderLayer.h | 14 +-- .../CCControlButtonTest.cpp | 44 ++++----- .../CCControlButtonTest/CCControlButtonTest.h | 16 ++-- .../CCControlColourPickerTest.cpp | 6 +- .../CCControlColourPickerTest.h | 2 +- .../CCControlPotentiometerTest.cpp | 6 +- .../CCControlPotentiometerTest.h | 2 +- .../CCControlSliderTest.cpp | 6 +- .../CCControlSliderTest/CCControlSliderTest.h | 2 +- .../CCControlStepperTest.cpp | 6 +- .../CCControlStepperTest.h | 2 +- .../CCControlSwitchTest.cpp | 6 +- .../CCControlSwitchTest/CCControlSwitchTest.h | 2 +- .../Classes/SchedulerTest/SchedulerTest.cpp | 8 +- .../Classes/SchedulerTest/SchedulerTest.h | 4 +- .../TestCpp/Classes/ShaderTest/ShaderTest.cpp | 4 +- .../TestCpp/Classes/ShaderTest/ShaderTest.h | 2 +- .../bindings/js_bindings_ccbreader.cpp | 2 +- .../bindings/js_bindings_ccbreader.h | 2 +- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- .../cocos2dx_support/LuaScriptHandlerMgr.cpp | 4 +- 50 files changed, 333 insertions(+), 284 deletions(-) create mode 100644 extensions/CCDeprecated-ext.cpp 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/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/CCDeprecated-ext.cpp b/extensions/CCDeprecated-ext.cpp new file mode 100644 index 0000000000..af5ffd07dc --- /dev/null +++ b/extensions/CCDeprecated-ext.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** + 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; + +NS_CC_EXT_END diff --git a/extensions/CCDeprecated-ext.h b/extensions/CCDeprecated-ext.h index 8c93828447..77e8255b56 100644 --- a/extensions/CCDeprecated-ext.h +++ b/extensions/CCDeprecated-ext.h @@ -120,8 +120,6 @@ 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; @@ -151,20 +149,26 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType; #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 -#define CCControlStateNormal ControlStateNormal -#define CCControlStateHighlighted ControlStateHighlighted -#define CCControlStateDisabled ControlStateDisabled -#define CCControlStateSelected ControlStateSelected +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 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 d1d17050e5..5104e650e7 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..5353aebb0b 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -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; } diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index 905e9fc9f4..4d1151a137 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -356,7 +356,7 @@ public: virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info); /* callback funtions */ - void touchDownAction(Object *sender, ControlEvent controlEvent); + void touchDownAction(Object *sender, Control::EventType controlEvent); protected: EditBoxImpl* _editBoxImpl; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp index a57d3020ee..714fa0e916 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -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 16dce83727..a917cc91d9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -19,10 +19,10 @@ public: virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonJumpClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonFunkyClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonJumpClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onControlButtonFunkyClicked(cocos2d::Object * pSender, 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..7c044de877 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -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 8f7a3f8a25..22280ad8ca 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -19,7 +19,7 @@ public: virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonClicked(cocos2d::Object * pSender, 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 89c5603de0..9224f267d8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -126,19 +126,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch return bRet; } -void HelloCocosBuilderLayer::onMenuTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onMenuTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onSpriteTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onSpriteTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onButtonTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onButtonTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { /* Create an autorelease NodeLoaderLibrary. */ NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); @@ -179,16 +179,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d:: //this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * pSender, cocos2d::extension::Control::EventType pControlEvent) { this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * pSender, 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 55e4d44845..37e69ea1dc 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -34,13 +34,13 @@ class HelloCocosBuilderLayer 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 * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onButtonTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onAnimationsTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onParticleSystemTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onScrollViewTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onTimelineCallbackSoundClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onMenuTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onButtonTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onAnimationsTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onParticleSystemTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onScrollViewTestClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); + void onTimelineCallbackSoundClicked(cocos2d::Object * pSender, cocos2d::extension::Control::EventType pControlEvent); private: cocos2d::Sprite * mBurstSprite; 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/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 94e094198a..ea95ac1a5c 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* pSender, ControlEvent controlEvent) +void SchedulerTimeScale::sliderAction(Object* pSender, Control::EventType controlEvent) { ControlSlider* pSliderCtl = static_cast(pSender); 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 464ffff35a..22b100c03f 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* pSender, ControlEvent controlEvent); + void sliderAction(Object* pSender, 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 258070f96a..34fd5cf84f 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 09f70b987c..f5845eadaf 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_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index d8e2e29f20..ea86b4c1fb 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -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..0a83a3bf2e 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.h +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -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/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 47aa28698d..8bb198e845 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -bfb95e6faa9b59a5045353dffbae4d7cad7d6655 \ No newline at end of file +ca873cec3679fc5428aabc3ff0c1eeb585d98f1a \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp index d79ad670df..4cda0c9f86 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp @@ -470,7 +470,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); + Control::EventType controlevent = (Control::EventType)tolua_tonumber(tolua_S,3,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) @@ -502,7 +502,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); + Control::EventType controlevent = (Control::EventType)tolua_tonumber(tolua_S,2,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) From bafc01c2aaaecf7f4842de29b4afbd752ef6335d Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 15:55:12 +0800 Subject: [PATCH 05/12] issue 2430:fix a compiling error and add missing cpp --- cocos2dx/platform/win32/CCImage.cpp | 2 +- extensions/proj.win32/libExtensions.vcxproj | 1 + extensions/proj.win32/libExtensions.vcxproj.filters | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index 0b0c31f020..15d3e2aae5 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -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/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 + From 0b3ed85914ab61755e0f60be73e270371d903ed3 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 16:43:40 +0800 Subject: [PATCH 06/12] issue #2430:fix some compiling error --- extensions/proj.linux/Makefile | 2 +- samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index 9609edd8cc..a882d33953 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -107,7 +107,7 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../Components/CCComAudio.cpp \ ../Components/CCComController.cpp \ ../Components/CCInputDelegate.cpp \ -../CCDprecated-ext.cpp +../CCDeprecated-ext.cpp include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk 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"); } From a7c1904eb82d2243ad4d70dc746d519ccb5b03b5 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 17:45:01 +0800 Subject: [PATCH 07/12] issue #2430:move EditBox enum into class --- extensions/CCDeprecated-ext.cpp | 20 ++ extensions/CCDeprecated-ext.h | 36 ++-- extensions/GUI/CCEditBox/CCEditBox.cpp | 12 +- extensions/GUI/CCEditBox/CCEditBox.h | 199 +++++++++--------- extensions/GUI/CCEditBox/CCEditBoxImpl.h | 6 +- .../GUI/CCEditBox/CCEditBoxImplAndroid.cpp | 20 +- .../GUI/CCEditBox/CCEditBoxImplAndroid.h | 12 +- extensions/GUI/CCEditBox/CCEditBoxImplIOS.h | 6 +- extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm | 38 ++-- extensions/GUI/CCEditBox/CCEditBoxImplMac.h | 6 +- extensions/GUI/CCEditBox/CCEditBoxImplMac.mm | 6 +- .../GUI/CCEditBox/CCEditBoxImplTizen.cpp | 12 +- extensions/GUI/CCEditBox/CCEditBoxImplTizen.h | 12 +- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 10 +- extensions/GUI/CCEditBox/CCEditBoxImplWin.h | 12 +- .../EditBoxTest/EditBoxTest.cpp | 2 +- .../bindings/js/jsb_cocos2d_extension.js | 2 +- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- 18 files changed, 220 insertions(+), 193 deletions(-) diff --git a/extensions/CCDeprecated-ext.cpp b/extensions/CCDeprecated-ext.cpp index af5ffd07dc..6c3c4be2d3 100644 --- a/extensions/CCDeprecated-ext.cpp +++ b/extensions/CCDeprecated-ext.cpp @@ -41,4 +41,24 @@ const Control::State CCControlStateHighlighted = Control::State::HIGH_LIGHTED; const Control::State CCControlStateDisabled = Control::State::DISABLED; const Control::State CCControlStateSelected = Control::State::SELECTED; +const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDefault = EditBox::EditBox::KeyboardReturnType::DEFAULT; +const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDone = EditBox::EditBox::KeyboardReturnType::DONE; +const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSend = EditBox::EditBox::KeyboardReturnType::SEND; +const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSearch = EditBox::EditBox::KeyboardReturnType::SEARCH; +const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeGo = EditBox::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; + NS_CC_EXT_END diff --git a/extensions/CCDeprecated-ext.h b/extensions/CCDeprecated-ext.h index 77e8255b56..245cb1b80d 100644 --- a/extensions/CCDeprecated-ext.h +++ b/extensions/CCDeprecated-ext.h @@ -131,25 +131,35 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType; #define kCCScrollViewDirectionHorizontal kScrollViewDirectionHorizontal #define kCCScrollViewDirectionVertical kScrollViewDirectionVertical #define kCCScrollViewDirectionBoth kScrollViewDirectionBoth -#define kCCKeyboardReturnTypeDefault kKeyboardReturnTypeDefault -#define kCCKeyboardReturnTypeDone kKeyboardReturnTypeDone -#define kCCKeyboardReturnTypeSend kKeyboardReturnTypeSend -#define kCCKeyboardReturnTypeSearch kKeyboardReturnTypeSearch -#define kCCKeyboardReturnTypeGo kKeyboardReturnTypeGo -#define kCCEditBoxInputModeAny kEditBoxInputModeAny -#define kCCEditBoxInputModeEmailAddr kEditBoxInputModeEmailAddr -#define kCCEditBoxInputModeNumeric kEditBoxInputModeNumeric -#define kCCEditBoxInputModePhoneNumber kEditBoxInputModePhoneNumber -#define kCCEditBoxInputModeUrl kEditBoxInputModeUrl -#define kCCEditBoxInputModeDecimal kEditBoxInputModeDecimal -#define kCCEditBoxInputModeSingleLine kEditBoxInputModeSingleLine +CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDefault; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDone; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSend; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSearch; +CC_DEPRECATED_ATTRIBUTE extern const EditBox::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::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 - CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDown; CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragInside; CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragOutside; diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index 5353aebb0b..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) @@ -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 4d1151a137..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); @@ -362,9 +359,9 @@ 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..02728a7fd4 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::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..be95184355 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -40,8 +40,8 @@ EditBoxImplWin::EditBoxImplWin(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) @@ -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; } 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/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index 51168f33bd..d7c8b43cbf 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -64,7 +64,7 @@ EditBoxTest::EditBoxTest() _editPassword->setPlaceHolder("Password:"); _editPassword->setMaxLength(6); _editPassword->setInputFlag(kEditBoxInputFlagPassword); - _editPassword->setInputMode(kEditBoxInputModeSingleLine); + _editPassword->setInputMode(EditBox::InputMode::SINGLE_LINE); _editPassword->setDelegate(this); addChild(_editPassword); 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/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 8fb5b810c5..aa7b94103e 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -b719069e8b815e75ee76fa6f7030a04aa9b85ed9 \ No newline at end of file +fca740660ab4437f598bbf3c6db8841bd82ca4e8 \ No newline at end of file From 3cb40b36e4a4c9c69dc58862bfd36ac03be35031 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 26 Jul 2013 18:07:40 +0800 Subject: [PATCH 08/12] issue #2430:fix some errors --- cocos2dx/platform/CCImage.h | 4 ++-- cocos2dx/platform/linux/CCImage.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 2 +- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 2 +- .../Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 94a275c9c2..81eb450db1 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -73,9 +73,9 @@ public: TOP = 0x13, ///< Horizontal center and vertical top. TOP_RIGHT = 0x12, ///< Horizontal right and vertical top. RIGHT = 0x32, ///< Horizontal right and vertical center. - BOTTOEM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. + BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. BOTTOM = 0x23, ///< Horizontal center and vertical bottom. - BOTTOEM_LEFT = 0x21, ///< Horizontal left 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. }; diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 550ca50f08..b88f95cfb6 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -242,7 +242,7 @@ public: */ int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; - if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) { + if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; } else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index ae56f36a93..b80433d8c3 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -474,7 +474,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment) { eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::BOTTOM - : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOEM_LEFT : Image::TextAlign::BOTTOEM_RIGHT; + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOM_LEFT : Image::TextAlign::BOTTOM_RIGHT; } else { diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index be95184355..5a9a9eb2d7 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -42,7 +42,7 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) , _labelPlaceHolder(NULL) , _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) , _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) -, _keyboardReturnType(kKeyboardReturnTypeDefault) +, _keyboardReturnType(EditBox::EditBox::KeyboardReturnType::DEFAULT) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index d7c8b43cbf..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,7 +63,7 @@ EditBoxTest::EditBoxTest() _editPassword->setFontColor(Color3B::GREEN); _editPassword->setPlaceHolder("Password:"); _editPassword->setMaxLength(6); - _editPassword->setInputFlag(kEditBoxInputFlagPassword); + _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); From 2bfccb4a4395890bfc2fd2e26e844d754a49423b Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 26 Jul 2013 21:36:32 +0800 Subject: [PATCH 09/12] A typo fix: EditBox::EditBox::KeyboardReturnType --> EditBox::KeyboardReturnType --- extensions/CCDeprecated-ext.cpp | 10 +++++----- extensions/CCDeprecated-ext.h | 12 ++++++------ extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp | 2 +- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/extensions/CCDeprecated-ext.cpp b/extensions/CCDeprecated-ext.cpp index 6c3c4be2d3..3977aa3f07 100644 --- a/extensions/CCDeprecated-ext.cpp +++ b/extensions/CCDeprecated-ext.cpp @@ -41,11 +41,11 @@ const Control::State CCControlStateHighlighted = Control::State::HIGH_LIGHTED; const Control::State CCControlStateDisabled = Control::State::DISABLED; const Control::State CCControlStateSelected = Control::State::SELECTED; -const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDefault = EditBox::EditBox::KeyboardReturnType::DEFAULT; -const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDone = EditBox::EditBox::KeyboardReturnType::DONE; -const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSend = EditBox::EditBox::KeyboardReturnType::SEND; -const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSearch = EditBox::EditBox::KeyboardReturnType::SEARCH; -const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeGo = EditBox::EditBox::KeyboardReturnType::GO; +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; diff --git a/extensions/CCDeprecated-ext.h b/extensions/CCDeprecated-ext.h index 245cb1b80d..afbb11bbad 100644 --- a/extensions/CCDeprecated-ext.h +++ b/extensions/CCDeprecated-ext.h @@ -132,11 +132,11 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType; #define kCCScrollViewDirectionVertical kScrollViewDirectionVertical #define kCCScrollViewDirectionBoth kScrollViewDirectionBoth -CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDefault; -CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeDone; -CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSend; -CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeSearch; -CC_DEPRECATED_ATTRIBUTE extern const EditBox::EditBox::KeyboardReturnType kKeyboardReturnTypeGo; +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; @@ -152,7 +152,7 @@ CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitial CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsSentence; CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsAllCharacters; -CC_DEPRECATED_ATTRIBUTE typedef EditBox::EditBox::KeyboardReturnType KeyboardReturnType; +CC_DEPRECATED_ATTRIBUTE typedef EditBox::KeyboardReturnType KeyboardReturnType; CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputMode EditBoxInputMode; CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputFlag EditBoxInputFlag; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index 02728a7fd4..8afb9b6e0a 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -45,7 +45,7 @@ EditBoxImplAndroid::EditBoxImplAndroid(EditBox* pEditText) , _labelPlaceHolder(NULL) , _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) , _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) -, _keyboardReturnType(EditBox::EditBox::KeyboardReturnType::DEFAULT) +, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index 5a9a9eb2d7..1bc8020266 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -42,7 +42,7 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText) , _labelPlaceHolder(NULL) , _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) , _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) -, _keyboardReturnType(EditBox::EditBox::KeyboardReturnType::DEFAULT) +, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) , _colText(Color3B::WHITE) , _colPlaceHolder(Color3B::GRAY) , _maxLength(-1) From 19d9c08c79df4b370b56f17eacfbb6fdd3fed640 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 26 Jul 2013 22:15:30 +0800 Subject: [PATCH 10/12] issue #2430: Fixing compilation errors for lua and js bindings. --- scripting/javascript/bindings/jsb_websocket.cpp | 8 ++++---- .../lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp | 4 ++-- scripting/lua/cocos2dx_support/Lua_web_socket.cpp | 10 +++++----- tools/tolua++/basic.lua | 3 ++- 5 files changed, 14 insertions(+), 13 deletions(-) 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 2d31c6f2f2..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)); - Control::EventType controlevent = (Control::EventType)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); - Control::EventType controlevent = (Control::EventType)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/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)") From 58a3560bcae9f3ceaef0fbab47c81b8f4b396bea Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 26 Jul 2013 22:55:41 +0800 Subject: [PATCH 11/12] More enum class: ScrollView::Direction, TableView::VerticalFillOrder --- cocos2dx/touch_dispatcher/CCTouchDispatcher.h | 9 ---- extensions/CCBReader/CCScrollViewLoader.cpp | 2 +- extensions/CCDeprecated-ext.cpp | 10 +++++ extensions/CCDeprecated-ext.h | 20 +++++---- extensions/GUI/CCScrollView/CCScrollView.cpp | 16 +++---- extensions/GUI/CCScrollView/CCScrollView.h | 20 ++++----- extensions/GUI/CCScrollView/CCTableView.cpp | 42 +++++++++---------- extensions/GUI/CCScrollView/CCTableView.h | 19 +++++---- .../TableViewTest/TableViewTestScene.cpp | 6 +-- .../lua/cocos2dx_support/LuaScrollView.cpp | 12 +++--- 10 files changed, 81 insertions(+), 75 deletions(-) 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/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 index 3977aa3f07..efa1e560b8 100644 --- a/extensions/CCDeprecated-ext.cpp +++ b/extensions/CCDeprecated-ext.cpp @@ -61,4 +61,14 @@ const EditBox::InputFlag kEditBoxInputFlagInitialCapsWord = EditBox::InputFlag:: 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 afbb11bbad..f5da5f3376 100644 --- a/extensions/CCDeprecated-ext.h +++ b/extensions/CCDeprecated-ext.h @@ -117,20 +117,24 @@ 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 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 +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; + + +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; 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/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/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 From 387ae822b18735608ece2bacf406ebca43cab571 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 26 Jul 2013 22:56:37 +0800 Subject: [PATCH 12/12] issue #2430: Compilation error fix for CCEditBox/CCEditBoxImplWin.cpp --- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index 1bc8020266..1126e4e8b1 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -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++)