mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3280 from dumganhar/minggo-iss2430-modify_enum
Merge PR https://github.com/cocos2d/cocos2d-x/pull/3270, move enum into class and using enum class
This commit is contained in:
commit
04077e312e
|
@ -1 +1 @@
|
||||||
a30cd2dad1df734bd988309d3b344ff946601cb4
|
b803d542a8eac86722010a38dd782612565198b7
|
|
@ -67,18 +67,18 @@ public:
|
||||||
UNKOWN
|
UNKOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
enum class TextAlign
|
||||||
{
|
{
|
||||||
kAlignCenter = 0x33, ///< Horizontal center and vertical center.
|
CENTER = 0x33, ///< Horizontal center and vertical center.
|
||||||
kAlignTop = 0x13, ///< Horizontal center and vertical top.
|
TOP = 0x13, ///< Horizontal center and vertical top.
|
||||||
kAlignTopRight = 0x12, ///< Horizontal right and vertical top.
|
TOP_RIGHT = 0x12, ///< Horizontal right and vertical top.
|
||||||
kAlignRight = 0x32, ///< Horizontal right and vertical center.
|
RIGHT = 0x32, ///< Horizontal right and vertical center.
|
||||||
kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom.
|
BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom.
|
||||||
kAlignBottom = 0x23, ///< Horizontal center and vertical bottom.
|
BOTTOM = 0x23, ///< Horizontal center and vertical bottom.
|
||||||
kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom.
|
BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom.
|
||||||
kAlignLeft = 0x31, ///< Horizontal left and vertical center.
|
LEFT = 0x31, ///< Horizontal left and vertical center.
|
||||||
kAlignTopLeft = 0x11, ///< Horizontal left and vertical top.
|
TOP_LEFT = 0x11, ///< Horizontal left and vertical top.
|
||||||
}ETextAlign;
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load the image from the specified path.
|
@brief Load the image from the specified path.
|
||||||
|
@ -120,7 +120,7 @@ public:
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth = 0,
|
int nWidth = 0,
|
||||||
int nHeight = 0,
|
int nHeight = 0,
|
||||||
ETextAlign eAlignMask = kAlignCenter,
|
TextAlign eAlignMask = TextAlign::CENTER,
|
||||||
const char * pFontName = 0,
|
const char * pFontName = 0,
|
||||||
int nSize = 0);
|
int nSize = 0);
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public:
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth = 0,
|
int nWidth = 0,
|
||||||
int nHeight = 0,
|
int nHeight = 0,
|
||||||
ETextAlign eAlignMask = kAlignCenter,
|
TextAlign eAlignMask = TextAlign::CENTER,
|
||||||
const char * pFontName = 0,
|
const char * pFontName = 0,
|
||||||
int nSize = 0,
|
int nSize = 0,
|
||||||
float textTintR = 1,
|
float textTintR = 1,
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
bool getBitmapFromJavaShadowStroke( const char *text,
|
bool getBitmapFromJavaShadowStroke( const char *text,
|
||||||
int nWidth,
|
int nWidth,
|
||||||
int nHeight,
|
int nHeight,
|
||||||
Image::ETextAlign eAlignMask,
|
Image::TextAlign eAlignMask,
|
||||||
const char * pFontName,
|
const char * pFontName,
|
||||||
float fontSize,
|
float fontSize,
|
||||||
float textTintR = 1.0,
|
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 );
|
return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize );
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth/* = 0*/,
|
int nWidth/* = 0*/,
|
||||||
int nHeight/* = 0*/,
|
int nHeight/* = 0*/,
|
||||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
const char * pFontName/* = nil*/,
|
const char * pFontName/* = nil*/,
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +182,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth ,
|
int nWidth ,
|
||||||
int nHeight ,
|
int nHeight ,
|
||||||
ETextAlign eAlignMask ,
|
TextAlign eAlignMask ,
|
||||||
const char * pFontName ,
|
const char * pFontName ,
|
||||||
int nSize ,
|
int nSize ,
|
||||||
float textTintR,
|
float textTintR,
|
||||||
|
|
|
@ -172,7 +172,7 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
|
||||||
#define ALIGN_CENTER 3
|
#define ALIGN_CENTER 3
|
||||||
#define ALIGN_BOTTOM 2
|
#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;
|
bool bRet = false;
|
||||||
do
|
do
|
||||||
|
@ -221,7 +221,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
|
||||||
if (constrainSize.height > dim.height)
|
if (constrainSize.height > dim.height)
|
||||||
{
|
{
|
||||||
// vertical alignment
|
// vertical alignment
|
||||||
unsigned int vAlignment = (eAlign >> 4) & 0x0F;
|
unsigned int vAlignment = ((int)eAlign >> 4) & 0x0F;
|
||||||
if (vAlignment == ALIGN_TOP)
|
if (vAlignment == ALIGN_TOP)
|
||||||
{
|
{
|
||||||
startH = 0;
|
startH = 0;
|
||||||
|
@ -297,7 +297,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
|
||||||
UIGraphicsPushContext(context);
|
UIGraphicsPushContext(context);
|
||||||
|
|
||||||
// measure text size with specified font and determine the rectangle to draw text in
|
// measure text size with specified font and determine the rectangle to draw text in
|
||||||
unsigned uHoriFlag = eAlign & 0x0f;
|
unsigned uHoriFlag = (int)eAlign & 0x0f;
|
||||||
UITextAlignment align = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight
|
UITextAlignment align = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight
|
||||||
: (3 == uHoriFlag) ? UITextAlignmentCenter
|
: (3 == uHoriFlag) ? UITextAlignmentCenter
|
||||||
: UITextAlignmentLeft);
|
: UITextAlignmentLeft);
|
||||||
|
@ -543,7 +543,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth /* = 0 */,
|
int nWidth /* = 0 */,
|
||||||
int nHeight /* = 0 */,
|
int nHeight /* = 0 */,
|
||||||
ETextAlign eAlignMask /* = kAlignCenter */,
|
TextAlign eAlignMask /* = kAlignCenter */,
|
||||||
const char * pFontName /* = nil */,
|
const char * pFontName /* = nil */,
|
||||||
int nSize /* = 0 */)
|
int nSize /* = 0 */)
|
||||||
{
|
{
|
||||||
|
@ -554,7 +554,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth ,
|
int nWidth ,
|
||||||
int nHeight ,
|
int nHeight ,
|
||||||
ETextAlign eAlignMask ,
|
TextAlign eAlignMask ,
|
||||||
const char * pFontName ,
|
const char * pFontName ,
|
||||||
int nSize ,
|
int nSize ,
|
||||||
float textTintR,
|
float textTintR,
|
||||||
|
|
|
@ -240,11 +240,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* compute the start pos of every line
|
* 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;
|
int lineWidth = textLines.at(line).lineWidth;
|
||||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
||||||
return (iMaxLineWidth - lineWidth) / 2;
|
return (iMaxLineWidth - lineWidth) / 2;
|
||||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
||||||
return (iMaxLineWidth - lineWidth);
|
return (iMaxLineWidth - lineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,12 +252,12 @@ public:
|
||||||
return 0;
|
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);
|
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) {
|
||||||
//vertical center
|
//vertical center
|
||||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) {
|
||||||
//vertical bottom
|
//vertical bottom
|
||||||
return borderHeight - txtHeight + baseLinePos;
|
return borderHeight - txtHeight + baseLinePos;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ public:
|
||||||
return family_name;
|
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) {
|
if (libError) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth/* = 0*/,
|
int nWidth/* = 0*/,
|
||||||
int nHeight/* = 0*/,
|
int nHeight/* = 0*/,
|
||||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
const char * pFontName/* = nil*/,
|
const char * pFontName/* = nil*/,
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,7 +308,7 @@ static bool _isValidFontName(const char *fontName)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor)
|
static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
||||||
|
@ -344,8 +344,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
|
||||||
|
|
||||||
|
|
||||||
// alignment, linebreak
|
// alignment, linebreak
|
||||||
unsigned uHoriFlag = eAlign & 0x0f;
|
unsigned uHoriFlag = (int)eAlign & 0x0f;
|
||||||
unsigned uVertFlag = (eAlign >> 4) & 0x0f;
|
unsigned uVertFlag = ((int)eAlign >> 4) & 0x0f;
|
||||||
NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment
|
NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment
|
||||||
: (3 == uHoriFlag) ? NSCenterTextAlignment
|
: (3 == uHoriFlag) ? NSCenterTextAlignment
|
||||||
: NSLeftTextAlignment;
|
: NSLeftTextAlignment;
|
||||||
|
@ -859,7 +859,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth,
|
int nWidth,
|
||||||
int nHeight,
|
int nHeight,
|
||||||
ETextAlign eAlignMask,
|
TextAlign eAlignMask,
|
||||||
const char * pFontName,
|
const char * pFontName,
|
||||||
int nSize)
|
int nSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,7 +214,7 @@ public:
|
||||||
* while -1 means fail
|
* 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 iLineIndex)
|
||||||
{
|
{
|
||||||
int iRet;
|
int iRet;
|
||||||
|
@ -223,11 +223,11 @@ public:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eAlignMask == Image::kAlignCenter) {
|
if (eAlignMask == Image::TextAlign::CENTER) {
|
||||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
|
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
|
||||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||||
|
|
||||||
} else if (eAlignMask == Image::kAlignRight) {
|
} else if (eAlignMask == Image::TextAlign::RIGHT) {
|
||||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
|
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
|
||||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||||
} else {
|
} else {
|
||||||
|
@ -237,17 +237,17 @@ public:
|
||||||
return iRet;
|
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;
|
int iRet = 0;
|
||||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft ||
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT ||
|
||||||
eAlignMask == Image::kAlignRight ) {
|
eAlignMask == Image::TextAlign::RIGHT ) {
|
||||||
//vertical center
|
//vertical center
|
||||||
iRet = (borderHeight - txtHeight)/2;
|
iRet = (borderHeight - txtHeight)/2;
|
||||||
|
|
||||||
} else if (eAlignMask == Image::kAlignBottomRight ||
|
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT ||
|
||||||
eAlignMask == Image::kAlignBottom ||
|
eAlignMask == Image::TextAlign::BOTTOM ||
|
||||||
eAlignMask == Image::kAlignBottomLeft ) {
|
eAlignMask == Image::TextAlign::BOTTOM_LEFT ) {
|
||||||
//vertical bottom
|
//vertical bottom
|
||||||
iRet = borderHeight - txtHeight;
|
iRet = borderHeight - txtHeight;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ public:
|
||||||
return true;
|
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();
|
size_t lines = vLines.size();
|
||||||
for (size_t i = 0; i < lines; i++)
|
for (size_t i = 0; i < lines; i++)
|
||||||
|
@ -328,7 +328,7 @@ public:
|
||||||
return true;
|
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;
|
FT_Error iError;
|
||||||
if (libError)
|
if (libError)
|
||||||
|
|
|
@ -240,11 +240,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* compute the start pos of every line
|
* 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;
|
int lineWidth = textLines.at(line).lineWidth;
|
||||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
||||||
return (iMaxLineWidth - lineWidth) / 2;
|
return (iMaxLineWidth - lineWidth) / 2;
|
||||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TO_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
||||||
return (iMaxLineWidth - lineWidth);
|
return (iMaxLineWidth - lineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,12 +252,12 @@ public:
|
||||||
return 0;
|
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);
|
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) {
|
||||||
//vertical center
|
//vertical center
|
||||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) {
|
||||||
//vertical bottom
|
//vertical bottom
|
||||||
return borderHeight - txtHeight + baseLinePos;
|
return borderHeight - txtHeight + baseLinePos;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ public:
|
||||||
return family_name;
|
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) {
|
if (libError) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drawText(const char * pszText, SIZE& tSize, Image::ETextAlign eAlign)
|
int drawText(const char * pszText, SIZE& tSize, Image::TextAlign eAlign)
|
||||||
{
|
{
|
||||||
int nRet = 0;
|
int nRet = 0;
|
||||||
wchar_t * pwszBuffer = 0;
|
wchar_t * pwszBuffer = 0;
|
||||||
|
@ -249,8 +249,8 @@ public:
|
||||||
CC_BREAK_IF(! pszText);
|
CC_BREAK_IF(! pszText);
|
||||||
|
|
||||||
DWORD dwFmt = DT_WORDBREAK;
|
DWORD dwFmt = DT_WORDBREAK;
|
||||||
DWORD dwHoriFlag = eAlign & 0x0f;
|
DWORD dwHoriFlag = (int)eAlign & 0x0f;
|
||||||
DWORD dwVertFlag = (eAlign & 0xf0) >> 4;
|
DWORD dwVertFlag = ((int)eAlign & 0xf0) >> 4;
|
||||||
|
|
||||||
switch (dwHoriFlag)
|
switch (dwHoriFlag)
|
||||||
{
|
{
|
||||||
|
@ -370,7 +370,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth/* = 0*/,
|
int nWidth/* = 0*/,
|
||||||
int nHeight/* = 0*/,
|
int nHeight/* = 0*/,
|
||||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
const char * pFontName/* = nil*/,
|
const char * pFontName/* = nil*/,
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
|
|
|
@ -459,22 +459,22 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
Image::ETextAlign eAlign;
|
Image::TextAlign eAlign;
|
||||||
|
|
||||||
if (Label::VAlignment::TOP == textDefinition._vertAlignment)
|
if (Label::VAlignment::TOP == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignTop
|
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::TOP
|
||||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::TOP_LEFT : Image::TextAlign::TOP_RIGHT;
|
||||||
}
|
}
|
||||||
else if (Label::VAlignment::CENTER == textDefinition._vertAlignment)
|
else if (Label::VAlignment::CENTER == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::CENTER
|
||||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::LEFT : Image::TextAlign::RIGHT;
|
||||||
}
|
}
|
||||||
else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment)
|
else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::BOTTOM
|
||||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOM_LEFT : Image::TextAlign::BOTTOM_RIGHT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 {
|
enum {
|
||||||
CCTOUCHBEGAN,
|
CCTOUCHBEGAN,
|
||||||
|
|
|
@ -102,7 +102,8 @@ spine/SlotData.cpp \
|
||||||
spine/extension.cpp \
|
spine/extension.cpp \
|
||||||
spine/CCSkeletonAnimation.cpp \
|
spine/CCSkeletonAnimation.cpp \
|
||||||
spine/CCSkeleton.cpp \
|
spine/CCSkeleton.cpp \
|
||||||
spine/spine-cocos2dx.cpp
|
spine/spine-cocos2dx.cpp \
|
||||||
|
CCDeprecated-ext.cpp
|
||||||
|
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
|
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
|
||||||
|
|
|
@ -134,7 +134,7 @@ bool AssetsManager::checkUpdate()
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
sendErrorMessage(kNetwork);
|
sendErrorMessage(ErrorCode::NETWORK);
|
||||||
CCLOG("can not get version file content, error code is %d", res);
|
CCLOG("can not get version file content, error code is %d", res);
|
||||||
curl_easy_cleanup(_curl);
|
curl_easy_cleanup(_curl);
|
||||||
return false;
|
return false;
|
||||||
|
@ -143,7 +143,7 @@ bool AssetsManager::checkUpdate()
|
||||||
string recordedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION);
|
string recordedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION);
|
||||||
if (recordedVersion == _version)
|
if (recordedVersion == _version)
|
||||||
{
|
{
|
||||||
sendErrorMessage(kNoNewVersion);
|
sendErrorMessage(ErrorCode::NO_NEW_VERSION);
|
||||||
CCLOG("there is not new version");
|
CCLOG("there is not new version");
|
||||||
// Set resource search path.
|
// Set resource search path.
|
||||||
setSearchPath();
|
setSearchPath();
|
||||||
|
@ -173,7 +173,7 @@ void AssetsManager::downloadAndUncompress()
|
||||||
// Uncompress zip file.
|
// Uncompress zip file.
|
||||||
if (! uncompress())
|
if (! uncompress())
|
||||||
{
|
{
|
||||||
sendErrorMessage(AssetsManager::kUncompress);
|
sendErrorMessage(ErrorCode::UNCOMPRESS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ bool AssetsManager::downLoad()
|
||||||
FILE *fp = fopen(outFileName.c_str(), "wb");
|
FILE *fp = fopen(outFileName.c_str(), "wb");
|
||||||
if (! fp)
|
if (! fp)
|
||||||
{
|
{
|
||||||
sendErrorMessage(kCreateFile);
|
sendErrorMessage(ErrorCode::CREATE_FILE);
|
||||||
CCLOG("can not create file %s", outFileName.c_str());
|
CCLOG("can not create file %s", outFileName.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ bool AssetsManager::downLoad()
|
||||||
curl_easy_cleanup(_curl);
|
curl_easy_cleanup(_curl);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
sendErrorMessage(kNetwork);
|
sendErrorMessage(ErrorCode::NETWORK);
|
||||||
CCLOG("error when download package");
|
CCLOG("error when download package");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,19 +44,19 @@ class AssetsManagerDelegateProtocol;
|
||||||
class AssetsManager
|
class AssetsManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ErrorCode
|
enum class ErrorCode
|
||||||
{
|
{
|
||||||
// Error caused by creating a file to store downloaded data
|
// Error caused by creating a file to store downloaded data
|
||||||
kCreateFile,
|
CREATE_FILE,
|
||||||
/** Error caused by network
|
/** Error caused by network
|
||||||
-- network unavaivable
|
-- network unavaivable
|
||||||
-- timeout
|
-- timeout
|
||||||
-- ...
|
-- ...
|
||||||
*/
|
*/
|
||||||
kNetwork,
|
NETWORK,
|
||||||
/** There is not a new version
|
/** There is not a new version
|
||||||
*/
|
*/
|
||||||
kNoNewVersion,
|
NO_NEW_VERSION,
|
||||||
/** Error caused in uncompressing stage
|
/** Error caused in uncompressing stage
|
||||||
-- can not open zip file
|
-- can not open zip file
|
||||||
-- can not read file global information
|
-- can not read file global information
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
-- can not create a directory
|
-- can not create a directory
|
||||||
-- ...
|
-- ...
|
||||||
*/
|
*/
|
||||||
kUncompress,
|
UNCOMPRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* @brief Creates a AssetsManager with new package url, version code url and storage path.
|
/* @brief Creates a AssetsManager with new package url, version code url and storage path.
|
||||||
|
|
|
@ -25,7 +25,7 @@ class CCBSelectorResolver {
|
||||||
virtual ~CCBSelectorResolver() {};
|
virtual ~CCBSelectorResolver() {};
|
||||||
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0;
|
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||||
virtual SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; };
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) {
|
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) {
|
} 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) {
|
} 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 {
|
} else {
|
||||||
ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader);
|
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) {
|
void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) {
|
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) {
|
} 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) {
|
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) {
|
||||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateDisabled);
|
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::DISABLED);
|
||||||
} else {
|
} else {
|
||||||
ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
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) {
|
void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) {
|
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) {
|
} 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) {
|
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) {
|
||||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateDisabled);
|
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::DISABLED);
|
||||||
} else {
|
} else {
|
||||||
ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
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) {
|
void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
|
||||||
if(pSpriteFrame != NULL) {
|
if(pSpriteFrame != NULL) {
|
||||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateNormal);
|
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL);
|
||||||
}
|
}
|
||||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
|
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
|
||||||
if(pSpriteFrame != NULL) {
|
if(pSpriteFrame != NULL) {
|
||||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateHighlighted);
|
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED);
|
||||||
}
|
}
|
||||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
|
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
|
||||||
if(pSpriteFrame != NULL) {
|
if(pSpriteFrame != NULL) {
|
||||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateDisabled);
|
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, pCCBReader);
|
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) {
|
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
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) {
|
} 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) {
|
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) {
|
||||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateDisabled);
|
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::DISABLED);
|
||||||
} else {
|
} else {
|
||||||
ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, pCCBReader);
|
ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, pCCBReader);
|
||||||
}
|
}
|
||||||
|
|
|
@ -811,7 +811,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
|
||||||
|
|
||||||
if(target != NULL) {
|
if(target != NULL) {
|
||||||
if(selectorName.length() > 0) {
|
if(selectorName.length() > 0) {
|
||||||
SEL_CCControlHandler selControlHandler = 0;
|
Control::Handler selControlHandler = 0;
|
||||||
|
|
||||||
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
||||||
|
|
||||||
|
@ -832,7 +832,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
|
||||||
blockControlData->mSELControlHandler = selControlHandler;
|
blockControlData->mSELControlHandler = selControlHandler;
|
||||||
|
|
||||||
blockControlData->mTarget = target;
|
blockControlData->mTarget = target;
|
||||||
blockControlData->mControlEvents = controlEvents;
|
blockControlData->mControlEvents = (Control::EventType)controlEvents;
|
||||||
|
|
||||||
return blockControlData;
|
return blockControlData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "CCBReader.h"
|
#include "CCBReader.h"
|
||||||
#include "CCBValue.h"
|
#include "CCBValue.h"
|
||||||
|
#include "../GUI/CCControlExtension/CCControl.h"
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
|
@ -35,9 +36,9 @@ struct BlockData {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlockControlData {
|
struct BlockControlData {
|
||||||
SEL_CCControlHandler mSELControlHandler;
|
Control::Handler mSELControlHandler;
|
||||||
Object * mTarget;
|
Object * mTarget;
|
||||||
int mControlEvents;
|
Control::EventType mControlEvents;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Forward declaration. */
|
/* Forward declaration. */
|
||||||
|
|
|
@ -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) {
|
void ScrollViewLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_DIRECTION) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_DIRECTION) == 0) {
|
||||||
((ScrollView *)pNode)->setDirection(ScrollViewDirection(pIntegerLabeled));
|
((ScrollView *)pNode)->setDirection(ScrollView::Direction(pIntegerLabeled));
|
||||||
} else {
|
} else {
|
||||||
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cocos-ext.h"
|
||||||
|
|
||||||
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
|
const Control::EventType CCControlEventTouchDown = Control::EventType::TOUCH_DOWN;
|
||||||
|
const Control::EventType CCControlEventTouchDragInside = Control::EventType::DRAG_INSIDE;
|
||||||
|
const Control::EventType CCControlEventTouchDragOutside = Control::EventType::DRAG_OUTSIDE;
|
||||||
|
const Control::EventType CCControlEventTouchDragEnter = Control::EventType::DRAG_ENTER;
|
||||||
|
const Control::EventType CCControlEventTouchDragExit = Control::EventType::DRAG_EXIT;
|
||||||
|
const Control::EventType CCControlEventTouchUpInside = Control::EventType::TOUCH_UP_INSIDE;
|
||||||
|
const Control::EventType CCControlEventTouchUpOutside = Control::EventType::TOUCH_UP_OUTSIDE;
|
||||||
|
const Control::EventType CCControlEventTouchCancel = Control::EventType::TOUCH_CANCEL;
|
||||||
|
const Control::EventType CCControlEventValueChanged = Control::EventType::VALUE_CHANGED;
|
||||||
|
|
||||||
|
const Control::State CCControlStateNormal = Control::State::NORMAL;
|
||||||
|
const Control::State CCControlStateHighlighted = Control::State::HIGH_LIGHTED;
|
||||||
|
const Control::State CCControlStateDisabled = Control::State::DISABLED;
|
||||||
|
const Control::State CCControlStateSelected = Control::State::SELECTED;
|
||||||
|
|
||||||
|
const EditBox::KeyboardReturnType kKeyboardReturnTypeDefault = EditBox::KeyboardReturnType::DEFAULT;
|
||||||
|
const EditBox::KeyboardReturnType kKeyboardReturnTypeDone = EditBox::KeyboardReturnType::DONE;
|
||||||
|
const EditBox::KeyboardReturnType kKeyboardReturnTypeSend = EditBox::KeyboardReturnType::SEND;
|
||||||
|
const EditBox::KeyboardReturnType kKeyboardReturnTypeSearch = EditBox::KeyboardReturnType::SEARCH;
|
||||||
|
const EditBox::KeyboardReturnType kKeyboardReturnTypeGo = EditBox::KeyboardReturnType::GO;
|
||||||
|
|
||||||
|
const EditBox::InputMode kEditBoxInputModeAny = EditBox::InputMode::ANY;
|
||||||
|
const EditBox::InputMode kEditBoxInputModeEmailAddr = EditBox::InputMode::EMAIL_ADDRESS;
|
||||||
|
const EditBox::InputMode kEditBoxInputModeNumeric = EditBox::InputMode::NUMERIC;
|
||||||
|
const EditBox::InputMode kEditBoxInputModePhoneNumber = EditBox::InputMode::PHONE_NUMBER;
|
||||||
|
const EditBox::InputMode kEditBoxInputModeUrl = EditBox::InputMode::URL;
|
||||||
|
const EditBox::InputMode kEditBoxInputModeDecimal = EditBox::InputMode::DECIMAL;
|
||||||
|
const EditBox::InputMode kEditBoxInputModeSingleLine = EditBox::InputMode::SINGLE_LINE;
|
||||||
|
|
||||||
|
const EditBox::InputFlag kEditBoxInputFlagPassword = EditBox::InputFlag::PASSWORD;
|
||||||
|
const EditBox::InputFlag kEditBoxInputFlagSensitive = EditBox::InputFlag::SENSITIVE;
|
||||||
|
const EditBox::InputFlag kEditBoxInputFlagInitialCapsWord = EditBox::InputFlag::INITIAL_CAPS_WORD;
|
||||||
|
const EditBox::InputFlag kEditBoxInputFlagInitialCapsSentence = EditBox::InputFlag::INITIAL_CAPS_SENTENCE;
|
||||||
|
const EditBox::InputFlag kEditBoxInputFlagInitialCapsAllCharacters = EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS;
|
||||||
|
|
||||||
|
|
||||||
|
const ScrollView::Direction kCCScrollViewDirectionNone = ScrollView::Direction::NONE;
|
||||||
|
const ScrollView::Direction kCCScrollViewDirectionHorizontal = ScrollView::Direction::HORIZONTAL;
|
||||||
|
const ScrollView::Direction kCCScrollViewDirectionVertical = ScrollView::Direction::VERTICAL;
|
||||||
|
const ScrollView::Direction kCCScrollViewDirectionBoth = ScrollView::Direction::BOTH;
|
||||||
|
|
||||||
|
const TableView::VerticalFillOrder kCCTableViewFillTopDown = TableView::VerticalFillOrder::TOP_DOWN;
|
||||||
|
const TableView::VerticalFillOrder kCCTableViewFillBottomUp = TableView::VerticalFillOrder::BOTTOM_UP;
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_EXT_END
|
|
@ -117,54 +117,72 @@ CC_DEPRECATED_ATTRIBUTE typedef AttachmentTimeline CCAttachmentTimeline;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef AtlasAttachmentLoader CCAtlasAttachmentLoader;
|
CC_DEPRECATED_ATTRIBUTE typedef AtlasAttachmentLoader CCAtlasAttachmentLoader;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef VertexIndex CCVertexIndex;
|
CC_DEPRECATED_ATTRIBUTE typedef VertexIndex CCVertexIndex;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef RegionAttachment CCRegionAttachment;
|
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 ControlStepperPart CCControlStepperPart;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef ControlEvent CCControlEvent;
|
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef ControlState CCControlState;
|
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMap CCNodeLoaderMap;
|
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMap CCNodeLoaderMap;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMapEntry CCNodeLoaderMapEntry;
|
CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMapEntry CCNodeLoaderMapEntry;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef EventRegistry CCEventRegistry;
|
CC_DEPRECATED_ATTRIBUTE typedef EventRegistry CCEventRegistry;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType;
|
CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType;
|
||||||
|
|
||||||
#define kCCTableViewFillTopDown kTableViewFillTopDown
|
CC_DEPRECATED_ATTRIBUTE typedef ScrollView::Direction CCScrollViewDirection;
|
||||||
#define kCCTableViewFillBottomUp kTableViewFillBottomUp
|
CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionNone;
|
||||||
#define kCCScrollViewDirectionNone kScrollViewDirectionNone
|
CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionHorizontal;
|
||||||
#define kCCScrollViewDirectionHorizontal kScrollViewDirectionHorizontal
|
CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionVertical;
|
||||||
#define kCCScrollViewDirectionVertical kScrollViewDirectionVertical
|
CC_DEPRECATED_ATTRIBUTE extern const ScrollView::Direction kCCScrollViewDirectionBoth;
|
||||||
#define kCCScrollViewDirectionBoth kScrollViewDirectionBoth
|
|
||||||
#define kCCKeyboardReturnTypeDefault kKeyboardReturnTypeDefault
|
|
||||||
#define kCCKeyboardReturnTypeDone kKeyboardReturnTypeDone
|
|
||||||
#define kCCKeyboardReturnTypeSend kKeyboardReturnTypeSend
|
|
||||||
#define kCCKeyboardReturnTypeSearch kKeyboardReturnTypeSearch
|
|
||||||
#define kCCKeyboardReturnTypeGo kKeyboardReturnTypeGo
|
|
||||||
|
|
||||||
#define kCCEditBoxInputModeAny kEditBoxInputModeAny
|
|
||||||
#define kCCEditBoxInputModeEmailAddr kEditBoxInputModeEmailAddr
|
CC_DEPRECATED_ATTRIBUTE typedef TableView::VerticalFillOrder CCTableViewVerticalFillOrder;
|
||||||
#define kCCEditBoxInputModeNumeric kEditBoxInputModeNumeric
|
CC_DEPRECATED_ATTRIBUTE extern const TableView::VerticalFillOrder kCCTableViewFillTopDown;
|
||||||
#define kCCEditBoxInputModePhoneNumber kEditBoxInputModePhoneNumber
|
CC_DEPRECATED_ATTRIBUTE extern const TableView::VerticalFillOrder kCCTableViewFillBottomUp;
|
||||||
#define kCCEditBoxInputModeUrl kEditBoxInputModeUrl
|
|
||||||
#define kCCEditBoxInputModeDecimal kEditBoxInputModeDecimal
|
|
||||||
#define kCCEditBoxInputModeSingleLine kEditBoxInputModeSingleLine
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeDefault;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeDone;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeSend;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeSearch;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::KeyboardReturnType kKeyboardReturnTypeGo;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeAny;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeEmailAddr;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeNumeric;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModePhoneNumber;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeUrl;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeDecimal;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputMode kEditBoxInputModeSingleLine;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagPassword;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagSensitive;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsWord;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsSentence;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const EditBox::InputFlag kEditBoxInputFlagInitialCapsAllCharacters;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef EditBox::KeyboardReturnType KeyboardReturnType;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputMode EditBoxInputMode;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef EditBox::InputFlag EditBoxInputFlag;
|
||||||
|
|
||||||
#define kCCControlStepperPartMinus kControlStepperPartMinus
|
#define kCCControlStepperPartMinus kControlStepperPartMinus
|
||||||
#define kCCControlStepperPartPlus kControlStepperPartPlus
|
#define kCCControlStepperPartPlus kControlStepperPartPlus
|
||||||
#define kCCControlStepperPartNone kControlStepperPartNone
|
#define kCCControlStepperPartNone kControlStepperPartNone
|
||||||
|
|
||||||
#define CCControlEventTouchDown ControlEventTouchDown
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDown;
|
||||||
#define CCControlEventTouchDragInside ControlEventTouchDragInside
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragInside;
|
||||||
#define CCControlEventTouchDragOutside ControlEventTouchDragOutside
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragOutside;
|
||||||
#define CCControlEventTouchDragEnter ControlEventTouchDragEnter
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragEnter;
|
||||||
#define CCControlEventTouchDragExit ControlEventTouchDragExit
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchDragExit;
|
||||||
#define CCControlEventTouchUpInside ControlEventTouchUpInside
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpInside;
|
||||||
#define CCControlEventTouchUpOutside ControlEventTouchUpOutside
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchUpOutside;
|
||||||
#define CCControlEventTouchCancel ControlEventTouchCancel
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventTouchCancel;
|
||||||
#define CCControlEventValueChanged ControlEventValueChanged
|
CC_DEPRECATED_ATTRIBUTE extern const Control::EventType CCControlEventValueChanged;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef Control::EventType CCControlEvent;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateNormal;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateHighlighted;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateDisabled;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE extern const Control::State CCControlStateSelected;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef Control::State CCControlState;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE typedef Control::Handler SEL_CCControlHandler;
|
||||||
|
|
||||||
#define CCControlStateNormal ControlStateNormal
|
|
||||||
#define CCControlStateHighlighted ControlStateHighlighted
|
|
||||||
#define CCControlStateDisabled ControlStateDisabled
|
|
||||||
#define CCControlStateSelected ControlStateSelected
|
|
||||||
|
|
||||||
#define kCCCreateFile kCreateFile
|
#define kCCCreateFile kCreateFile
|
||||||
#define kCCNetwork kNetwork
|
#define kCCNetwork kNetwork
|
||||||
|
|
|
@ -32,12 +32,13 @@
|
||||||
#include "touch_dispatcher/CCTouchDispatcher.h"
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
||||||
#include "menu_nodes/CCMenu.h"
|
#include "menu_nodes/CCMenu.h"
|
||||||
#include "touch_dispatcher/CCTouch.h"
|
#include "touch_dispatcher/CCTouch.h"
|
||||||
|
#include "CCInvocation.h"
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
Control::Control()
|
Control::Control()
|
||||||
: _isOpacityModifyRGB(false)
|
: _isOpacityModifyRGB(false)
|
||||||
, _state(ControlStateNormal)
|
, _state(State::NORMAL)
|
||||||
, _hasVisibleParents(false)
|
, _hasVisibleParents(false)
|
||||||
, _enabled(false)
|
, _enabled(false)
|
||||||
, _selected(false)
|
, _selected(false)
|
||||||
|
@ -69,7 +70,7 @@ bool Control::init()
|
||||||
//this->setTouchEnabled(true);
|
//this->setTouchEnabled(true);
|
||||||
//_isTouchEnabled=true;
|
//_isTouchEnabled=true;
|
||||||
// Initialise instance variables
|
// Initialise instance variables
|
||||||
_state=ControlStateNormal;
|
_state=Control::State::NORMAL;
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
setHighlighted(false);
|
setHighlighted(false);
|
||||||
|
@ -108,17 +109,17 @@ void Control::onExit()
|
||||||
Layer::onExit();
|
Layer::onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::sendActionsForControlEvents(ControlEvent controlEvents)
|
void Control::sendActionsForControlEvents(EventType controlEvents)
|
||||||
{
|
{
|
||||||
// For each control events
|
// For each control events
|
||||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
// If the given controlEvents bitmask contains the curent event
|
// If the given controlEvents bitmask contains the curent event
|
||||||
if ((controlEvents & (1 << i)))
|
if (((int)controlEvents & (1 << i)))
|
||||||
{
|
{
|
||||||
// Call invocations
|
// Call invocations
|
||||||
// <Invocation*>
|
// <Invocation*>
|
||||||
Array* invocationList = this->dispatchListforControlEvent(1<<i);
|
Array* invocationList = this->dispatchListforControlEvent((Control::EventType)(1<<i));
|
||||||
Object* pObj = NULL;
|
Object* pObj = NULL;
|
||||||
CCARRAY_FOREACH(invocationList, pObj)
|
CCARRAY_FOREACH(invocationList, pObj)
|
||||||
{
|
{
|
||||||
|
@ -135,15 +136,15 @@ void Control::sendActionsForControlEvents(ControlEvent controlEvents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Control::addTargetWithActionForControlEvents(Object* target, SEL_CCControlHandler action, ControlEvent controlEvents)
|
void Control::addTargetWithActionForControlEvents(Object* target, Handler action, EventType controlEvents)
|
||||||
{
|
{
|
||||||
// For each control events
|
// For each control events
|
||||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
// If the given controlEvents bitmask contains the curent event
|
// If the given controlEvents bitmask contains the curent event
|
||||||
if ((controlEvents & (1 << i)))
|
if (((int)controlEvents & (1 << i)))
|
||||||
{
|
{
|
||||||
this->addTargetWithActionForControlEvent(target, action, 1<<i);
|
this->addTargetWithActionForControlEvent(target, action, (EventType)(1<<i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +164,7 @@ void Control::addTargetWithActionForControlEvents(Object* target, SEL_CCControlH
|
||||||
* @param controlEvent A control event for which the action message is sent.
|
* @param controlEvent A control event for which the action message is sent.
|
||||||
* See "CCControlEvent" for constants.
|
* See "CCControlEvent" for constants.
|
||||||
*/
|
*/
|
||||||
void Control::addTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
void Control::addTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent)
|
||||||
{
|
{
|
||||||
// Create the invocation object
|
// Create the invocation object
|
||||||
Invocation *invocation = Invocation::create(target, action, controlEvent);
|
Invocation *invocation = Invocation::create(target, action, controlEvent);
|
||||||
|
@ -173,20 +174,20 @@ void Control::addTargetWithActionForControlEvent(Object* target, SEL_CCControlHa
|
||||||
eventInvocationList->addObject(invocation);
|
eventInvocationList->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 each control events
|
||||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
// If the given controlEvents bitmask contains the curent event
|
// 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
|
// Retrieve all invocations for the given control event
|
||||||
//<Invocation*>
|
//<Invocation*>
|
||||||
|
@ -264,15 +265,15 @@ bool Control::isTouchInside(Touch* touch)
|
||||||
return bBox.containsPoint(touchLocation);
|
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 the invocation list does not exist for the dispatch table, we create it
|
||||||
if (invocationList == NULL)
|
if (invocationList == NULL)
|
||||||
{
|
{
|
||||||
invocationList = Array::createWithCapacity(1);
|
invocationList = Array::createWithCapacity(1);
|
||||||
_dispatchTable->setObject(invocationList, controlEvent);
|
_dispatchTable->setObject(invocationList, (int)controlEvent);
|
||||||
}
|
}
|
||||||
return invocationList;
|
return invocationList;
|
||||||
}
|
}
|
||||||
|
@ -285,9 +286,9 @@ void Control::setEnabled(bool bEnabled)
|
||||||
{
|
{
|
||||||
_enabled = bEnabled;
|
_enabled = bEnabled;
|
||||||
if(_enabled) {
|
if(_enabled) {
|
||||||
_state = ControlStateNormal;
|
_state = Control::State::NORMAL;
|
||||||
} else {
|
} else {
|
||||||
_state = ControlStateDisabled;
|
_state = Control::State::DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->needsLayout();
|
this->needsLayout();
|
||||||
|
|
|
@ -30,12 +30,13 @@
|
||||||
#ifndef __CCCONTROL_H__
|
#ifndef __CCCONTROL_H__
|
||||||
#define __CCCONTROL_H__
|
#define __CCCONTROL_H__
|
||||||
|
|
||||||
#include "CCInvocation.h"
|
|
||||||
#include "CCControlUtils.h"
|
#include "CCControlUtils.h"
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Invocation;
|
class Invocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,30 +49,6 @@ class Invocation;
|
||||||
/** Number of kinds of control event. */
|
/** Number of kinds of control event. */
|
||||||
#define kControlEventTotalNumber 9
|
#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
|
* @class
|
||||||
|
@ -88,6 +65,31 @@ typedef unsigned int ControlState;
|
||||||
class Control : public LayerRGBA
|
class Control : public LayerRGBA
|
||||||
{
|
{
|
||||||
public:
|
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();
|
static Control* create();
|
||||||
|
|
||||||
Control();
|
Control();
|
||||||
|
@ -118,7 +120,7 @@ public:
|
||||||
* @param controlEvents A bitmask whose set flags specify the control events for
|
* @param controlEvents A bitmask whose set flags specify the control events for
|
||||||
* which action messages are sent. See "CCControlEvent" for bitmask constants.
|
* 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
|
* 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
|
* @param controlEvents A bitmask specifying the control events for which the
|
||||||
* action message is sent. See "CCControlEvent" for bitmask constants.
|
* 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
|
* 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
|
* @param controlEvents A bitmask specifying the control events associated with
|
||||||
* target and action. See "CCControlEvent" for bitmask constants.
|
* 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
|
* 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
|
* @return an Invocation object able to construct messages using a given
|
||||||
* target-action pair.
|
* 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
|
* 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.
|
* @return the Invocation list for the given control event.
|
||||||
*/
|
*/
|
||||||
//<Invocation*>
|
//<Invocation*>
|
||||||
Array* dispatchListforControlEvent(ControlEvent controlEvent);
|
Array* dispatchListforControlEvent(EventType controlEvent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a target and action for a particular event to an internal dispatch
|
* 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.
|
* @param controlEvent A control event for which the action message is sent.
|
||||||
* See "CCControlEvent" for constants.
|
* 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
|
* 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.
|
* @param controlEvent A control event for which the action message is sent.
|
||||||
* See "CCControlEvent" for constants.
|
* See "CCControlEvent" for constants.
|
||||||
*/
|
*/
|
||||||
void removeTargetWithActionForControlEvent(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
void removeTargetWithActionForControlEvent(Object* target, Handler action, EventType controlEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
|
@ -249,7 +251,7 @@ protected:
|
||||||
bool _isOpacityModifyRGB;
|
bool _isOpacityModifyRGB;
|
||||||
|
|
||||||
/** The current control state constant. */
|
/** The current control state constant. */
|
||||||
CC_SYNTHESIZE_READONLY(ControlState, _state, State);
|
CC_SYNTHESIZE_READONLY(State, _state, State);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of GUI group
|
// end of GUI group
|
||||||
|
|
|
@ -125,10 +125,10 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
||||||
|
|
||||||
String* tempString = String::create(label->getString());
|
String* tempString = String::create(label->getString());
|
||||||
//tempString->autorelease();
|
//tempString->autorelease();
|
||||||
setTitleForState(tempString, ControlStateNormal);
|
setTitleForState(tempString, Control::State::NORMAL);
|
||||||
setTitleColorForState(rgbaLabel->getColor(), ControlStateNormal);
|
setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL);
|
||||||
setTitleLabelForState(node, ControlStateNormal);
|
setTitleLabelForState(node, Control::State::NORMAL);
|
||||||
setBackgroundSpriteForState(backgroundSprite, ControlStateNormal);
|
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
|
||||||
|
|
||||||
setLabelAnchorPoint(Point(0.5f, 0.5f));
|
setLabelAnchorPoint(Point(0.5f, 0.5f));
|
||||||
|
|
||||||
|
@ -204,11 +204,11 @@ void ControlButton::setHighlighted(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled == true)
|
if (enabled == true)
|
||||||
{
|
{
|
||||||
_state = ControlStateHighlighted;
|
_state = Control::State::HIGH_LIGHTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_state = ControlStateNormal;
|
_state = Control::State::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Control::setHighlighted(enabled);
|
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)
|
if (_titleDispatchTable != NULL)
|
||||||
{
|
{
|
||||||
String* title=(String*)_titleDispatchTable->objectForKey(state);
|
String* title=(String*)_titleDispatchTable->objectForKey((int)state);
|
||||||
if (title)
|
if (title)
|
||||||
{
|
{
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
return (String*)_titleDispatchTable->objectForKey(ControlStateNormal);
|
return (String*)_titleDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||||
}
|
}
|
||||||
return String::create("");
|
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)
|
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
|
// 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;
|
Color3B returnColor = Color3B::WHITE;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(NULL == _titleColorDispatchTable);
|
CC_BREAK_IF(NULL == _titleColorDispatchTable);
|
||||||
Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey(state);
|
Color3bObject* colorObject=(Color3bObject*)_titleColorDispatchTable->objectForKey((int)state);
|
||||||
if (colorObject)
|
if (colorObject)
|
||||||
{
|
{
|
||||||
returnColor = colorObject->value;
|
returnColor = colorObject->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey(ControlStateNormal);
|
colorObject = (Color3bObject*)_titleColorDispatchTable->objectForKey((int)Control::State::NORMAL);
|
||||||
if (colorObject)
|
if (colorObject)
|
||||||
{
|
{
|
||||||
returnColor = colorObject->value;
|
returnColor = colorObject->value;
|
||||||
|
@ -343,13 +343,13 @@ Color3B ControlButton::getTitleColorForState(ControlState state) const
|
||||||
return returnColor;
|
return returnColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlButton::setTitleColorForState(Color3B color, ControlState state)
|
void ControlButton::setTitleColorForState(Color3B color, State state)
|
||||||
{
|
{
|
||||||
//Color3B* colorValue=&color;
|
//Color3B* colorValue=&color;
|
||||||
_titleColorDispatchTable->removeObjectForKey(state);
|
_titleColorDispatchTable->removeObjectForKey((int)state);
|
||||||
Color3bObject* pColor3bObject = new Color3bObject(color);
|
Color3bObject* pColor3bObject = new Color3bObject(color);
|
||||||
pColor3bObject->autorelease();
|
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 the current state if equal to the given state we update the layout
|
||||||
if (getState() == state)
|
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)
|
if (titleLabel)
|
||||||
{
|
{
|
||||||
return 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)
|
if (previousLabel)
|
||||||
{
|
{
|
||||||
removeChild(previousLabel, true);
|
removeChild(previousLabel, true);
|
||||||
_titleLabelDispatchTable->removeObjectForKey(state);
|
_titleLabelDispatchTable->removeObjectForKey((int)state);
|
||||||
}
|
}
|
||||||
|
|
||||||
_titleLabelDispatchTable->setObject(titleLabel, state);
|
_titleLabelDispatchTable->setObject(titleLabel, (int)state);
|
||||||
titleLabel->setVisible(false);
|
titleLabel->setVisible(false);
|
||||||
titleLabel->setAnchorPoint(Point(0.5f, 0.5f));
|
titleLabel->setAnchorPoint(Point(0.5f, 0.5f));
|
||||||
addChild(titleLabel, 1);
|
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);
|
String * title = this->getTitleForState(state);
|
||||||
if (!title)
|
if (!title)
|
||||||
|
@ -399,7 +399,7 @@ void ControlButton::setTitleTTFForState(const char * fntFile, ControlState state
|
||||||
this->setTitleLabelForState(LabelTTF::create(title->getCString(), fntFile, 12), 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<LabelProtocol*>(this->getTitleLabelForState(state));
|
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(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<LabelProtocol*>(this->getTitleLabelForState(state));
|
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||||
if(label)
|
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<LabelProtocol*>(this->getTitleLabelForState(state));
|
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(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);
|
String * title = this->getTitleForState(state);
|
||||||
if (!title)
|
if (!title)
|
||||||
|
@ -450,7 +450,7 @@ void ControlButton::setTitleBMFontForState(const char * fntFile, ControlState st
|
||||||
this->setTitleLabelForState(LabelBMFont::create(title->getCString(), fntFile), state);
|
this->setTitleLabelForState(LabelBMFont::create(title->getCString(), fntFile), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * ControlButton::getTitleBMFontForState(ControlState state)
|
const char * ControlButton::getTitleBMFontForState(State state)
|
||||||
{
|
{
|
||||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||||
LabelBMFont* labelBMFont = dynamic_cast<LabelBMFont*>(label);
|
LabelBMFont* labelBMFont = dynamic_cast<LabelBMFont*>(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)
|
if (backgroundSprite)
|
||||||
{
|
{
|
||||||
return 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;
|
Size oldPreferredSize = _preferredSize;
|
||||||
|
|
||||||
Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey(state);
|
Scale9Sprite* previousBackgroundSprite = (Scale9Sprite*)_backgroundSpriteDispatchTable->objectForKey((int)state);
|
||||||
if (previousBackgroundSprite)
|
if (previousBackgroundSprite)
|
||||||
{
|
{
|
||||||
removeChild(previousBackgroundSprite, true);
|
removeChild(previousBackgroundSprite, true);
|
||||||
_backgroundSpriteDispatchTable->removeObjectForKey(state);
|
_backgroundSpriteDispatchTable->removeObjectForKey((int)state);
|
||||||
}
|
}
|
||||||
|
|
||||||
_backgroundSpriteDispatchTable->setObject(sprite, state);
|
_backgroundSpriteDispatchTable->setObject(sprite, (int)state);
|
||||||
sprite->setVisible(false);
|
sprite->setVisible(false);
|
||||||
sprite->setAnchorPoint(Point(0.5f, 0.5f));
|
sprite->setAnchorPoint(Point(0.5f, 0.5f));
|
||||||
addChild(sprite);
|
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);
|
Scale9Sprite * sprite = Scale9Sprite::createWithSpriteFrame(spriteFrame);
|
||||||
this->setBackgroundSpriteForState(sprite, state);
|
this->setBackgroundSpriteForState(sprite, state);
|
||||||
|
@ -647,7 +647,7 @@ bool ControlButton::ccTouchBegan(Touch *pTouch, Event *pEvent)
|
||||||
|
|
||||||
_isPushed = true;
|
_isPushed = true;
|
||||||
this->setHighlighted(true);
|
this->setHighlighted(true);
|
||||||
sendActionsForControlEvents(ControlEventTouchDown);
|
sendActionsForControlEvents(Control::EventType::TOUCH_DOWN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,21 +666,21 @@ void ControlButton::ccTouchMoved(Touch *pTouch, Event *pEvent)
|
||||||
if (isTouchMoveInside && !isHighlighted())
|
if (isTouchMoveInside && !isHighlighted())
|
||||||
{
|
{
|
||||||
setHighlighted(true);
|
setHighlighted(true);
|
||||||
sendActionsForControlEvents(ControlEventTouchDragEnter);
|
sendActionsForControlEvents(Control::EventType::DRAG_ENTER);
|
||||||
}
|
}
|
||||||
else if (isTouchMoveInside && isHighlighted())
|
else if (isTouchMoveInside && isHighlighted())
|
||||||
{
|
{
|
||||||
sendActionsForControlEvents(ControlEventTouchDragInside);
|
sendActionsForControlEvents(Control::EventType::DRAG_INSIDE);
|
||||||
}
|
}
|
||||||
else if (!isTouchMoveInside && isHighlighted())
|
else if (!isTouchMoveInside && isHighlighted())
|
||||||
{
|
{
|
||||||
setHighlighted(false);
|
setHighlighted(false);
|
||||||
|
|
||||||
sendActionsForControlEvents(ControlEventTouchDragExit);
|
sendActionsForControlEvents(Control::EventType::DRAG_EXIT);
|
||||||
}
|
}
|
||||||
else if (!isTouchMoveInside && !isHighlighted())
|
else if (!isTouchMoveInside && !isHighlighted())
|
||||||
{
|
{
|
||||||
sendActionsForControlEvents(ControlEventTouchDragOutside);
|
sendActionsForControlEvents(Control::EventType::DRAG_OUTSIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
||||||
|
@ -691,11 +691,11 @@ void ControlButton::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
||||||
|
|
||||||
if (isTouchInside(pTouch))
|
if (isTouchInside(pTouch))
|
||||||
{
|
{
|
||||||
sendActionsForControlEvents(ControlEventTouchUpInside);
|
sendActionsForControlEvents(Control::EventType::TOUCH_UP_INSIDE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendActionsForControlEvents(ControlEventTouchUpOutside);
|
sendActionsForControlEvents(Control::EventType::TOUCH_UP_OUTSIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ void ControlButton::ccTouchCancelled(Touch *pTouch, Event *pEvent)
|
||||||
{
|
{
|
||||||
_isPushed = false;
|
_isPushed = false;
|
||||||
setHighlighted(false);
|
setHighlighted(false);
|
||||||
sendActionsForControlEvents(ControlEventTouchCancel);
|
sendActionsForControlEvents(Control::EventType::TOUCH_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlButton* ControlButton::create()
|
ControlButton* ControlButton::create()
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The title for the specified state.
|
* @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.
|
* 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
|
* @param state The state that uses the specified title. The values are described
|
||||||
* in "CCControlState".
|
* in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual void setTitleForState(String* title, ControlState state);
|
virtual void setTitleForState(String* title, State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the title color used for a state.
|
* Returns the title color used for a state.
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
* @return The color of the title for the specified state.
|
* @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.
|
* 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
|
* @param state The state that uses the specified color. The values are described
|
||||||
* in "CCControlState".
|
* in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual void setTitleColorForState(Color3B color, ControlState state);
|
virtual void setTitleColorForState(Color3B color, State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the title label used for a 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
|
* @param state The state that uses the title label. Possible values are described
|
||||||
* in "CCControlState".
|
* in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual Node* getTitleLabelForState(ControlState state);
|
virtual Node* getTitleLabelForState(State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the title label to use for the specified 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
|
* @param state The state that uses the specified title. The values are described
|
||||||
* in "CCControlState".
|
* 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 void setTitleTTFForState(const char * fntFile, State state);
|
||||||
virtual const char * getTitleTTFForState(ControlState state);
|
virtual const char * getTitleTTFForState(State state);
|
||||||
|
|
||||||
virtual void setTitleTTFSizeForState(float size, ControlState state);
|
virtual void setTitleTTFSizeForState(float size, State state);
|
||||||
virtual float getTitleTTFSizeForState(ControlState state);
|
virtual float getTitleTTFSizeForState(State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font of the label, changes the label to a LabelBMFont if neccessary.
|
* 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
|
* @param state The state that uses the specified fntFile. The values are described
|
||||||
* in "CCControlState".
|
* in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual void setTitleBMFontForState(const char * fntFile, ControlState state);
|
virtual void setTitleBMFontForState(const char * fntFile, State state);
|
||||||
virtual const char * getTitleBMFontForState(ControlState state);
|
virtual const char * getTitleBMFontForState(State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the background sprite used for a 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
|
* @param state The state that uses the background sprite. Possible values are
|
||||||
* described in "CCControlState".
|
* described in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual Scale9Sprite* getBackgroundSpriteForState(ControlState state);
|
virtual Scale9Sprite* getBackgroundSpriteForState(State state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the background sprite to use for the specified button 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
|
* @param state The state that uses the specified image. The values are described
|
||||||
* in "CCControlState".
|
* 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.
|
* 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
|
* @param state The state that uses the specified image. The values are described
|
||||||
* in "CCControlState".
|
* 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)
|
//set the margins at once (so we only have to do one call of needsLayout)
|
||||||
virtual void setMargins(int marginH, int marginV);
|
virtual void setMargins(int marginH, int marginV);
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) override;
|
virtual bool ccTouchBegan(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||||
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) override;
|
virtual void ccTouchMoved(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||||
virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) override;
|
virtual void ccTouchEnded(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||||
virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) override;
|
virtual void ccTouchCancelled(Touch *pTouch, cocos2d::Event *pEvent) override;
|
||||||
virtual GLubyte getOpacity(void) const override;
|
virtual GLubyte getOpacity(void) const override;
|
||||||
virtual void setOpacity(GLubyte var) override;
|
virtual void setOpacity(GLubyte var) override;
|
||||||
virtual const Color3B& getColor(void) const override;
|
virtual const Color3B& getColor(void) const override;
|
||||||
|
|
|
@ -92,8 +92,8 @@ bool ControlColourPicker::init()
|
||||||
_colourPicker->initWithTargetAndPos(spriteSheet, Point(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
|
_colourPicker->initWithTargetAndPos(spriteSheet, Point(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
|
||||||
|
|
||||||
// Setup events
|
// Setup events
|
||||||
_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), ControlEventValueChanged);
|
_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), Control::EventType::VALUE_CHANGED);
|
||||||
_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), ControlEventValueChanged);
|
_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), Control::EventType::VALUE_CHANGED);
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
updateHueAndControlPicker();
|
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()
|
void ControlColourPicker::updateControlPicker()
|
||||||
{
|
{
|
||||||
_huePicker->setHue(_hsv.h);
|
_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();
|
_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)));
|
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||||
|
|
||||||
// Send Control callback
|
// Send Control callback
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
updateControlPicker();
|
updateControlPicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlColourPicker::colourSliderValueChanged(Object * sender, ControlEvent controlEvent)
|
void ControlColourPicker::colourSliderValueChanged(Object * sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
_hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation();
|
_hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation();
|
||||||
_hsv.v=((ControlSaturationBrightnessPicker*)sender)->getBrightness();
|
_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)));
|
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||||
|
|
||||||
// Send Control callback
|
// Send Control callback
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ignore all touches, handled by children
|
//ignore all touches, handled by children
|
||||||
|
|
|
@ -61,8 +61,8 @@ public:
|
||||||
virtual void setEnabled(bool bEnabled);
|
virtual void setEnabled(bool bEnabled);
|
||||||
|
|
||||||
//virtual ~ControlColourPicker();
|
//virtual ~ControlColourPicker();
|
||||||
void hueSliderValueChanged(Object * sender, ControlEvent controlEvent);
|
void hueSliderValueChanged(Object * sender, Control::EventType controlEvent);
|
||||||
void colourSliderValueChanged(Object * sender, ControlEvent controlEvent);
|
void colourSliderValueChanged(Object * sender, Control::EventType controlEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateControlPicker();
|
void updateControlPicker();
|
||||||
|
|
|
@ -147,7 +147,7 @@ void ControlHuePicker::updateSliderPosition(Point location)
|
||||||
setHue(angleDeg);
|
setHue(angleDeg);
|
||||||
|
|
||||||
// send Control callback
|
// send Control callback
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlHuePicker::checkSliderPosition(Point location)
|
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
|
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
|
||||||
// updateSliderPosition(touchLocation);
|
// updateSliderPosition(touchLocation);
|
||||||
// sendActionsForControlEvents(ControlEventValueChanged);
|
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
// Check the touch position on the slider
|
// Check the touch position on the slider
|
||||||
checkSliderPosition(touchLocation);
|
checkSliderPosition(touchLocation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ void ControlPotentiometer::setValue(float value)
|
||||||
_progressTimer->setPercentage(percent * 100.0f);
|
_progressTimer->setPercentage(percent * 100.0f);
|
||||||
_thumbSprite->setRotation(percent * 360.0f);
|
_thumbSprite->setRotation(percent * 360.0f);
|
||||||
|
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
float ControlPotentiometer::getValue()
|
float ControlPotentiometer::getValue()
|
||||||
|
|
|
@ -174,7 +174,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
|
||||||
if (dist <= _background->getBoundingBox().size.width*0.5f)
|
if (dist <= _background->getBoundingBox().size.width*0.5f)
|
||||||
{
|
{
|
||||||
updateSliderPosition(location);
|
updateSliderPosition(location);
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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
|
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
|
||||||
// updateSliderPosition(touchLocation);
|
// updateSliderPosition(touchLocation);
|
||||||
// sendActionsForControlEvents(ControlEventValueChanged);
|
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
// Check the touch position on the slider
|
// Check the touch position on the slider
|
||||||
checkSliderPosition(touchLocation);
|
checkSliderPosition(touchLocation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ void ControlSlider::setEnabled(bool enabled)
|
||||||
|
|
||||||
this->needsLayout();
|
this->needsLayout();
|
||||||
|
|
||||||
this->sendActionsForControlEvents(ControlEventValueChanged);
|
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSlider::setMinimumValue(float minimumValue)
|
void ControlSlider::setMinimumValue(float minimumValue)
|
||||||
|
|
|
@ -213,7 +213,7 @@ void ControlStepper::setValueWithSendingEvent(double value, bool send)
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
this->sendActionsForControlEvents(ControlEventValueChanged);
|
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
/** Update the layout of the stepper with the given touch location. */
|
/** Update the layout of the stepper with the given touch location. */
|
||||||
void updateLayoutUsingTouchLocation(Point 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);
|
void setValue(double value, bool send);
|
||||||
|
|
||||||
/** Start the autorepeat increment/decrement. */
|
/** Start the autorepeat increment/decrement. */
|
||||||
|
|
|
@ -366,7 +366,7 @@ void ControlSwitch::setOn(bool isOn, bool animated)
|
||||||
_switchSprite->setSliderXPosition((_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition());
|
_switchSprite->setSliderXPosition((_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
sendActionsForControlEvents(ControlEventValueChanged);
|
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSwitch::setEnabled(bool enabled)
|
void ControlSwitch::setEnabled(bool enabled)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
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);
|
Invocation* pRet = new Invocation(target, action, controlEvent);
|
||||||
if (pRet != NULL)
|
if (pRet != NULL)
|
||||||
|
@ -38,7 +38,7 @@ Invocation* Invocation::create(Object* target, SEL_CCControlHandler action, Cont
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Invocation::Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent)
|
Invocation::Invocation(Object* target, Control::Handler action, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
_target=target;
|
_target=target;
|
||||||
_action=action;
|
_action=action;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "cocoa/CCObject.h"
|
#include "cocoa/CCObject.h"
|
||||||
#include "../../ExtensionMacros.h"
|
#include "../../ExtensionMacros.h"
|
||||||
|
#include "CCControl.h"
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
|
@ -42,24 +43,20 @@ NS_CC_EXT_BEGIN
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef unsigned int ControlEvent;
|
#define cccontrol_selector(_SELECTOR) (Control::Handler)(&_SELECTOR)
|
||||||
|
|
||||||
typedef void (Object::*SEL_CCControlHandler)(Object*, ControlEvent);
|
|
||||||
|
|
||||||
#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR)
|
|
||||||
|
|
||||||
class Invocation : public Object
|
class Invocation : public Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Invocation* create(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
static Invocation* create(Object* target, Control::Handler action, Control::EventType controlEvent);
|
||||||
Invocation(Object* target, SEL_CCControlHandler action, ControlEvent controlEvent);
|
Invocation(Object* target, Control::Handler action, Control::EventType controlEvent);
|
||||||
|
|
||||||
void invoke(Object* sender);
|
void invoke(Object* sender);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, _action, Action);
|
CC_SYNTHESIZE_READONLY(Control::Handler, _action, Action);
|
||||||
CC_SYNTHESIZE_READONLY(Object*, _target, Target);
|
CC_SYNTHESIZE_READONLY(Object*, _target, Target);
|
||||||
CC_SYNTHESIZE_READONLY(ControlEvent, _controlEvent, ControlEvent);
|
CC_SYNTHESIZE_READONLY(Control::EventType, _controlEvent, ControlEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of GUI group
|
// end of GUI group
|
||||||
|
|
|
@ -31,9 +31,9 @@ NS_CC_EXT_BEGIN
|
||||||
EditBox::EditBox(void)
|
EditBox::EditBox(void)
|
||||||
: _editBoxImpl(NULL)
|
: _editBoxImpl(NULL)
|
||||||
, _delegate(NULL)
|
, _delegate(NULL)
|
||||||
, _editBoxInputMode(kEditBoxInputModeSingleLine)
|
, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE)
|
||||||
, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters)
|
, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS)
|
||||||
, _keyboardReturnType(kKeyboardReturnTypeDefault)
|
, _keyboardReturnType(KeyboardReturnType::DEFAULT)
|
||||||
, _fontSize(-1)
|
, _fontSize(-1)
|
||||||
, _placeholderFontSize(-1)
|
, _placeholderFontSize(-1)
|
||||||
, _colText(Color3B::WHITE)
|
, _colText(Color3B::WHITE)
|
||||||
|
@ -51,7 +51,7 @@ EditBox::~EditBox(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditBox::touchDownAction(Object *sender, ControlEvent controlEvent)
|
void EditBox::touchDownAction(Object *sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
_editBoxImpl->openKeyboard();
|
_editBoxImpl->openKeyboard();
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,12 @@ EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale
|
||||||
{
|
{
|
||||||
if (pPressed9SpriteBg != NULL)
|
if (pPressed9SpriteBg != NULL)
|
||||||
{
|
{
|
||||||
pRet->setBackgroundSpriteForState(pPressed9SpriteBg, ControlStateHighlighted);
|
pRet->setBackgroundSpriteForState(pPressed9SpriteBg, Control::State::HIGH_LIGHTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDisabled9SpriteBg != NULL)
|
if (pDisabled9SpriteBg != NULL)
|
||||||
{
|
{
|
||||||
pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, ControlStateDisabled);
|
pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, Control::State::DISABLED);
|
||||||
}
|
}
|
||||||
pRet->autorelease();
|
pRet->autorelease();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pP
|
||||||
this->setZoomOnTouchDown(false);
|
this->setZoomOnTouchDown(false);
|
||||||
this->setPreferredSize(size);
|
this->setPreferredSize(size);
|
||||||
this->setPosition(Point(0, 0));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ const char* EditBox::getPlaceHolder(void)
|
||||||
return _placeHolder.c_str();
|
return _placeHolder.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBox::setInputMode(EditBoxInputMode inputMode)
|
void EditBox::setInputMode(EditBox::InputMode inputMode)
|
||||||
{
|
{
|
||||||
_editBoxInputMode = inputMode;
|
_editBoxInputMode = inputMode;
|
||||||
if (_editBoxImpl != NULL)
|
if (_editBoxImpl != NULL)
|
||||||
|
@ -257,7 +257,7 @@ int EditBox::getMaxLength()
|
||||||
return _maxLength;
|
return _maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBox::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBox::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
_editBoxInputFlag = inputFlag;
|
_editBoxInputFlag = inputFlag;
|
||||||
if (_editBoxImpl != NULL)
|
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)
|
if (_editBoxImpl != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,98 +32,6 @@
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
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 EditBox;
|
||||||
class EditBoxImpl;
|
class EditBoxImpl;
|
||||||
|
|
||||||
|
@ -173,6 +81,95 @@ class EditBox
|
||||||
, public IMEDelegate
|
, public IMEDelegate
|
||||||
{
|
{
|
||||||
public:
|
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.
|
* 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.
|
* @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.
|
* 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.
|
* 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.
|
* 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.
|
* 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 */
|
/* override functions */
|
||||||
virtual void setPosition(const Point& pos);
|
virtual void setPosition(const Point& pos);
|
||||||
|
@ -356,15 +353,15 @@ public:
|
||||||
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info);
|
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info);
|
||||||
|
|
||||||
/* callback funtions */
|
/* callback funtions */
|
||||||
void touchDownAction(Object *sender, ControlEvent controlEvent);
|
void touchDownAction(Object *sender, Control::EventType controlEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EditBoxImpl* _editBoxImpl;
|
EditBoxImpl* _editBoxImpl;
|
||||||
EditBoxDelegate* _delegate;
|
EditBoxDelegate* _delegate;
|
||||||
|
|
||||||
EditBoxInputMode _editBoxInputMode;
|
InputMode _editBoxInputMode;
|
||||||
EditBoxInputFlag _editBoxInputFlag;
|
InputFlag _editBoxInputFlag;
|
||||||
KeyboardReturnType _keyboardReturnType;
|
EditBox::KeyboardReturnType _keyboardReturnType;
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
std::string _placeHolder;
|
std::string _placeHolder;
|
||||||
|
|
|
@ -44,11 +44,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color) = 0;
|
virtual void setFontColor(const Color3B& color) = 0;
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize) = 0;
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize) = 0;
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color) = 0;
|
virtual void setPlaceholderFontColor(const Color3B& color) = 0;
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode) = 0;
|
virtual void setInputMode(EditBox::InputMode inputMode) = 0;
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag) = 0;
|
virtual void setInputFlag(EditBox::InputFlag inputFlag) = 0;
|
||||||
virtual void setMaxLength(int maxLength) = 0;
|
virtual void setMaxLength(int maxLength) = 0;
|
||||||
virtual int getMaxLength() = 0;
|
virtual int getMaxLength() = 0;
|
||||||
virtual void setReturnType(KeyboardReturnType returnType) = 0;
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType) = 0;
|
||||||
virtual bool isEditing() = 0;
|
virtual bool isEditing() = 0;
|
||||||
|
|
||||||
virtual void setText(const char* pText) = 0;
|
virtual void setText(const char* pText) = 0;
|
||||||
|
|
|
@ -43,9 +43,9 @@ EditBoxImplAndroid::EditBoxImplAndroid(EditBox* pEditText)
|
||||||
: EditBoxImpl(pEditText)
|
: EditBoxImpl(pEditText)
|
||||||
, _label(NULL)
|
, _label(NULL)
|
||||||
, _labelPlaceHolder(NULL)
|
, _labelPlaceHolder(NULL)
|
||||||
, _editBoxInputMode(kEditBoxInputModeSingleLine)
|
, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE)
|
||||||
, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters)
|
, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS)
|
||||||
, _keyboardReturnType(kKeyboardReturnTypeDefault)
|
, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT)
|
||||||
, _colText(Color3B::WHITE)
|
, _colText(Color3B::WHITE)
|
||||||
, _colPlaceHolder(Color3B::GRAY)
|
, _colPlaceHolder(Color3B::GRAY)
|
||||||
, _maxLength(-1)
|
, _maxLength(-1)
|
||||||
|
@ -120,7 +120,7 @@ void EditBoxImplAndroid::setPlaceholderFontColor(const Color3B& color)
|
||||||
_labelPlaceHolder->setColor(color);
|
_labelPlaceHolder->setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplAndroid::setInputMode(EditBoxInputMode inputMode)
|
void EditBoxImplAndroid::setInputMode(EditBox::InputMode inputMode)
|
||||||
{
|
{
|
||||||
_editBoxInputMode = inputMode;
|
_editBoxInputMode = inputMode;
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ int EditBoxImplAndroid::getMaxLength()
|
||||||
return _maxLength;
|
return _maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplAndroid::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBoxImplAndroid::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
_editBoxInputFlag = inputFlag;
|
_editBoxInputFlag = inputFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplAndroid::setReturnType(KeyboardReturnType returnType)
|
void EditBoxImplAndroid::setReturnType(EditBox::KeyboardReturnType returnType)
|
||||||
{
|
{
|
||||||
_keyboardReturnType = returnType;
|
_keyboardReturnType = returnType;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void EditBoxImplAndroid::setText(const char* pText)
|
||||||
|
|
||||||
std::string strToShow;
|
std::string strToShow;
|
||||||
|
|
||||||
if (kEditBoxInputFlagPassword == _editBoxInputFlag)
|
if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag)
|
||||||
{
|
{
|
||||||
long length = cc_utf8_strlen(_text.c_str(), -1);
|
long length = cc_utf8_strlen(_text.c_str(), -1);
|
||||||
for (long i = 0; i < length; i++)
|
for (long i = 0; i < length; i++)
|
||||||
|
@ -289,9 +289,9 @@ void EditBoxImplAndroid::openKeyboard()
|
||||||
|
|
||||||
showEditTextDialogJNI( _placeHolder.c_str(),
|
showEditTextDialogJNI( _placeHolder.c_str(),
|
||||||
_text.c_str(),
|
_text.c_str(),
|
||||||
_editBoxInputMode,
|
(int)_editBoxInputMode,
|
||||||
_editBoxInputFlag,
|
(int)_editBoxInputFlag,
|
||||||
_keyboardReturnType,
|
(int)_keyboardReturnType,
|
||||||
_maxLength,
|
_maxLength,
|
||||||
editBoxCallbackFunc,
|
editBoxCallbackFunc,
|
||||||
(void*)this );
|
(void*)this );
|
||||||
|
|
|
@ -48,11 +48,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color);
|
virtual void setFontColor(const Color3B& color);
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color);
|
virtual void setPlaceholderFontColor(const Color3B& color);
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode);
|
virtual void setInputMode(EditBox::InputMode inputMode);
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag);
|
virtual void setInputFlag(EditBox::InputFlag inputFlag);
|
||||||
virtual void setMaxLength(int maxLength);
|
virtual void setMaxLength(int maxLength);
|
||||||
virtual int getMaxLength();
|
virtual int getMaxLength();
|
||||||
virtual void setReturnType(KeyboardReturnType returnType);
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
|
||||||
virtual bool isEditing();
|
virtual bool isEditing();
|
||||||
|
|
||||||
virtual void setText(const char* pText);
|
virtual void setText(const char* pText);
|
||||||
|
@ -71,9 +71,9 @@ public:
|
||||||
private:
|
private:
|
||||||
LabelTTF* _label;
|
LabelTTF* _label;
|
||||||
LabelTTF* _labelPlaceHolder;
|
LabelTTF* _labelPlaceHolder;
|
||||||
EditBoxInputMode _editBoxInputMode;
|
EditBox::InputMode _editBoxInputMode;
|
||||||
EditBoxInputFlag _editBoxInputFlag;
|
EditBox::InputFlag _editBoxInputFlag;
|
||||||
KeyboardReturnType _keyboardReturnType;
|
EditBox::KeyboardReturnType _keyboardReturnType;
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
std::string _placeHolder;
|
std::string _placeHolder;
|
||||||
|
|
|
@ -79,11 +79,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color);
|
virtual void setFontColor(const Color3B& color);
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color);
|
virtual void setPlaceholderFontColor(const Color3B& color);
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode);
|
virtual void setInputMode(EditBox::InputMode inputMode);
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag);
|
virtual void setInputFlag(EditBox::InputFlag inputFlag);
|
||||||
virtual void setMaxLength(int maxLength);
|
virtual void setMaxLength(int maxLength);
|
||||||
virtual int getMaxLength();
|
virtual int getMaxLength();
|
||||||
virtual void setReturnType(KeyboardReturnType returnType);
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
|
||||||
virtual bool isEditing();
|
virtual bool isEditing();
|
||||||
|
|
||||||
virtual void setText(const char* pText);
|
virtual void setText(const char* pText);
|
||||||
|
|
|
@ -394,26 +394,26 @@ void EditBoxImplIOS::setPlaceholderFontColor(const Color3B& color)
|
||||||
_labelPlaceHolder->setColor(color);
|
_labelPlaceHolder->setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplIOS::setInputMode(EditBoxInputMode inputMode)
|
void EditBoxImplIOS::setInputMode(EditBox::InputMode inputMode)
|
||||||
{
|
{
|
||||||
switch (inputMode)
|
switch (inputMode)
|
||||||
{
|
{
|
||||||
case kEditBoxInputModeEmailAddr:
|
case EditBox::InputMode::EMAIL_ADDRESS:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypeEmailAddress;
|
_systemControl.textField.keyboardType = UIKeyboardTypeEmailAddress;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModeNumeric:
|
case EditBox::InputMode::NUMERIC:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
|
_systemControl.textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModePhoneNumber:
|
case EditBox::InputMode::PHONE_NUMBER:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypePhonePad;
|
_systemControl.textField.keyboardType = UIKeyboardTypePhonePad;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModeUrl:
|
case EditBox::InputMode::URL:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypeURL;
|
_systemControl.textField.keyboardType = UIKeyboardTypeURL;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModeDecimal:
|
case EditBox::InputMode::DECIMAL:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypeDecimalPad;
|
_systemControl.textField.keyboardType = UIKeyboardTypeDecimalPad;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModeSingleLine:
|
case EditBox::InputMode::SINGLE_LINE:
|
||||||
_systemControl.textField.keyboardType = UIKeyboardTypeDefault;
|
_systemControl.textField.keyboardType = UIKeyboardTypeDefault;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -432,23 +432,23 @@ int EditBoxImplIOS::getMaxLength()
|
||||||
return _maxTextLength;
|
return _maxTextLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplIOS::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBoxImplIOS::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
switch (inputFlag)
|
switch (inputFlag)
|
||||||
{
|
{
|
||||||
case kEditBoxInputFlagPassword:
|
case EditBox::InputFlag::PASSWORD:
|
||||||
_systemControl.textField.secureTextEntry = YES;
|
_systemControl.textField.secureTextEntry = YES;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputFlagInitialCapsWord:
|
case EditBox::InputFlag::INITIAL_CAPS_WORD:
|
||||||
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
|
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputFlagInitialCapsSentence:
|
case EditBox::InputFlag::INITIAL_CAPS_SENTENCE:
|
||||||
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
|
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputFlagInitialCapsAllCharacters:
|
case EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS:
|
||||||
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
|
_systemControl.textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputFlagSensitive:
|
case EditBox::InputFlag::SENSITIVE:
|
||||||
_systemControl.textField.autocorrectionType = UITextAutocorrectionTypeNo;
|
_systemControl.textField.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -456,22 +456,22 @@ void EditBoxImplIOS::setInputFlag(EditBoxInputFlag inputFlag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplIOS::setReturnType(KeyboardReturnType returnType)
|
void EditBoxImplIOS::setReturnType(EditBox::KeyboardReturnType returnType)
|
||||||
{
|
{
|
||||||
switch (returnType) {
|
switch (returnType) {
|
||||||
case kKeyboardReturnTypeDefault:
|
case EditBox::KeyboardReturnType::DEFAULT:
|
||||||
_systemControl.textField.returnKeyType = UIReturnKeyDefault;
|
_systemControl.textField.returnKeyType = UIReturnKeyDefault;
|
||||||
break;
|
break;
|
||||||
case kKeyboardReturnTypeDone:
|
case EditBox::KeyboardReturnType::DONE:
|
||||||
_systemControl.textField.returnKeyType = UIReturnKeyDone;
|
_systemControl.textField.returnKeyType = UIReturnKeyDone;
|
||||||
break;
|
break;
|
||||||
case kKeyboardReturnTypeSend:
|
case EditBox::KeyboardReturnType::SEND:
|
||||||
_systemControl.textField.returnKeyType = UIReturnKeySend;
|
_systemControl.textField.returnKeyType = UIReturnKeySend;
|
||||||
break;
|
break;
|
||||||
case kKeyboardReturnTypeSearch:
|
case EditBox::KeyboardReturnType::SEARCH:
|
||||||
_systemControl.textField.returnKeyType = UIReturnKeySearch;
|
_systemControl.textField.returnKeyType = UIReturnKeySearch;
|
||||||
break;
|
break;
|
||||||
case kKeyboardReturnTypeGo:
|
case EditBox::KeyboardReturnType::GO:
|
||||||
_systemControl.textField.returnKeyType = UIReturnKeyGo;
|
_systemControl.textField.returnKeyType = UIReturnKeyGo;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -78,11 +78,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color);
|
virtual void setFontColor(const Color3B& color);
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color);
|
virtual void setPlaceholderFontColor(const Color3B& color);
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode);
|
virtual void setInputMode(EditBox::InputMode inputMode);
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag);
|
virtual void setInputFlag(EditBox::InputFlag inputFlag);
|
||||||
virtual void setMaxLength(int maxLength);
|
virtual void setMaxLength(int maxLength);
|
||||||
virtual int getMaxLength();
|
virtual int getMaxLength();
|
||||||
virtual void setReturnType(KeyboardReturnType returnType);
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
|
||||||
virtual bool isEditing();
|
virtual bool isEditing();
|
||||||
|
|
||||||
virtual void setText(const char* pText);
|
virtual void setText(const char* pText);
|
||||||
|
|
|
@ -298,7 +298,7 @@ void EditBoxImplMac::setPlaceholderFontColor(const Color3B& color)
|
||||||
// TODO need to be implemented.
|
// 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;
|
return _maxTextLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplMac::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBoxImplMac::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
// TODO: NSSecureTextField
|
// TODO: NSSecureTextField
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplMac::setReturnType(KeyboardReturnType returnType)
|
void EditBoxImplMac::setReturnType(EditBox::KeyboardReturnType returnType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ EditBoxImplTizen::EditBoxImplTizen(EditBox* pEditText)
|
||||||
: EditBoxImpl(pEditText)
|
: EditBoxImpl(pEditText)
|
||||||
, _label(NULL)
|
, _label(NULL)
|
||||||
, _labelPlaceHolder(NULL)
|
, _labelPlaceHolder(NULL)
|
||||||
, _editBoxInputMode(kEditBoxInputModeSingleLine)
|
, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE)
|
||||||
, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters)
|
, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS)
|
||||||
, _keyboardReturnType(kKeyboardReturnTypeDefault)
|
, _keyboardReturnType(kKeyboardReturnTypeDefault)
|
||||||
, _colText(Color3B::WHITE)
|
, _colText(Color3B::WHITE)
|
||||||
, _colPlaceHolder(Color3B::GRAY)
|
, _colPlaceHolder(Color3B::GRAY)
|
||||||
|
@ -118,7 +118,7 @@ void EditBoxImplTizen::setPlaceholderFontColor(const Color3B& color)
|
||||||
_labelPlaceHolder->setColor(color);
|
_labelPlaceHolder->setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplTizen::setInputMode(EditBoxInputMode inputMode)
|
void EditBoxImplTizen::setInputMode(EditBox::InputMode inputMode)
|
||||||
{
|
{
|
||||||
_editBoxInputMode = inputMode;
|
_editBoxInputMode = inputMode;
|
||||||
}
|
}
|
||||||
|
@ -133,12 +133,12 @@ int EditBoxImplTizen::getMaxLength()
|
||||||
return _maxLength;
|
return _maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplTizen::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBoxImplTizen::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
_editBoxInputFlag = inputFlag;
|
_editBoxInputFlag = inputFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplTizen::setReturnType(KeyboardReturnType returnType)
|
void EditBoxImplTizen::setReturnType(EditBox::KeyboardReturnType returnType)
|
||||||
{
|
{
|
||||||
_keyboardReturnType = returnType;
|
_keyboardReturnType = returnType;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ void EditBoxImplTizen::openKeyboard()
|
||||||
case kEditBoxInputModeUrl:
|
case kEditBoxInputModeUrl:
|
||||||
keypadStyle = KEYPAD_STYLE_URL;
|
keypadStyle = KEYPAD_STYLE_URL;
|
||||||
break;
|
break;
|
||||||
case kEditBoxInputModeSingleLine:
|
case EditBox::InputMode::SINGLE_LINE:
|
||||||
bSingleLineEnabled = true;
|
bSingleLineEnabled = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -49,11 +49,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color);
|
virtual void setFontColor(const Color3B& color);
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color);
|
virtual void setPlaceholderFontColor(const Color3B& color);
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode);
|
virtual void setInputMode(EditBox::InputMode inputMode);
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag);
|
virtual void setInputFlag(EditBox::InputFlag inputFlag);
|
||||||
virtual void setMaxLength(int maxLength);
|
virtual void setMaxLength(int maxLength);
|
||||||
virtual int getMaxLength();
|
virtual int getMaxLength();
|
||||||
virtual void setReturnType(KeyboardReturnType returnType);
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
|
||||||
virtual bool isEditing();
|
virtual bool isEditing();
|
||||||
|
|
||||||
virtual void setText(const char* pText);
|
virtual void setText(const char* pText);
|
||||||
|
@ -72,9 +72,9 @@ public:
|
||||||
private:
|
private:
|
||||||
LabelTTF* _label;
|
LabelTTF* _label;
|
||||||
LabelTTF* _labelPlaceHolder;
|
LabelTTF* _labelPlaceHolder;
|
||||||
EditBoxInputMode _editBoxInputMode;
|
EditBox::InputMode _editBoxInputMode;
|
||||||
EditBoxInputFlag _editBoxInputFlag;
|
EditBox::InputFlag _editBoxInputFlag;
|
||||||
KeyboardReturnType _keyboardReturnType;
|
EditBox::KeyboardReturnType _keyboardReturnType;
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
std::string _placeHolder;
|
std::string _placeHolder;
|
||||||
|
|
|
@ -40,9 +40,9 @@ EditBoxImplWin::EditBoxImplWin(EditBox* pEditText)
|
||||||
: EditBoxImpl(pEditText)
|
: EditBoxImpl(pEditText)
|
||||||
, _label(NULL)
|
, _label(NULL)
|
||||||
, _labelPlaceHolder(NULL)
|
, _labelPlaceHolder(NULL)
|
||||||
, _editBoxInputMode(kEditBoxInputModeSingleLine)
|
, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE)
|
||||||
, _editBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters)
|
, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS)
|
||||||
, _keyboardReturnType(kKeyboardReturnTypeDefault)
|
, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT)
|
||||||
, _colText(Color3B::WHITE)
|
, _colText(Color3B::WHITE)
|
||||||
, _colPlaceHolder(Color3B::GRAY)
|
, _colPlaceHolder(Color3B::GRAY)
|
||||||
, _maxLength(-1)
|
, _maxLength(-1)
|
||||||
|
@ -113,7 +113,7 @@ void EditBoxImplWin::setPlaceholderFontColor(const Color3B& color)
|
||||||
_labelPlaceHolder->setColor(color);
|
_labelPlaceHolder->setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplWin::setInputMode(EditBoxInputMode inputMode)
|
void EditBoxImplWin::setInputMode(EditBox::InputMode inputMode)
|
||||||
{
|
{
|
||||||
_editBoxInputMode = inputMode;
|
_editBoxInputMode = inputMode;
|
||||||
}
|
}
|
||||||
|
@ -128,12 +128,12 @@ int EditBoxImplWin::getMaxLength()
|
||||||
return _maxLength;
|
return _maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplWin::setInputFlag(EditBoxInputFlag inputFlag)
|
void EditBoxImplWin::setInputFlag(EditBox::InputFlag inputFlag)
|
||||||
{
|
{
|
||||||
_editBoxInputFlag = inputFlag;
|
_editBoxInputFlag = inputFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBoxImplWin::setReturnType(KeyboardReturnType returnType)
|
void EditBoxImplWin::setReturnType(EditBox::KeyboardReturnType returnType)
|
||||||
{
|
{
|
||||||
_keyboardReturnType = returnType;
|
_keyboardReturnType = returnType;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ void EditBoxImplWin::setText(const char* pText)
|
||||||
|
|
||||||
std::string strToShow;
|
std::string strToShow;
|
||||||
|
|
||||||
if (kEditBoxInputFlagPassword == _editBoxInputFlag)
|
if (EditBox::InputFlag::PASSWORD == _editBoxInputFlag)
|
||||||
{
|
{
|
||||||
long length = cc_utf8_strlen(_text.c_str(), -1);
|
long length = cc_utf8_strlen(_text.c_str(), -1);
|
||||||
for (long i = 0; i < length; i++)
|
for (long i = 0; i < length; i++)
|
||||||
|
|
|
@ -48,11 +48,11 @@ public:
|
||||||
virtual void setFontColor(const Color3B& color);
|
virtual void setFontColor(const Color3B& color);
|
||||||
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
|
||||||
virtual void setPlaceholderFontColor(const Color3B& color);
|
virtual void setPlaceholderFontColor(const Color3B& color);
|
||||||
virtual void setInputMode(EditBoxInputMode inputMode);
|
virtual void setInputMode(EditBox::InputMode inputMode);
|
||||||
virtual void setInputFlag(EditBoxInputFlag inputFlag);
|
virtual void setInputFlag(EditBox::InputFlag inputFlag);
|
||||||
virtual void setMaxLength(int maxLength);
|
virtual void setMaxLength(int maxLength);
|
||||||
virtual int getMaxLength();
|
virtual int getMaxLength();
|
||||||
virtual void setReturnType(KeyboardReturnType returnType);
|
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
|
||||||
virtual bool isEditing();
|
virtual bool isEditing();
|
||||||
|
|
||||||
virtual void setText(const char* pText);
|
virtual void setText(const char* pText);
|
||||||
|
@ -71,9 +71,9 @@ private:
|
||||||
|
|
||||||
LabelTTF* _label;
|
LabelTTF* _label;
|
||||||
LabelTTF* _labelPlaceHolder;
|
LabelTTF* _labelPlaceHolder;
|
||||||
EditBoxInputMode _editBoxInputMode;
|
EditBox::InputMode _editBoxInputMode;
|
||||||
EditBoxInputFlag _editBoxInputFlag;
|
EditBox::InputFlag _editBoxInputFlag;
|
||||||
KeyboardReturnType _keyboardReturnType;
|
EditBox::KeyboardReturnType _keyboardReturnType;
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
std::string _placeHolder;
|
std::string _placeHolder;
|
||||||
|
|
|
@ -45,7 +45,7 @@ ScrollView::ScrollView()
|
||||||
, _minZoomScale(0.0f)
|
, _minZoomScale(0.0f)
|
||||||
, _maxZoomScale(0.0f)
|
, _maxZoomScale(0.0f)
|
||||||
, _delegate(NULL)
|
, _delegate(NULL)
|
||||||
, _direction(kScrollViewDirectionBoth)
|
, _direction(Direction::BOTH)
|
||||||
, _dragging(false)
|
, _dragging(false)
|
||||||
, _container(NULL)
|
, _container(NULL)
|
||||||
, _touchMoved(false)
|
, _touchMoved(false)
|
||||||
|
@ -114,7 +114,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/)
|
||||||
_bounceable = true;
|
_bounceable = true;
|
||||||
_clippingToBounds = true;
|
_clippingToBounds = true;
|
||||||
//_container->setContentSize(Size::ZERO);
|
//_container->setContentSize(Size::ZERO);
|
||||||
_direction = kScrollViewDirectionBoth;
|
_direction = Direction::BOTH;
|
||||||
_container->setPosition(Point(0.0f, 0.0f));
|
_container->setPosition(Point(0.0f, 0.0f));
|
||||||
_touchLength = 0.0f;
|
_touchLength = 0.0f;
|
||||||
|
|
||||||
|
@ -333,13 +333,13 @@ void ScrollView::relocateContainer(bool animated)
|
||||||
|
|
||||||
newX = oldPoint.x;
|
newX = oldPoint.x;
|
||||||
newY = oldPoint.y;
|
newY = oldPoint.y;
|
||||||
if (_direction == kScrollViewDirectionBoth || _direction == kScrollViewDirectionHorizontal)
|
if (_direction == Direction::BOTH || _direction == Direction::HORIZONTAL)
|
||||||
{
|
{
|
||||||
newX = MAX(newX, min.x);
|
newX = MAX(newX, min.x);
|
||||||
newX = MIN(newX, max.x);
|
newX = MIN(newX, max.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_direction == kScrollViewDirectionBoth || _direction == kScrollViewDirectionVertical)
|
if (_direction == Direction::BOTH || _direction == Direction::VERTICAL)
|
||||||
{
|
{
|
||||||
newY = MIN(newY, max.y);
|
newY = MIN(newY, max.y);
|
||||||
newY = MAX(newY, min.y);
|
newY = MAX(newY, min.y);
|
||||||
|
@ -659,11 +659,11 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event)
|
||||||
moveDistance = newPoint - _touchPoint;
|
moveDistance = newPoint - _touchPoint;
|
||||||
|
|
||||||
float dis = 0.0f;
|
float dis = 0.0f;
|
||||||
if (_direction == kScrollViewDirectionVertical)
|
if (_direction == Direction::VERTICAL)
|
||||||
{
|
{
|
||||||
dis = moveDistance.y;
|
dis = moveDistance.y;
|
||||||
}
|
}
|
||||||
else if (_direction == kScrollViewDirectionHorizontal)
|
else if (_direction == Direction::HORIZONTAL)
|
||||||
{
|
{
|
||||||
dis = moveDistance.x;
|
dis = moveDistance.x;
|
||||||
}
|
}
|
||||||
|
@ -690,10 +690,10 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event)
|
||||||
{
|
{
|
||||||
switch (_direction)
|
switch (_direction)
|
||||||
{
|
{
|
||||||
case kScrollViewDirectionVertical:
|
case Direction::VERTICAL:
|
||||||
moveDistance = Point(0.0f, moveDistance.y);
|
moveDistance = Point(0.0f, moveDistance.y);
|
||||||
break;
|
break;
|
||||||
case kScrollViewDirectionHorizontal:
|
case Direction::HORIZONTAL:
|
||||||
moveDistance = Point(moveDistance.x, 0.0f);
|
moveDistance = Point(moveDistance.x, 0.0f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -36,13 +36,6 @@ NS_CC_EXT_BEGIN
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
kScrollViewDirectionNone = -1,
|
|
||||||
kScrollViewDirectionHorizontal = 0,
|
|
||||||
kScrollViewDirectionVertical,
|
|
||||||
kScrollViewDirectionBoth
|
|
||||||
} ScrollViewDirection;
|
|
||||||
|
|
||||||
class ScrollView;
|
class ScrollView;
|
||||||
|
|
||||||
class ScrollViewDelegate
|
class ScrollViewDelegate
|
||||||
|
@ -61,6 +54,13 @@ public:
|
||||||
class ScrollView : public Layer
|
class ScrollView : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum class Direction
|
||||||
|
{
|
||||||
|
NONE = -1,
|
||||||
|
HORIZONTAL = 0,
|
||||||
|
VERTICAL,
|
||||||
|
BOTH
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Returns an autoreleased scroll view object.
|
* Returns an autoreleased scroll view object.
|
||||||
*
|
*
|
||||||
|
@ -172,8 +172,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* direction allowed to scroll. ScrollViewDirectionBoth by default.
|
* direction allowed to scroll. ScrollViewDirectionBoth by default.
|
||||||
*/
|
*/
|
||||||
ScrollViewDirection getDirection() const { return _direction; }
|
Direction getDirection() const { return _direction; }
|
||||||
virtual void setDirection(ScrollViewDirection eDirection) { _direction = eDirection; }
|
virtual void setDirection(Direction eDirection) { _direction = eDirection; }
|
||||||
|
|
||||||
ScrollViewDelegate* getDelegate() { return _delegate; }
|
ScrollViewDelegate* getDelegate() { return _delegate; }
|
||||||
void setDelegate(ScrollViewDelegate* pDelegate) { _delegate = pDelegate; }
|
void setDelegate(ScrollViewDelegate* pDelegate) { _delegate = pDelegate; }
|
||||||
|
@ -254,7 +254,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
ScrollViewDelegate* _delegate;
|
ScrollViewDelegate* _delegate;
|
||||||
|
|
||||||
ScrollViewDirection _direction;
|
Direction _direction;
|
||||||
/**
|
/**
|
||||||
* If YES, the view is being dragged.
|
* If YES, the view is being dragged.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -56,8 +56,8 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/)
|
||||||
_cellsUsed = new ArrayForObjectSorting();
|
_cellsUsed = new ArrayForObjectSorting();
|
||||||
_cellsFreed = new ArrayForObjectSorting();
|
_cellsFreed = new ArrayForObjectSorting();
|
||||||
_indices = new std::set<unsigned int>();
|
_indices = new std::set<unsigned int>();
|
||||||
_vordering = kTableViewFillBottomUp;
|
_vordering = VerticalFillOrder::BOTTOM_UP;
|
||||||
this->setDirection(kScrollViewDirectionVertical);
|
this->setDirection(Direction::VERTICAL);
|
||||||
|
|
||||||
ScrollView::setDelegate(this);
|
ScrollView::setDelegate(this);
|
||||||
return true;
|
return true;
|
||||||
|
@ -66,13 +66,13 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
TableView::TableView()
|
TableView::TableView()
|
||||||
: _touchedCell(NULL)
|
: _touchedCell(nullptr)
|
||||||
, _indices(NULL)
|
, _indices(nullptr)
|
||||||
, _cellsUsed(NULL)
|
, _cellsUsed(nullptr)
|
||||||
, _cellsFreed(NULL)
|
, _cellsFreed(nullptr)
|
||||||
, _dataSource(NULL)
|
, _dataSource(nullptr)
|
||||||
, _tableViewDelegate(NULL)
|
, _tableViewDelegate(nullptr)
|
||||||
, _oldDirection(kScrollViewDirectionNone)
|
, _oldDirection(Direction::NONE)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ TableView::~TableView()
|
||||||
CC_SAFE_RELEASE(_cellsFreed);
|
CC_SAFE_RELEASE(_cellsFreed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::setVerticalFillOrder(TableViewVerticalFillOrder fillOrder)
|
void TableView::setVerticalFillOrder(VerticalFillOrder fillOrder)
|
||||||
{
|
{
|
||||||
if (_vordering != fillOrder) {
|
if (_vordering != fillOrder) {
|
||||||
_vordering = fillOrder;
|
_vordering = fillOrder;
|
||||||
|
@ -94,14 +94,14 @@ void TableView::setVerticalFillOrder(TableViewVerticalFillOrder fillOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TableViewVerticalFillOrder TableView::getVerticalFillOrder()
|
TableView::VerticalFillOrder TableView::getVerticalFillOrder()
|
||||||
{
|
{
|
||||||
return _vordering;
|
return _vordering;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::reloadData()
|
void TableView::reloadData()
|
||||||
{
|
{
|
||||||
_oldDirection = kScrollViewDirectionNone;
|
_oldDirection = Direction::NONE;
|
||||||
Object* pObj = NULL;
|
Object* pObj = NULL;
|
||||||
CCARRAY_FOREACH(_cellsUsed, pObj)
|
CCARRAY_FOREACH(_cellsUsed, pObj)
|
||||||
{
|
{
|
||||||
|
@ -276,7 +276,7 @@ void TableView::_updateContentSize()
|
||||||
|
|
||||||
switch (this->getDirection())
|
switch (this->getDirection())
|
||||||
{
|
{
|
||||||
case kScrollViewDirectionHorizontal:
|
case Direction::HORIZONTAL:
|
||||||
size = Size(maxPosition, _viewSize.height);
|
size = Size(maxPosition, _viewSize.height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -289,7 +289,7 @@ void TableView::_updateContentSize()
|
||||||
|
|
||||||
if (_oldDirection != _direction)
|
if (_oldDirection != _direction)
|
||||||
{
|
{
|
||||||
if (_direction == kScrollViewDirectionHorizontal)
|
if (_direction == Direction::HORIZONTAL)
|
||||||
{
|
{
|
||||||
this->setContentOffset(Point(0,0));
|
this->setContentOffset(Point(0,0));
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ Point TableView::_offsetFromIndex(unsigned int index)
|
||||||
Point offset = this->__offsetFromIndex(index);
|
Point offset = this->__offsetFromIndex(index);
|
||||||
|
|
||||||
const Size cellSize = _dataSource->tableCellSizeForIndex(this, 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;
|
offset.y = this->getContainer()->getContentSize().height - offset.y - cellSize.height;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ Point TableView::__offsetFromIndex(unsigned int index)
|
||||||
|
|
||||||
switch (this->getDirection())
|
switch (this->getDirection())
|
||||||
{
|
{
|
||||||
case kScrollViewDirectionHorizontal:
|
case Direction::HORIZONTAL:
|
||||||
offset = Point(_vCellsPositions[index], 0.0f);
|
offset = Point(_vCellsPositions[index], 0.0f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -337,7 +337,7 @@ unsigned int TableView::_indexFromOffset(Point offset)
|
||||||
int index = 0;
|
int index = 0;
|
||||||
const int maxIdx = _dataSource->numberOfCellsInTableView(this)-1;
|
const int maxIdx = _dataSource->numberOfCellsInTableView(this)-1;
|
||||||
|
|
||||||
if (_vordering == kTableViewFillTopDown)
|
if (_vordering == VerticalFillOrder::TOP_DOWN)
|
||||||
{
|
{
|
||||||
offset.y = this->getContainer()->getContentSize().height - offset.y;
|
offset.y = this->getContainer()->getContentSize().height - offset.y;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ int TableView::__indexFromOffset(Point offset)
|
||||||
float search;
|
float search;
|
||||||
switch (this->getDirection())
|
switch (this->getDirection())
|
||||||
{
|
{
|
||||||
case kScrollViewDirectionHorizontal:
|
case Direction::HORIZONTAL:
|
||||||
search = offset.x;
|
search = offset.x;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -433,7 +433,7 @@ void TableView::_updateCellPositions() {
|
||||||
cellSize = _dataSource->tableCellSizeForIndex(this, i);
|
cellSize = _dataSource->tableCellSizeForIndex(this, i);
|
||||||
switch (this->getDirection())
|
switch (this->getDirection())
|
||||||
{
|
{
|
||||||
case kScrollViewDirectionHorizontal:
|
case Direction::HORIZONTAL:
|
||||||
currentPos += cellSize.width;
|
currentPos += cellSize.width;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -462,7 +462,7 @@ void TableView::scrollViewDidScroll(ScrollView* view)
|
||||||
Point offset = this->getContentOffset() * -1;
|
Point offset = this->getContentOffset() * -1;
|
||||||
maxIdx = MAX(uCountOfItems-1, 0);
|
maxIdx = MAX(uCountOfItems-1, 0);
|
||||||
|
|
||||||
if (_vordering == kTableViewFillTopDown)
|
if (_vordering == VerticalFillOrder::TOP_DOWN)
|
||||||
{
|
{
|
||||||
offset.y = offset.y + _viewSize.height/this->getContainer()->getScaleY();
|
offset.y = offset.y + _viewSize.height/this->getContainer()->getScaleY();
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ void TableView::scrollViewDidScroll(ScrollView* view)
|
||||||
startIdx = uCountOfItems - 1;
|
startIdx = uCountOfItems - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_vordering == kTableViewFillTopDown)
|
if (_vordering == VerticalFillOrder::TOP_DOWN)
|
||||||
{
|
{
|
||||||
offset.y -= _viewSize.height/this->getContainer()->getScaleY();
|
offset.y -= _viewSize.height/this->getContainer()->getScaleY();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ NS_CC_EXT_BEGIN
|
||||||
class TableView;
|
class TableView;
|
||||||
class ArrayForObjectSorting;
|
class ArrayForObjectSorting;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
kTableViewFillTopDown,
|
|
||||||
kTableViewFillBottomUp
|
|
||||||
} TableViewVerticalFillOrder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sole purpose of this delegate is to single touch event in this version.
|
* Sole purpose of this delegate is to single touch event in this version.
|
||||||
*/
|
*/
|
||||||
|
@ -137,6 +132,12 @@ public:
|
||||||
class TableView : public ScrollView, public ScrollViewDelegate
|
class TableView : public ScrollView, public ScrollViewDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum class VerticalFillOrder
|
||||||
|
{
|
||||||
|
TOP_DOWN,
|
||||||
|
BOTTOM_UP
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* An intialized table view object
|
* An intialized table view object
|
||||||
*
|
*
|
||||||
|
@ -174,8 +175,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* determines how cell is ordered and filled in the view.
|
* determines how cell is ordered and filled in the view.
|
||||||
*/
|
*/
|
||||||
void setVerticalFillOrder(TableViewVerticalFillOrder order);
|
void setVerticalFillOrder(VerticalFillOrder order);
|
||||||
TableViewVerticalFillOrder getVerticalFillOrder();
|
VerticalFillOrder getVerticalFillOrder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the content of the cell at a given index.
|
* Updates the content of the cell at a given index.
|
||||||
|
@ -228,7 +229,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* vertical direction of cell filling
|
* vertical direction of cell filling
|
||||||
*/
|
*/
|
||||||
TableViewVerticalFillOrder _vordering;
|
VerticalFillOrder _vordering;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index set to query the indexes of the cells used.
|
* index set to query the indexes of the cells used.
|
||||||
|
@ -257,7 +258,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
TableViewDelegate* _tableViewDelegate;
|
TableViewDelegate* _tableViewDelegate;
|
||||||
|
|
||||||
ScrollViewDirection _oldDirection;
|
Direction _oldDirection;
|
||||||
|
|
||||||
int __indexFromOffset(Point offset);
|
int __indexFromOffset(Point offset);
|
||||||
unsigned int _indexFromOffset(Point offset);
|
unsigned int _indexFromOffset(Point offset);
|
||||||
|
|
|
@ -100,20 +100,19 @@ SIOClientImpl::SIOClientImpl(const std::string& host, int port) :
|
||||||
s << host << ":" << port;
|
s << host << ":" << port;
|
||||||
_uri = s.str();
|
_uri = s.str();
|
||||||
|
|
||||||
_ws = NULL;
|
_ws = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIOClientImpl::~SIOClientImpl() {
|
SIOClientImpl::~SIOClientImpl()
|
||||||
|
{
|
||||||
if(_connected) disconnect();
|
if (_connected) disconnect();
|
||||||
|
|
||||||
CC_SAFE_DELETE(_clients);
|
CC_SAFE_DELETE(_clients);
|
||||||
CC_SAFE_DELETE(_ws);
|
CC_SAFE_DELETE(_ws);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::handshake() {
|
void SIOClientImpl::handshake()
|
||||||
|
{
|
||||||
log("SIOClientImpl::handshake() called");
|
log("SIOClientImpl::handshake() called");
|
||||||
|
|
||||||
std::stringstream pre;
|
std::stringstream pre;
|
||||||
|
@ -135,8 +134,8 @@ void SIOClientImpl::handshake() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) {
|
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response)
|
||||||
|
{
|
||||||
log("SIOClientImpl::handshakeResponse() called");
|
log("SIOClientImpl::handshakeResponse() called");
|
||||||
|
|
||||||
if (0 != strlen(response->getHttpRequest()->getTag()))
|
if (0 != strlen(response->getHttpRequest()->getTag()))
|
||||||
|
@ -185,18 +184,21 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
|
||||||
int heartbeat = 0, timeout = 0;
|
int heartbeat = 0, timeout = 0;
|
||||||
|
|
||||||
pos = res.find(":");
|
pos = res.find(":");
|
||||||
if(pos >= 0) {
|
if(pos >= 0)
|
||||||
|
{
|
||||||
sid = res.substr(0, pos);
|
sid = res.substr(0, pos);
|
||||||
res.erase(0, pos+1);
|
res.erase(0, pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = res.find(":");
|
pos = res.find(":");
|
||||||
if(pos >= 0){
|
if(pos >= 0)
|
||||||
|
{
|
||||||
heartbeat = atoi(res.substr(pos+1, res.size()).c_str());
|
heartbeat = atoi(res.substr(pos+1, res.size()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = res.find(":");
|
pos = res.find(":");
|
||||||
if(pos >= 0){
|
if(pos >= 0)
|
||||||
|
{
|
||||||
timeout = atoi(res.substr(pos+1, res.size()).c_str());
|
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");
|
log("SIOClientImpl::openSocket() called");
|
||||||
|
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << _uri << "/socket.io/1/websocket/" << _sid;
|
s << _uri << "/socket.io/1/websocket/" << _sid;
|
||||||
|
|
||||||
_ws = new WebSocket();
|
_ws = new WebSocket();
|
||||||
if(!_ws->init(*this, s.str()))
|
if (!_ws->init(*this, s.str()))
|
||||||
{
|
{
|
||||||
CC_SAFE_DELETE(_ws);
|
CC_SAFE_DELETE(_ws);
|
||||||
}
|
}
|
||||||
|
@ -226,23 +228,21 @@ void SIOClientImpl::openSocket() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SIOClientImpl::init() {
|
bool SIOClientImpl::init()
|
||||||
|
{
|
||||||
log("SIOClientImpl::init() successful");
|
log("SIOClientImpl::init() successful");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::connect() {
|
void SIOClientImpl::connect()
|
||||||
|
{
|
||||||
this->handshake();
|
this->handshake();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::disconnect() {
|
void SIOClientImpl::disconnect()
|
||||||
|
{
|
||||||
if(_ws->getReadyState() == WebSocket::kStateOpen) {
|
if(_ws->getReadyState() == WebSocket::State::OPEN)
|
||||||
|
{
|
||||||
std::string s = "0::";
|
std::string s = "0::";
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
@ -250,7 +250,6 @@ void SIOClientImpl::disconnect() {
|
||||||
log("Disconnect sent");
|
log("Disconnect sent");
|
||||||
|
|
||||||
_ws->close();
|
_ws->close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Director::getInstance()->getScheduler()->unscheduleAllForTarget(this);
|
Director::getInstance()->getScheduler()->unscheduleAllForTarget(this);
|
||||||
|
@ -258,79 +257,71 @@ void SIOClientImpl::disconnect() {
|
||||||
_connected = false;
|
_connected = false;
|
||||||
|
|
||||||
SocketIO::instance()->removeSocket(_uri);
|
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);
|
SIOClientImpl *s = new SIOClientImpl(host, port);
|
||||||
|
|
||||||
if(s && s->init()) {
|
if (s && s->init())
|
||||||
|
{
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIOClient* SIOClientImpl::getClient(const std::string& endpoint) {
|
SIOClient* SIOClientImpl::getClient(const std::string& endpoint)
|
||||||
|
{
|
||||||
return static_cast<SIOClient*>(_clients->objectForKey(endpoint));
|
return static_cast<SIOClient*>(_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);
|
_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 path = endpoint == "/" ? "" : endpoint;
|
||||||
|
|
||||||
std::string s = "1::" + path;
|
std::string s = "1::" + path;
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) {
|
void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint)
|
||||||
|
{
|
||||||
_clients->removeObjectForKey(endpoint);
|
_clients->removeObjectForKey(endpoint);
|
||||||
|
|
||||||
if(_clients->count() == 0 || endpoint == "/") {
|
if(_clients->count() == 0 || endpoint == "/")
|
||||||
|
{
|
||||||
log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect");
|
log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect");
|
||||||
|
|
||||||
if(_connected) this->disconnect();
|
if(_connected) this->disconnect();
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
std::string path = endpoint == "/" ? "" : endpoint;
|
std::string path = endpoint == "/" ? "" : endpoint;
|
||||||
|
|
||||||
std::string s = "0::" + path;
|
std::string s = "0::" + path;
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::heartbeat(float dt) {
|
void SIOClientImpl::heartbeat(float dt)
|
||||||
|
{
|
||||||
std::string s = "2::";
|
std::string s = "2::";
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
|
||||||
log("Heartbeat sent");
|
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::stringstream pre;
|
||||||
|
|
||||||
std::string path = endpoint == "/" ? "" : endpoint;
|
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());
|
log("sending message: %s", msg.c_str());
|
||||||
|
|
||||||
_ws->send(msg);
|
_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::stringstream pre;
|
||||||
|
|
||||||
std::string path = endpoint == "/" ? "" : endpoint;
|
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());
|
log("emitting event with data: %s", msg.c_str());
|
||||||
|
|
||||||
_ws->send(msg);
|
_ws->send(msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) {
|
void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws)
|
||||||
|
{
|
||||||
_connected = true;
|
_connected = true;
|
||||||
|
|
||||||
SocketIO::instance()->addSocket(_uri, this);
|
SocketIO::instance()->addSocket(_uri, this);
|
||||||
|
|
||||||
DictElement* e = NULL;
|
DictElement* e = NULL;
|
||||||
|
|
||||||
CCDICT_FOREACH(_clients, e) {
|
CCDICT_FOREACH(_clients, e)
|
||||||
|
{
|
||||||
SIOClient *c = static_cast<SIOClient*>(e->getObject());
|
SIOClient *c = static_cast<SIOClient*>(e->getObject());
|
||||||
|
|
||||||
c->onOpen();
|
c->onOpen();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
|
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
|
||||||
|
|
||||||
log("SIOClientImpl::onOpen socket connected!");
|
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);
|
log("SIOClientImpl::onMessage received: %s", data.bytes);
|
||||||
|
|
||||||
int control = atoi(&data.bytes[0]);
|
int control = atoi(&data.bytes[0]);
|
||||||
|
@ -406,25 +393,26 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
|
||||||
payload.erase(0, pos+1);
|
payload.erase(0, pos+1);
|
||||||
|
|
||||||
pos = payload.find(":");
|
pos = payload.find(":");
|
||||||
if(pos >= 0) {
|
if(pos >= 0)
|
||||||
|
{
|
||||||
endpoint = payload.substr(0, pos);
|
endpoint = payload.substr(0, pos);
|
||||||
payload.erase(0, pos+1);
|
payload.erase(0, pos+1);
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
endpoint = payload;
|
endpoint = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(endpoint == "") endpoint = "/";
|
if (endpoint == "") endpoint = "/";
|
||||||
|
|
||||||
|
|
||||||
s_data = payload;
|
s_data = payload;
|
||||||
SIOClient *c = NULL;
|
SIOClient *c = NULL;
|
||||||
c = getClient(endpoint);
|
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:
|
case 0:
|
||||||
log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str());
|
log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str());
|
||||||
if(c) c->receivedDisconnect();
|
if(c) c->receivedDisconnect();
|
||||||
|
@ -448,11 +436,13 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
|
||||||
case 5:
|
case 5:
|
||||||
log("Event Received with data: %s \n", s_data.c_str());
|
log("Event Received with data: %s \n", s_data.c_str());
|
||||||
|
|
||||||
if(c) {
|
if(c)
|
||||||
|
{
|
||||||
eventname = "";
|
eventname = "";
|
||||||
pos = s_data.find(":");
|
pos = s_data.find(":");
|
||||||
pos2 = s_data.find(",");
|
pos2 = s_data.find(",");
|
||||||
if(pos2 > pos) {
|
if(pos2 > pos)
|
||||||
|
{
|
||||||
s_data = s_data.substr(pos+1, pos2-pos-1);
|
s_data = s_data.substr(pos+1, pos2-pos-1);
|
||||||
std::remove_copy(s_data.begin(), s_data.end(),
|
std::remove_copy(s_data.begin(), s_data.end(),
|
||||||
std::back_inserter(eventname), '"');
|
std::back_inserter(eventname), '"');
|
||||||
|
@ -477,29 +467,25 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::onClose(cocos2d::extension::WebSocket* ws) {
|
void SIOClientImpl::onClose(cocos2d::extension::WebSocket* ws)
|
||||||
|
{
|
||||||
if(_clients->count() > 0) {
|
if(_clients->count() > 0)
|
||||||
|
{
|
||||||
DictElement *e;
|
DictElement *e;
|
||||||
|
|
||||||
CCDICT_FOREACH(_clients, e) {
|
CCDICT_FOREACH(_clients, e)
|
||||||
|
{
|
||||||
SIOClient *c = static_cast<SIOClient *>(e->getObject());
|
SIOClient *c = static_cast<SIOClient *>(e->getObject());
|
||||||
|
|
||||||
c->receivedDisconnect();
|
c->receivedDisconnect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->release();
|
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
|
//begin SIOClient methods
|
||||||
|
@ -512,56 +498,58 @@ SIOClient::SIOClient(const std::string& host, int port, const std::string& path,
|
||||||
, _delegate(&delegate)
|
, _delegate(&delegate)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIOClient::~SIOClient(void) {
|
SIOClient::~SIOClient(void)
|
||||||
|
{
|
||||||
if(_connected) {
|
if (_connected)
|
||||||
|
{
|
||||||
_socket->disconnectFromEndpoint(_path);
|
_socket->disconnectFromEndpoint(_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::onOpen() {
|
void SIOClient::onOpen()
|
||||||
|
{
|
||||||
if(_path != "/") {
|
if (_path != "/")
|
||||||
|
{
|
||||||
_socket->connectToEndpoint(_path);
|
_socket->connectToEndpoint(_path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::onConnect() {
|
void SIOClient::onConnect()
|
||||||
|
{
|
||||||
_connected = true;
|
_connected = true;
|
||||||
_delegate->onConnect(this);
|
_delegate->onConnect(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::send(std::string s) {
|
void SIOClient::send(std::string s)
|
||||||
|
{
|
||||||
if(_connected) {
|
if (_connected)
|
||||||
|
{
|
||||||
_socket->send(_path, s);
|
_socket->send(_path, s);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_delegate->onError(this, "Client not yet connected");
|
_delegate->onError(this, "Client not yet connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::emit(std::string eventname, std::string args) {
|
void SIOClient::emit(std::string eventname, std::string args)
|
||||||
|
{
|
||||||
if(_connected) {
|
if(_connected)
|
||||||
|
{
|
||||||
_socket->emit(_path, eventname, args);
|
_socket->emit(_path, eventname, args);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_delegate->onError(this, "Client not yet connected");
|
_delegate->onError(this, "Client not yet connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::disconnect() {
|
void SIOClient::disconnect()
|
||||||
|
{
|
||||||
_connected = false;
|
_connected = false;
|
||||||
|
|
||||||
_socket->disconnectFromEndpoint(_path);
|
_socket->disconnectFromEndpoint(_path);
|
||||||
|
@ -569,31 +557,28 @@ void SIOClient::disconnect() {
|
||||||
_delegate->onClose(this);
|
_delegate->onClose(this);
|
||||||
|
|
||||||
this->release();
|
this->release();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::receivedDisconnect() {
|
void SIOClient::receivedDisconnect()
|
||||||
|
{
|
||||||
_connected = false;
|
_connected = false;
|
||||||
|
|
||||||
_delegate->onClose(this);
|
_delegate->onClose(this);
|
||||||
|
|
||||||
this->release();
|
this->release();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClient::on(const std::string& eventName, SIOEvent e) {
|
void SIOClient::on(const std::string& eventName, SIOEvent e)
|
||||||
|
{
|
||||||
_eventRegistry[eventName] = 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());
|
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];
|
SIOEvent e = _eventRegistry[eventName];
|
||||||
|
|
||||||
e(this, data);
|
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());
|
log("SIOClient::fireEvent no event with name %s found", eventName.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//begin SocketIO methods
|
//begin SocketIO methods
|
||||||
SocketIO *SocketIO::_inst = NULL;
|
SocketIO *SocketIO::_inst = nullptr;
|
||||||
|
|
||||||
SocketIO::SocketIO() {
|
|
||||||
|
|
||||||
|
SocketIO::SocketIO()
|
||||||
|
{
|
||||||
_sockets = Dictionary::create();
|
_sockets = Dictionary::create();
|
||||||
_sockets->retain();
|
_sockets->retain();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketIO::~SocketIO(void) {
|
SocketIO::~SocketIO(void)
|
||||||
|
{
|
||||||
CC_SAFE_DELETE(_sockets);
|
CC_SAFE_DELETE(_sockets);
|
||||||
delete _inst;
|
delete _inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketIO* SocketIO::instance() {
|
SocketIO* SocketIO::instance()
|
||||||
|
{
|
||||||
if(!_inst)
|
if(!_inst) _inst = new SocketIO();
|
||||||
_inst = new SocketIO();
|
|
||||||
|
|
||||||
return _inst;
|
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;
|
std::string host = uri;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
pos = host.find("//");
|
pos = host.find("//");
|
||||||
if(pos >= 0) {
|
if (pos >= 0)
|
||||||
|
{
|
||||||
host.erase(0, pos+2);
|
host.erase(0, pos+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = host.find(":");
|
pos = host.find(":");
|
||||||
if(pos >= 0){
|
if (pos >= 0)
|
||||||
|
{
|
||||||
port = atoi(host.substr(pos+1, host.size()).c_str());
|
port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = host.find("/", 0);
|
pos = host.find("/", 0);
|
||||||
std::string path = "/";
|
std::string path = "/";
|
||||||
if(pos >= 0){
|
if (pos >= 0)
|
||||||
|
{
|
||||||
path += host.substr(pos + 1, host.size());
|
path += host.substr(pos + 1, host.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = host.find(":");
|
pos = host.find(":");
|
||||||
if(pos >= 0){
|
if (pos >= 0)
|
||||||
|
{
|
||||||
host.erase(pos, host.size());
|
host.erase(pos, host.size());
|
||||||
}else if((pos = host.find("/"))>=0) {
|
}
|
||||||
|
else if ((pos = host.find("/"))>=0)
|
||||||
|
{
|
||||||
host.erase(pos, host.size());
|
host.erase(pos, host.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << host << ":" << port;
|
s << host << ":" << port;
|
||||||
|
|
||||||
SIOClientImpl* socket = NULL;
|
SIOClientImpl* socket = nullptr;
|
||||||
SIOClient *c = NULL;
|
SIOClient *c = nullptr;
|
||||||
|
|
||||||
socket = SocketIO::instance()->getSocket(s.str());
|
socket = SocketIO::instance()->getSocket(s.str());
|
||||||
|
|
||||||
if(socket == NULL) {
|
if(socket == nullptr)
|
||||||
|
{
|
||||||
//create a new socket, new client, connect
|
//create a new socket, new client, connect
|
||||||
socket = SIOClientImpl::create(host, port);
|
socket = SIOClientImpl::create(host, port);
|
||||||
|
|
||||||
|
@ -675,40 +664,37 @@ SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string&
|
||||||
socket->addClient(path, c);
|
socket->addClient(path, c);
|
||||||
|
|
||||||
socket->connect();
|
socket->connect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
} else {
|
|
||||||
//check if already connected to endpoint, handle
|
//check if already connected to endpoint, handle
|
||||||
c = socket->getClient(path);
|
c = socket->getClient(path);
|
||||||
|
|
||||||
if(c == NULL) {
|
if(c == NULL)
|
||||||
|
{
|
||||||
c = new SIOClient(host, port, path, socket, delegate);
|
c = new SIOClient(host, port, path, socket, delegate);
|
||||||
|
|
||||||
socket->addClient(path, c);
|
socket->addClient(path, c);
|
||||||
|
|
||||||
socket->connectToEndpoint(path);
|
socket->connectToEndpoint(path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIOClientImpl* SocketIO::getSocket(const std::string& uri) {
|
SIOClientImpl* SocketIO::getSocket(const std::string& uri)
|
||||||
|
{
|
||||||
return static_cast<SIOClientImpl*>(_sockets->objectForKey(uri));
|
return static_cast<SIOClientImpl*>(_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);
|
_sockets->setObject(socket, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketIO::removeSocket(const std::string& uri) {
|
void SocketIO::removeSocket(const std::string& uri)
|
||||||
|
{
|
||||||
_sockets->removeObjectForKey(uri);
|
_sockets->removeObjectForKey(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,14 +211,14 @@ enum WS_MSG {
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocket::WebSocket()
|
WebSocket::WebSocket()
|
||||||
: _readyState(kStateConnecting)
|
: _readyState(State::CONNECTING)
|
||||||
, _port(80)
|
, _port(80)
|
||||||
, _wsHelper(NULL)
|
, _wsHelper(nullptr)
|
||||||
, _wsInstance(NULL)
|
, _wsInstance(nullptr)
|
||||||
, _wsContext(NULL)
|
, _wsContext(nullptr)
|
||||||
, _delegate(NULL)
|
, _delegate(nullptr)
|
||||||
, _SSLConnection(0)
|
, _SSLConnection(0)
|
||||||
, _wsProtocols(NULL)
|
, _wsProtocols(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,8 @@ WebSocket::~WebSocket()
|
||||||
close();
|
close();
|
||||||
CC_SAFE_RELEASE_NULL(_wsHelper);
|
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[i].name);
|
||||||
}
|
}
|
||||||
CC_SAFE_DELETE_ARRAY(_wsProtocols);
|
CC_SAFE_DELETE_ARRAY(_wsProtocols);
|
||||||
|
@ -247,9 +248,7 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
|
|
||||||
//ws://
|
//ws://
|
||||||
pos = host.find("ws://");
|
pos = host.find("ws://");
|
||||||
if (pos == 0){
|
if (pos == 0) host.erase(0,5);
|
||||||
host.erase(0,5);
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = host.find("wss://");
|
pos = host.find("wss://");
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
|
@ -259,15 +258,11 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = host.find(":");
|
pos = host.find(":");
|
||||||
if(pos >= 0){
|
if (pos >= 0) port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||||
port = atoi(host.substr(pos+1, host.size()).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = host.find("/", 0);
|
pos = host.find("/", 0);
|
||||||
std::string path = "/";
|
std::string path = "/";
|
||||||
if(pos >= 0){
|
if (pos >= 0) path += host.substr(pos + 1, host.size());
|
||||||
path += host.substr(pos + 1, host.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = host.find(":");
|
pos = host.find(":");
|
||||||
if(pos >= 0){
|
if(pos >= 0){
|
||||||
|
@ -299,7 +294,8 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
if (protocols)
|
if (protocols)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (std::vector<std::string>::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i) {
|
for (std::vector<std::string>::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i)
|
||||||
|
{
|
||||||
char* name = new char[(*iter).length()+1];
|
char* name = new char[(*iter).length()+1];
|
||||||
strcpy(name, (*iter).c_str());
|
strcpy(name, (*iter).c_str());
|
||||||
_wsProtocols[i].name = name;
|
_wsProtocols[i].name = name;
|
||||||
|
@ -323,7 +319,7 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
|
|
||||||
void WebSocket::send(const std::string& message)
|
void WebSocket::send(const std::string& message)
|
||||||
{
|
{
|
||||||
if (_readyState == kStateOpen)
|
if (_readyState == State::OPEN)
|
||||||
{
|
{
|
||||||
// In main thread
|
// In main thread
|
||||||
WsMessage* msg = new WsMessage();
|
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)
|
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
|
// In main thread
|
||||||
WsMessage* msg = new WsMessage();
|
WsMessage* msg = new WsMessage();
|
||||||
|
@ -359,13 +355,13 @@ void WebSocket::close()
|
||||||
{
|
{
|
||||||
Director::getInstance()->getScheduler()->unscheduleAllForTarget(_wsHelper);
|
Director::getInstance()->getScheduler()->unscheduleAllForTarget(_wsHelper);
|
||||||
|
|
||||||
if (_readyState == kStateClosing || _readyState == kStateClosed)
|
if (_readyState == State::CLOSING || _readyState == State::CLOSED)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLOG("websocket (%p) connection closed by client", this);
|
CCLOG("websocket (%p) connection closed by client", this);
|
||||||
_readyState = kStateClosed;
|
_readyState = State::CLOSED;
|
||||||
|
|
||||||
_wsHelper->joinSubThread();
|
_wsHelper->joinSubThread();
|
||||||
|
|
||||||
|
@ -381,14 +377,14 @@ WebSocket::State WebSocket::getReadyState()
|
||||||
|
|
||||||
int WebSocket::onSubThreadLoop()
|
int WebSocket::onSubThreadLoop()
|
||||||
{
|
{
|
||||||
if (_readyState == kStateClosed || _readyState == kStateClosing)
|
if (_readyState == State::CLOSED || _readyState == State::CLOSING)
|
||||||
{
|
{
|
||||||
libwebsocket_context_destroy(_wsContext);
|
libwebsocket_context_destroy(_wsContext);
|
||||||
// return 1 to exit the loop.
|
// return 1 to exit the loop.
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_wsContext && _readyState != kStateClosed && _readyState != kStateClosing)
|
if (_wsContext && _readyState != State::CLOSED && _readyState != State::CLOSING)
|
||||||
{
|
{
|
||||||
libwebsocket_service(_wsContext, 0);
|
libwebsocket_service(_wsContext, 0);
|
||||||
}
|
}
|
||||||
|
@ -424,15 +420,15 @@ void WebSocket::onSubThreadStarted()
|
||||||
|
|
||||||
_wsContext = libwebsocket_create_context(&info);
|
_wsContext = libwebsocket_create_context(&info);
|
||||||
|
|
||||||
if(NULL != _wsContext){
|
if(nullptr != _wsContext)
|
||||||
_readyState = kStateConnecting;
|
{
|
||||||
|
_readyState = State::CONNECTING;
|
||||||
std::string name;
|
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);
|
name += (_wsProtocols[i].name);
|
||||||
if (_wsProtocols[i+1].callback != NULL)
|
|
||||||
{
|
if (_wsProtocols[i+1].callback != nullptr) name += ", ";
|
||||||
name += ", ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection,
|
_wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection,
|
||||||
_path.c_str(), _host.c_str(), _host.c_str(),
|
_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)
|
void *user, void *in, size_t len)
|
||||||
{
|
{
|
||||||
//CCLOG("socket callback for %d reason", reason);
|
//CCLOG("socket callback for %d reason", reason);
|
||||||
CCASSERT(_wsContext == NULL || ctx == _wsContext, "Invalid context.");
|
CCASSERT(_wsContext == nullptr || ctx == _wsContext, "Invalid context.");
|
||||||
CCASSERT(_wsInstance == NULL || wsi == NULL || wsi == _wsInstance, "Invaild websocket instance.");
|
CCASSERT(_wsInstance == nullptr || wsi == nullptr || wsi == _wsInstance, "Invaild websocket instance.");
|
||||||
|
|
||||||
switch (reason)
|
switch (reason)
|
||||||
{
|
{
|
||||||
|
@ -460,17 +456,17 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
case LWS_CALLBACK_PROTOCOL_DESTROY:
|
case LWS_CALLBACK_PROTOCOL_DESTROY:
|
||||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||||
{
|
{
|
||||||
WsMessage* msg = NULL;
|
WsMessage* msg = nullptr;
|
||||||
if (reason == LWS_CALLBACK_CLIENT_CONNECTION_ERROR
|
if (reason == LWS_CALLBACK_CLIENT_CONNECTION_ERROR
|
||||||
|| (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == kStateConnecting)
|
|| (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == State::CONNECTING)
|
||||||
|| (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == kStateConnecting)
|
|| (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == State::CONNECTING)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
msg = new WsMessage();
|
msg = new WsMessage();
|
||||||
msg->what = WS_MSG_TO_UITHREAD_ERROR;
|
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 = new WsMessage();
|
||||||
msg->what = WS_MSG_TO_UITHREAD_CLOSE;
|
msg->what = WS_MSG_TO_UITHREAD_CLOSE;
|
||||||
|
@ -486,7 +482,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
{
|
{
|
||||||
WsMessage* msg = new WsMessage();
|
WsMessage* msg = new WsMessage();
|
||||||
msg->what = WS_MSG_TO_UITHREAD_OPEN;
|
msg->what = WS_MSG_TO_UITHREAD_OPEN;
|
||||||
_readyState = kStateOpen;
|
_readyState = State::OPEN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* start the ball rolling,
|
* start the ball rolling,
|
||||||
* LWS_CALLBACK_CLIENT_WRITEABLE will come next service
|
* LWS_CALLBACK_CLIENT_WRITEABLE will come next service
|
||||||
|
@ -503,8 +500,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
std::list<WsMessage*>::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin();
|
std::list<WsMessage*>::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin();
|
||||||
|
|
||||||
int bytesWrite = 0;
|
int bytesWrite = 0;
|
||||||
for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter) {
|
for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter)
|
||||||
|
{
|
||||||
WsMessage* subThreadMsg = *iter;
|
WsMessage* subThreadMsg = *iter;
|
||||||
|
|
||||||
if ( WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what
|
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);
|
bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], data->len, writeProtocol);
|
||||||
|
|
||||||
if (bytesWrite < 0) {
|
if (bytesWrite < 0)
|
||||||
|
{
|
||||||
CCLOGERROR("%s", "libwebsocket_write error...");
|
CCLOGERROR("%s", "libwebsocket_write error...");
|
||||||
}
|
}
|
||||||
if (bytesWrite < data->len) {
|
if (bytesWrite < data->len)
|
||||||
|
{
|
||||||
CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n");
|
CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,10 +561,10 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
|
|
||||||
_wsHelper->quitSubThread();
|
_wsHelper->quitSubThread();
|
||||||
|
|
||||||
if (_readyState != kStateClosed)
|
if (_readyState != State::CLOSED)
|
||||||
{
|
{
|
||||||
WsMessage* msg = new WsMessage();
|
WsMessage* msg = new WsMessage();
|
||||||
_readyState = kStateClosed;
|
_readyState = State::CLOSED;
|
||||||
msg->what = WS_MSG_TO_UITHREAD_CLOSE;
|
msg->what = WS_MSG_TO_UITHREAD_CLOSE;
|
||||||
_wsHelper->sendMessageToUIThread(msg);
|
_wsHelper->sendMessageToUIThread(msg);
|
||||||
}
|
}
|
||||||
|
@ -637,7 +636,7 @@ void WebSocket::onUIThreadReceiveMessage(WsMessage* msg)
|
||||||
case WS_MSG_TO_UITHREAD_ERROR:
|
case WS_MSG_TO_UITHREAD_ERROR:
|
||||||
{
|
{
|
||||||
// FIXME: The exact error needs to be checked.
|
// FIXME: The exact error needs to be checked.
|
||||||
WebSocket::ErrorCode err = kErrorConnectionFailure;
|
WebSocket::ErrorCode err = ErrorCode::CONNECTION_FAILURE;
|
||||||
_delegate->onError(this, err);
|
_delegate->onError(this, err);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -63,11 +63,22 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Errors in websocket
|
* @brief Errors in websocket
|
||||||
*/
|
*/
|
||||||
enum ErrorCode
|
enum class ErrorCode
|
||||||
{
|
{
|
||||||
kErrorTimeout = 0,
|
TIME_OUT,
|
||||||
kErrorConnectionFailure,
|
CONNECTION_FAILURE,
|
||||||
kErrorUnknown
|
UNKNOWN,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Websocket state
|
||||||
|
*/
|
||||||
|
enum class State
|
||||||
|
{
|
||||||
|
CONNECTING,
|
||||||
|
OPEN,
|
||||||
|
CLOSING,
|
||||||
|
CLOSED,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,17 +121,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
/**
|
|
||||||
* Websocket state
|
|
||||||
*/
|
|
||||||
enum State
|
|
||||||
{
|
|
||||||
kStateConnecting = 0,
|
|
||||||
kStateOpen,
|
|
||||||
kStateClosing,
|
|
||||||
kStateClosed
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets current state of connection.
|
* @brief Gets current state of connection.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -87,7 +87,8 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \
|
||||||
../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \
|
../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \
|
||||||
../CCArmature/utils/CCTransformHelp.cpp \
|
../CCArmature/utils/CCTransformHelp.cpp \
|
||||||
../CCArmature/utils/CCTweenFunction.cpp \
|
../CCArmature/utils/CCTweenFunction.cpp \
|
||||||
../CCArmature/utils/CCUtilMath.cpp
|
../CCArmature/utils/CCUtilMath.cpp \
|
||||||
|
../CCDprecated-ext.cpp
|
||||||
|
|
||||||
include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk
|
include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,8 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \
|
||||||
../Components/CCComAttribute.cpp \
|
../Components/CCComAttribute.cpp \
|
||||||
../Components/CCComAudio.cpp \
|
../Components/CCComAudio.cpp \
|
||||||
../Components/CCComController.cpp \
|
../Components/CCComController.cpp \
|
||||||
../Components/CCInputDelegate.cpp
|
../Components/CCInputDelegate.cpp \
|
||||||
|
../CCDeprecated-ext.cpp
|
||||||
|
|
||||||
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
|
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,8 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \
|
||||||
../Components/CCComAttribute.cpp \
|
../Components/CCComAttribute.cpp \
|
||||||
../Components/CCComAudio.cpp \
|
../Components/CCComAudio.cpp \
|
||||||
../Components/CCComController.cpp \
|
../Components/CCComController.cpp \
|
||||||
../Components/CCInputDelegate.cpp
|
../Components/CCInputDelegate.cpp \
|
||||||
|
../CCDprecated-ext.cpp
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@
|
||||||
<ClCompile Include="..\CCBReader\CCScale9SpriteLoader.cpp" />
|
<ClCompile Include="..\CCBReader\CCScale9SpriteLoader.cpp" />
|
||||||
<ClCompile Include="..\CCBReader\CCScrollViewLoader.cpp" />
|
<ClCompile Include="..\CCBReader\CCScrollViewLoader.cpp" />
|
||||||
<ClCompile Include="..\CCBReader\CCSpriteLoader.cpp" />
|
<ClCompile Include="..\CCBReader\CCSpriteLoader.cpp" />
|
||||||
|
<ClCompile Include="..\CCDeprecated-ext.cpp" />
|
||||||
<ClCompile Include="..\Components\CCComAttribute.cpp" />
|
<ClCompile Include="..\Components\CCComAttribute.cpp" />
|
||||||
<ClCompile Include="..\Components\CCComAudio.cpp" />
|
<ClCompile Include="..\Components\CCComAudio.cpp" />
|
||||||
<ClCompile Include="..\Components\CCComController.cpp" />
|
<ClCompile Include="..\Components\CCComController.cpp" />
|
||||||
|
|
|
@ -357,6 +357,7 @@
|
||||||
<ClCompile Include="..\network\SocketIO.cpp">
|
<ClCompile Include="..\network\SocketIO.cpp">
|
||||||
<Filter>network</Filter>
|
<Filter>network</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\CCDeprecated-ext.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\GUI\CCScrollView\CCScrollView.h">
|
<ClInclude Include="..\GUI\CCScrollView\CCScrollView.h">
|
||||||
|
|
|
@ -204,12 +204,12 @@ void UpdateLayer::createDownloadedDir()
|
||||||
|
|
||||||
void UpdateLayer::onError(AssetsManager::ErrorCode errorCode)
|
void UpdateLayer::onError(AssetsManager::ErrorCode errorCode)
|
||||||
{
|
{
|
||||||
if (errorCode == AssetsManager::kNoNewVersion)
|
if (errorCode == AssetsManager::ErrorCode::NO_NEW_VERSION)
|
||||||
{
|
{
|
||||||
pProgressLabel->setString("no new version");
|
pProgressLabel->setString("no new version");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCode == AssetsManager::kNetwork)
|
if (errorCode == AssetsManager::ErrorCode::NETWORK)
|
||||||
{
|
{
|
||||||
pProgressLabel->setString("network error");
|
pProgressLabel->setString("network error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(Object * pTa
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) {
|
Control::Handler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) {
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonIdleClicked", AnimationsTestLayer::onControlButtonIdleClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonIdleClicked", AnimationsTestLayer::onControlButtonIdleClicked);
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonWaveClicked", AnimationsTestLayer::onControlButtonWaveClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonWaveClicked", AnimationsTestLayer::onControlButtonWaveClicked);
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonJumpClicked", AnimationsTestLayer::onControlButtonJumpClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonJumpClicked", AnimationsTestLayer::onControlButtonJumpClicked);
|
||||||
|
@ -39,18 +39,18 @@ void AnimationsTestLayer::setAnimationManager(cocos2d::extension::CCBAnimationMa
|
||||||
CC_SAFE_RETAIN(mAnimationManager);
|
CC_SAFE_RETAIN(mAnimationManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, ControlEvent pControlEvent) {
|
void AnimationsTestLayer::onControlButtonIdleClicked(Object *pSender, Control::EventType pControlEvent) {
|
||||||
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Idle", 0.3f);
|
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);
|
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);
|
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);
|
mAnimationManager->runAnimationsForSequenceNamedTweenDuration("Funky", 0.3f);
|
||||||
}
|
}
|
|
@ -16,13 +16,13 @@ public:
|
||||||
virtual ~AnimationsTestLayer();
|
virtual ~AnimationsTestLayer();
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||||
|
|
||||||
void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
|
|
||||||
void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager);
|
void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
Control::Handler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonClicked", ButtonTestLayer::onControlButtonClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonClicked", ButtonTestLayer::onControlButtonClicked);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -28,33 +28,33 @@ bool ButtonTestLayer::onAssignCCBMemberVariable(Object * pTarget, const char * p
|
||||||
return false;
|
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) {
|
switch(pControlEvent) {
|
||||||
case ControlEventTouchDown:
|
case Control::EventType::TOUCH_DOWN:
|
||||||
this->mControlEventLabel->setString("Touch Down.");
|
this->mControlEventLabel->setString("Touch Down.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchDragInside:
|
case Control::EventType::DRAG_INSIDE:
|
||||||
this->mControlEventLabel->setString("Touch Drag Inside.");
|
this->mControlEventLabel->setString("Touch Drag Inside.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchDragOutside:
|
case Control::EventType::DRAG_OUTSIDE:
|
||||||
this->mControlEventLabel->setString("Touch Drag Outside.");
|
this->mControlEventLabel->setString("Touch Drag Outside.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchDragEnter:
|
case Control::EventType::DRAG_ENTER:
|
||||||
this->mControlEventLabel->setString("Touch Drag Enter.");
|
this->mControlEventLabel->setString("Touch Drag Enter.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchDragExit:
|
case Control::EventType::DRAG_EXIT:
|
||||||
this->mControlEventLabel->setString("Touch Drag Exit.");
|
this->mControlEventLabel->setString("Touch Drag Exit.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchUpInside:
|
case Control::EventType::TOUCH_UP_INSIDE:
|
||||||
this->mControlEventLabel->setString("Touch Up Inside.");
|
this->mControlEventLabel->setString("Touch Up Inside.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchUpOutside:
|
case Control::EventType::TOUCH_UP_OUTSIDE:
|
||||||
this->mControlEventLabel->setString("Touch Up Outside.");
|
this->mControlEventLabel->setString("Touch Up Outside.");
|
||||||
break;
|
break;
|
||||||
case ControlEventTouchCancel:
|
case Control::EventType::TOUCH_CANCEL:
|
||||||
this->mControlEventLabel->setString("Touch Cancel.");
|
this->mControlEventLabel->setString("Touch Cancel.");
|
||||||
break;
|
break;
|
||||||
case ControlEventValueChanged:
|
case Control::EventType::VALUE_CHANGED:
|
||||||
this->mControlEventLabel->setString("Value Changed.");
|
this->mControlEventLabel->setString("Value Changed.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -16,10 +16,10 @@ public:
|
||||||
virtual ~ButtonTestLayer();
|
virtual ~ButtonTestLayer();
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||||
|
|
||||||
void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cocos2d::LabelBMFont * mControlEventLabel;
|
cocos2d::LabelBMFont * mControlEventLabel;
|
||||||
|
|
|
@ -72,7 +72,7 @@ SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(Object *
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked);
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked);
|
||||||
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked);
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked);
|
||||||
|
@ -126,19 +126,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) {
|
void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||||
this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) {
|
void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||||
this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) {
|
void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||||
this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) {
|
void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||||
|
|
||||||
/* Create an autorelease NodeLoaderLibrary. */
|
/* Create an autorelease NodeLoaderLibrary. */
|
||||||
NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
|
NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
|
||||||
|
@ -179,16 +179,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::e
|
||||||
//this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader());
|
//this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) {
|
void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent) {
|
||||||
this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent)
|
void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent)
|
||||||
{
|
{
|
||||||
this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent)
|
void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, cocos2d::extension::Control::EventType pControlEvent)
|
||||||
{
|
{
|
||||||
this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader());
|
this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,18 @@ class HelloCocosBuilderLayer
|
||||||
void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocos2d::extension::NodeLoader * nodeLoader = NULL);
|
void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocos2d::extension::NodeLoader * nodeLoader = NULL);
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||||
virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue);
|
virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue);
|
||||||
virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader);
|
virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader);
|
||||||
|
|
||||||
void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent);
|
void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cocos2d::Sprite * mBurstSprite;
|
cocos2d::Sprite * mBurstSprite;
|
||||||
|
|
|
@ -20,7 +20,7 @@ SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
Control::Handler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class MenuTestLayer
|
||||||
virtual ~MenuTestLayer();
|
virtual ~MenuTestLayer();
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||||
|
|
||||||
void onMenuItemAClicked(cocos2d::Object * sender);
|
void onMenuItemAClicked(cocos2d::Object * sender);
|
||||||
|
|
|
@ -9,7 +9,7 @@ SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
Control::Handler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TestHeaderLayer
|
||||||
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create);
|
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create);
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader);
|
virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader);
|
||||||
|
|
||||||
void onBackClicked(cocos2d::Object * sender);
|
void onBackClicked(cocos2d::Object * sender);
|
||||||
|
|
|
@ -18,7 +18,7 @@ SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(Object
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
Control::Handler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TimelineCallbackTestLayer
|
||||||
virtual ~TimelineCallbackTestLayer();
|
virtual ~TimelineCallbackTestLayer();
|
||||||
|
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||||
virtual cocos2d::SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName);
|
virtual cocos2d::SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@ ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(cons
|
||||||
titleButton->setColor(Color3B(159, 168, 176));
|
titleButton->setColor(Color3B(159, 168, 176));
|
||||||
|
|
||||||
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
||||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||||
button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,8 @@ bool ControlButtonTest_Event::init()
|
||||||
titleButton->setColor(Color3B(159, 168, 176));
|
titleButton->setColor(Color3B(159, 168, 176));
|
||||||
|
|
||||||
ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton);
|
ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton);
|
||||||
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||||
controlButton->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||||
|
|
||||||
controlButton->setAnchorPoint(Point(0.5f, 1));
|
controlButton->setAnchorPoint(Point(0.5f, 1));
|
||||||
controlButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
controlButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
||||||
|
@ -154,55 +154,55 @@ bool ControlButtonTest_Event::init()
|
||||||
addChild(background);
|
addChild(background);
|
||||||
|
|
||||||
// Sets up event handlers
|
// Sets up event handlers
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), ControlEventTouchDown);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDownAction), Control::EventType::TOUCH_DOWN);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), ControlEventTouchDragInside);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragInsideAction), Control::EventType::DRAG_INSIDE);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), ControlEventTouchDragOutside);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragOutsideAction), Control::EventType::DRAG_OUTSIDE);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), ControlEventTouchDragEnter);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragEnterAction), Control::EventType::DRAG_ENTER);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), ControlEventTouchDragExit);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchDragExitAction), Control::EventType::DRAG_EXIT);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), ControlEventTouchUpInside);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), ControlEventTouchUpOutside);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE);
|
||||||
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), ControlEventTouchCancel);
|
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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());
|
_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());
|
_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());
|
_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());
|
_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());
|
_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());
|
_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());
|
_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());
|
_displayValueLabel->setString(String::createWithFormat("Touch Cancel")->getCString());
|
||||||
}
|
}
|
||||||
|
@ -269,8 +269,8 @@ ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *ti
|
||||||
titleButton->setColor(Color3B(159, 168, 176));
|
titleButton->setColor(Color3B(159, 168, 176));
|
||||||
|
|
||||||
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
ControlButton *button = ControlButton::create(titleButton, backgroundButton);
|
||||||
button->setBackgroundSpriteForState(backgroundHighlightedButton, ControlStateHighlighted);
|
button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
|
||||||
button->setTitleColorForState(Color3B::WHITE, ControlStateHighlighted);
|
button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,14 @@ public:
|
||||||
ControlButtonTest_Event();
|
ControlButtonTest_Event();
|
||||||
~ControlButtonTest_Event();
|
~ControlButtonTest_Event();
|
||||||
bool init();
|
bool init();
|
||||||
void touchDownAction(Object *sender, ControlEvent controlEvent);
|
void touchDownAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchDragInsideAction(Object *sender, ControlEvent controlEvent);
|
void touchDragInsideAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchDragOutsideAction(Object *sender, ControlEvent controlEvent);
|
void touchDragOutsideAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchDragEnterAction(Object *sender, ControlEvent controlEvent);
|
void touchDragEnterAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchDragExitAction(Object *sender, ControlEvent controlEvent);
|
void touchDragExitAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchUpInsideAction(Object *sender, ControlEvent controlEvent);
|
void touchUpInsideAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchUpOutsideAction(Object *sender, ControlEvent controlEvent);
|
void touchUpOutsideAction(Object *sender, Control::EventType controlEvent);
|
||||||
void touchCancelAction(Object *sender, ControlEvent controlEvent);
|
void touchCancelAction(Object *sender, Control::EventType controlEvent);
|
||||||
protected:
|
protected:
|
||||||
CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel)
|
CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel)
|
||||||
CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event)
|
CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event)
|
||||||
|
|
|
@ -53,7 +53,7 @@ bool ControlColourPickerTest::init()
|
||||||
layer->addChild(colourPicker);
|
layer->addChild(colourPicker);
|
||||||
|
|
||||||
// Add the target-action pair
|
// 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;
|
layer_width += colourPicker->getContentSize().width;
|
||||||
|
@ -77,7 +77,7 @@ bool ControlColourPickerTest::init()
|
||||||
layer->setAnchorPoint(Point (0.5f, 0.5f));
|
layer->setAnchorPoint(Point (0.5f, 0.5f));
|
||||||
|
|
||||||
// Update the color text
|
// Update the color text
|
||||||
colourValueChanged(colourPicker, ControlEventValueChanged);
|
colourValueChanged(colourPicker, Control::EventType::VALUE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -89,7 +89,7 @@ ControlColourPickerTest::~ControlColourPickerTest()
|
||||||
CC_SAFE_RELEASE(_colorLabel);
|
CC_SAFE_RELEASE(_colorLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlColourPickerTest::colourValueChanged(Object *sender, ControlEvent controlEvent)
|
void ControlColourPickerTest::colourValueChanged(Object *sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlColourPicker* pPicker = (ControlColourPicker*)sender;
|
ControlColourPicker* pPicker = (ControlColourPicker*)sender;
|
||||||
_colorLabel->setString(String::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString());
|
_colorLabel->setString(String::createWithFormat("#%02X%02X%02X",pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b)->getCString());
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
virtual ~ControlColourPickerTest();
|
virtual ~ControlColourPickerTest();
|
||||||
bool init();
|
bool init();
|
||||||
/** Callback for the change value. */
|
/** Callback for the change value. */
|
||||||
void colourValueChanged(Object *sender, ControlEvent controlEvent);
|
void colourValueChanged(Object *sender, Control::EventType controlEvent);
|
||||||
|
|
||||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _colorLabel, ColorLabel)
|
CC_SYNTHESIZE_RETAIN(LabelTTF*, _colorLabel, ColorLabel)
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ bool ControlPotentiometerTest::init()
|
||||||
potentiometer->setPosition(Point(layer_width + 10 + potentiometer->getContentSize().width / 2, 0));
|
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
|
// 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);
|
layer->addChild(potentiometer);
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ bool ControlPotentiometerTest::init()
|
||||||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||||
|
|
||||||
// Update the value label
|
// Update the value label
|
||||||
this->valueChanged(potentiometer, ControlEventValueChanged);
|
this->valueChanged(potentiometer, Control::EventType::VALUE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPotentiometerTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
void ControlPotentiometerTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlPotentiometer* pControl = (ControlPotentiometer*)sender;
|
ControlPotentiometer* pControl = (ControlPotentiometer*)sender;
|
||||||
// Change value of label.
|
// Change value of label.
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
||||||
|
|
||||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||||
|
|
||||||
CONTROL_SCENE_CREATE_FUNC(ControlPotentiometerTest)
|
CONTROL_SCENE_CREATE_FUNC(ControlPotentiometerTest)
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,7 +58,7 @@ bool ControlSliderTest::init()
|
||||||
slider->setTag(1);
|
slider->setTag(1);
|
||||||
|
|
||||||
// When the value of the slider will change, the given selector will be call
|
// 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");
|
ControlSlider *restrictSlider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
|
||||||
restrictSlider->setAnchorPoint(Point(0.5f, 1.0f));
|
restrictSlider->setAnchorPoint(Point(0.5f, 1.0f));
|
||||||
|
@ -71,7 +71,7 @@ bool ControlSliderTest::init()
|
||||||
restrictSlider->setTag(2);
|
restrictSlider->setTag(2);
|
||||||
|
|
||||||
//same with restricted
|
//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(slider);
|
||||||
addChild(restrictSlider);
|
addChild(restrictSlider);
|
||||||
|
@ -80,7 +80,7 @@ bool ControlSliderTest::init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSliderTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
void ControlSliderTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlSlider* pSlider = (ControlSlider*)sender;
|
ControlSlider* pSlider = (ControlSlider*)sender;
|
||||||
// Change value of label.
|
// Change value of label.
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
ControlSliderTest();
|
ControlSliderTest();
|
||||||
virtual ~ControlSliderTest();
|
virtual ~ControlSliderTest();
|
||||||
bool init();
|
bool init();
|
||||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||||
protected:
|
protected:
|
||||||
LabelTTF* _displayValueLabel;
|
LabelTTF* _displayValueLabel;
|
||||||
CONTROL_SCENE_CREATE_FUNC(ControlSliderTest)
|
CONTROL_SCENE_CREATE_FUNC(ControlSliderTest)
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool ControlStepperTest::init()
|
||||||
|
|
||||||
ControlStepper *stepper = this->makeControlStepper();
|
ControlStepper *stepper = this->makeControlStepper();
|
||||||
stepper->setPosition(Point(layer_width + 10 + stepper->getContentSize().width / 2, 0));
|
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->addChild(stepper);
|
||||||
|
|
||||||
layer_width += stepper->getContentSize().width;
|
layer_width += stepper->getContentSize().width;
|
||||||
|
@ -73,7 +73,7 @@ bool ControlStepperTest::init()
|
||||||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||||
|
|
||||||
// Update the value label
|
// Update the value label
|
||||||
this->valueChanged(stepper, ControlEventValueChanged);
|
this->valueChanged(stepper, Control::EventType::VALUE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -87,7 +87,7 @@ ControlStepper *ControlStepperTest::makeControlStepper()
|
||||||
return ControlStepper::create(minusSprite, plusSprite);
|
return ControlStepper::create(minusSprite, plusSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlStepperTest::valueChanged(Object *sender, ControlEvent controlEvent)
|
void ControlStepperTest::valueChanged(Object *sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlStepper* pControl = (ControlStepper*)sender;
|
ControlStepper* pControl = (ControlStepper*)sender;
|
||||||
// Change value of label.
|
// Change value of label.
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
ControlStepper* makeControlStepper();
|
ControlStepper* makeControlStepper();
|
||||||
|
|
||||||
/** Callback for the change value. */
|
/** Callback for the change value. */
|
||||||
void valueChanged(Object *sender, ControlEvent controlEvent);
|
void valueChanged(Object *sender, Control::EventType controlEvent);
|
||||||
protected:
|
protected:
|
||||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
CC_SYNTHESIZE_RETAIN(LabelTTF*, _displayValueLabel, DisplayValueLabel)
|
||||||
CONTROL_SCENE_CREATE_FUNC(ControlStepperTest)
|
CONTROL_SCENE_CREATE_FUNC(ControlStepperTest)
|
||||||
|
|
|
@ -70,20 +70,20 @@ bool ControlSwitchTest::init()
|
||||||
switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0));
|
switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0));
|
||||||
layer->addChild(switchControl);
|
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
|
// Set the layer size
|
||||||
layer->setContentSize(Size(layer_width, 0));
|
layer->setContentSize(Size(layer_width, 0));
|
||||||
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
layer->setAnchorPoint(Point(0.5f, 0.5f));
|
||||||
|
|
||||||
// Update the value label
|
// Update the value label
|
||||||
valueChanged(switchControl, ControlEventValueChanged);
|
valueChanged(switchControl, Control::EventType::VALUE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSwitchTest::valueChanged(Object* sender, ControlEvent controlEvent)
|
void ControlSwitchTest::valueChanged(Object* sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlSwitch* pSwitch = (ControlSwitch*)sender;
|
ControlSwitch* pSwitch = (ControlSwitch*)sender;
|
||||||
if (pSwitch->isOn())
|
if (pSwitch->isOn())
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
virtual ~ControlSwitchTest();
|
virtual ~ControlSwitchTest();
|
||||||
bool init();
|
bool init();
|
||||||
/** Callback for the change value. */
|
/** Callback for the change value. */
|
||||||
void valueChanged(Object* sender, ControlEvent controlEvent);
|
void valueChanged(Object* sender, Control::EventType controlEvent);
|
||||||
LabelTTF *_displayValueLabel;
|
LabelTTF *_displayValueLabel;
|
||||||
CONTROL_SCENE_CREATE_FUNC(ControlSwitchTest)
|
CONTROL_SCENE_CREATE_FUNC(ControlSwitchTest)
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ EditBoxTest::EditBoxTest()
|
||||||
_editName->setPlaceHolder("Name:");
|
_editName->setPlaceHolder("Name:");
|
||||||
_editName->setPlaceholderFontColor(Color3B::WHITE);
|
_editName->setPlaceholderFontColor(Color3B::WHITE);
|
||||||
_editName->setMaxLength(8);
|
_editName->setMaxLength(8);
|
||||||
_editName->setReturnType(kKeyboardReturnTypeDone);
|
_editName->setReturnType(EditBox::KeyboardReturnType::DONE);
|
||||||
_editName->setDelegate(this);
|
_editName->setDelegate(this);
|
||||||
addChild(_editName);
|
addChild(_editName);
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ EditBoxTest::EditBoxTest()
|
||||||
_editPassword->setFontColor(Color3B::GREEN);
|
_editPassword->setFontColor(Color3B::GREEN);
|
||||||
_editPassword->setPlaceHolder("Password:");
|
_editPassword->setPlaceHolder("Password:");
|
||||||
_editPassword->setMaxLength(6);
|
_editPassword->setMaxLength(6);
|
||||||
_editPassword->setInputFlag(kEditBoxInputFlagPassword);
|
_editPassword->setInputFlag(EditBox::InputFlag::PASSWORD);
|
||||||
_editPassword->setInputMode(kEditBoxInputModeSingleLine);
|
_editPassword->setInputMode(EditBox::InputMode::SINGLE_LINE);
|
||||||
_editPassword->setDelegate(this);
|
_editPassword->setDelegate(this);
|
||||||
addChild(_editPassword);
|
addChild(_editPassword);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ EditBoxTest::EditBoxTest()
|
||||||
_editEmail->setPosition(Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4));
|
_editEmail->setPosition(Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4));
|
||||||
_editEmail->setAnchorPoint(Point(0.5, 1.0f));
|
_editEmail->setAnchorPoint(Point(0.5, 1.0f));
|
||||||
_editEmail->setPlaceHolder("Email:");
|
_editEmail->setPlaceHolder("Email:");
|
||||||
_editEmail->setInputMode(kEditBoxInputModeEmailAddr);
|
_editEmail->setInputMode(EditBox::InputMode::EMAIL_ADDRESS);
|
||||||
_editEmail->setDelegate(this);
|
_editEmail->setDelegate(this);
|
||||||
addChild(_editEmail);
|
addChild(_editEmail);
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
|
||||||
// Menu Callbacks
|
// Menu Callbacks
|
||||||
void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender)
|
void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender)
|
||||||
{
|
{
|
||||||
if (_wsiSendText->getReadyState() == WebSocket::kStateOpen)
|
if (_wsiSendText->getReadyState() == WebSocket::State::OPEN)
|
||||||
{
|
{
|
||||||
_sendTextStatus->setString("Send Text WS is waiting...");
|
_sendTextStatus->setString("Send Text WS is waiting...");
|
||||||
_wsiSendText->send("Hello WebSocket, I'm a text message.");
|
_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)
|
void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender)
|
||||||
{
|
{
|
||||||
if (_wsiSendBinary->getReadyState() == WebSocket::kStateOpen)
|
if (_wsiSendBinary->getReadyState() == WebSocket::State::OPEN)
|
||||||
{
|
{
|
||||||
_sendBinaryStatus->setString("Send Binary WS is waiting...");
|
_sendBinaryStatus->setString("Send Binary WS is waiting...");
|
||||||
char buf[] = "Hello WebSocket,\0 I'm\0 a\0 binary\0 message\0.";
|
char buf[] = "Hello WebSocket,\0 I'm\0 a\0 binary\0 message\0.";
|
||||||
|
|
|
@ -24,17 +24,17 @@ bool TableViewTestLayer::init()
|
||||||
Size winSize = Director::getInstance()->getWinSize();
|
Size winSize = Director::getInstance()->getWinSize();
|
||||||
|
|
||||||
TableView* tableView = TableView::create(this, Size(250, 60));
|
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->setPosition(Point(20,winSize.height/2-30));
|
||||||
tableView->setDelegate(this);
|
tableView->setDelegate(this);
|
||||||
this->addChild(tableView);
|
this->addChild(tableView);
|
||||||
tableView->reloadData();
|
tableView->reloadData();
|
||||||
|
|
||||||
tableView = TableView::create(this, Size(60, 250));
|
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->setPosition(Point(winSize.width-150,winSize.height/2-120));
|
||||||
tableView->setDelegate(this);
|
tableView->setDelegate(this);
|
||||||
tableView->setVerticalFillOrder(kTableViewFillTopDown);
|
tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
|
||||||
this->addChild(tableView);
|
this->addChild(tableView);
|
||||||
tableView->reloadData();
|
tableView->reloadData();
|
||||||
|
|
||||||
|
|
|
@ -865,7 +865,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl()
|
||||||
{
|
{
|
||||||
ControlSlider * slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
|
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->setMinimumValue(-3.0f);
|
||||||
slider->setMaximumValue(3.0f);
|
slider->setMaximumValue(3.0f);
|
||||||
|
@ -874,7 +874,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl()
|
||||||
return slider;
|
return slider;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SchedulerTimeScale::sliderAction(Object* sender, ControlEvent controlEvent)
|
void SchedulerTimeScale::sliderAction(Object* sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlSlider* pSliderCtl = static_cast<ControlSlider*>(sender);
|
ControlSlider* pSliderCtl = static_cast<ControlSlider*>(sender);
|
||||||
float scale;
|
float scale;
|
||||||
|
@ -953,7 +953,7 @@ ControlSlider *TwoSchedulers::sliderCtl()
|
||||||
// CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f);
|
// CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f);
|
||||||
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
|
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png");
|
||||||
//[[UISlider alloc] initWithFrame:frame];
|
//[[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
|
// in case the parent view draws with a custom color or gradient, use a transparent color
|
||||||
//slider.backgroundColor = [UIColor clearColor];
|
//slider.backgroundColor = [UIColor clearColor];
|
||||||
|
@ -966,7 +966,7 @@ ControlSlider *TwoSchedulers::sliderCtl()
|
||||||
return slider;
|
return slider;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoSchedulers::sliderAction(Object* sender, ControlEvent controlEvent)
|
void TwoSchedulers::sliderAction(Object* sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ public:
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
ControlSlider* sliderCtl();
|
ControlSlider* sliderCtl();
|
||||||
void sliderAction(Object* sender, ControlEvent controlEvent);
|
void sliderAction(Object* sender, Control::EventType controlEvent);
|
||||||
ControlSlider* _sliderCtl;
|
ControlSlider* _sliderCtl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ public:
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
void onEnter();
|
void onEnter();
|
||||||
ControlSlider* sliderCtl();
|
ControlSlider* sliderCtl();
|
||||||
void sliderAction(Object* sender, ControlEvent controlEvent);
|
void sliderAction(Object* sender, Control::EventType controlEvent);
|
||||||
Scheduler *sched1;
|
Scheduler *sched1;
|
||||||
Scheduler *sched2;
|
Scheduler *sched2;
|
||||||
ActionManager *actionManager1;
|
ActionManager *actionManager1;
|
||||||
|
|
|
@ -593,7 +593,7 @@ ControlSlider* ShaderBlur::createSliderCtl()
|
||||||
slider->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 3.0f));
|
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
|
// 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;
|
return slider;
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ bool ShaderBlur::init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderBlur::sliderAction(Object* sender, ControlEvent controlEvent)
|
void ShaderBlur::sliderAction(Object* sender, Control::EventType controlEvent)
|
||||||
{
|
{
|
||||||
ControlSlider* pSlider = (ControlSlider*)sender;
|
ControlSlider* pSlider = (ControlSlider*)sender;
|
||||||
_blurSprite->setBlurSize(pSlider->getValue());
|
_blurSprite->setBlurSize(pSlider->getValue());
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
ControlSlider* createSliderCtl();
|
ControlSlider* createSliderCtl();
|
||||||
void sliderAction(Object* sender, ControlEvent controlEvent);
|
void sliderAction(Object* sender, Control::EventType controlEvent);
|
||||||
protected:
|
protected:
|
||||||
SpriteBlur* _blurSprite;
|
SpriteBlur* _blurSprite;
|
||||||
ControlSlider* _sliderCtl;
|
ControlSlider* _sliderCtl;
|
||||||
|
|
|
@ -45,7 +45,7 @@ cc.KEYBOARD_RETURNTYPE_SEARCH = 3;
|
||||||
cc.KEYBOARD_RETURNTYPE_GO = 4;
|
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
|
* @constant
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,7 +29,7 @@ SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::
|
||||||
return menu_selector(CCBScriptCallbackProxy::menuItemCallback);
|
return menu_selector(CCBScriptCallbackProxy::menuItemCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget,
|
Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget,
|
||||||
const char * pSelectorName) {
|
const char * pSelectorName) {
|
||||||
|
|
||||||
this->callBackProp = pSelectorName;
|
this->callBackProp = pSelectorName;
|
||||||
|
@ -56,7 +56,7 @@ void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) {
|
||||||
ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() );
|
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() );
|
ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget,
|
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget,
|
||||||
const char * pSelectorName);
|
const char * pSelectorName);
|
||||||
|
|
||||||
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget,
|
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget,
|
||||||
const char * pSelectorName);
|
const char * pSelectorName);
|
||||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName,
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName,
|
||||||
cocos2d::Node * pNode);
|
cocos2d::Node * pNode);
|
||||||
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
virtual CCBSelectorResolver * createNew();
|
virtual CCBSelectorResolver * createNew();
|
||||||
void menuItemCallback(Object *pSender);
|
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 setCallbackProperty(const char *prop);
|
||||||
void setJSOwner(jsval ownr);
|
void setJSOwner(jsval ownr);
|
||||||
jsval getJSOwner();
|
jsval getJSOwner();
|
||||||
|
|
|
@ -365,13 +365,13 @@ void register_jsb_websocket(JSContext *cx, JSObject *global) {
|
||||||
|
|
||||||
JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()"));
|
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);
|
, 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);
|
, 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);
|
, 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);
|
, NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
||||||
|
|
||||||
// make the class enumerable in the registered namespace
|
// make the class enumerable in the registered namespace
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
fa9c4583d202c4fd4af5f97259eb3cac2bfbdec1
|
ab4c02a68cfeccde64ff6b990aba6925d8e7787d
|
|
@ -471,7 +471,7 @@ int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,3,0);
|
int controlevent = (int)tolua_tonumber(tolua_S,3,0);
|
||||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
if ((controlevent & (1 << i)))
|
if ((controlevent & (1 << i)))
|
||||||
|
@ -503,7 +503,7 @@ int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
|
||||||
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,2,0);
|
int controlevent = (int)tolua_tonumber(tolua_S,2,0);
|
||||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||||
{
|
{
|
||||||
if ((controlevent & (1 << i)))
|
if ((controlevent & (1 << i)))
|
||||||
|
|
|
@ -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);
|
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDirection'", NULL);
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ScrollViewDirection tolua_ret = (ScrollViewDirection) self->getDirection();
|
ScrollView::Direction tolua_ret = (ScrollView::Direction) self->getDirection();
|
||||||
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
|
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,7 @@ static int tolua_Cocos2d_ScrollView_setDirection00(lua_State* tolua_S)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0);
|
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
|
#ifndef TOLUA_RELEASE
|
||||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDirection'", NULL);
|
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDirection'", NULL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1562,10 +1562,10 @@ TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S)
|
||||||
tolua_reg_scrollview_type(tolua_S);
|
tolua_reg_scrollview_type(tolua_S);
|
||||||
tolua_module(tolua_S,NULL,0);
|
tolua_module(tolua_S,NULL,0);
|
||||||
tolua_beginmodule(tolua_S,NULL);
|
tolua_beginmodule(tolua_S,NULL);
|
||||||
tolua_constant(tolua_S,"kScrollViewDirectionNone",kScrollViewDirectionNone);
|
tolua_constant(tolua_S,"kScrollViewDirectionNone",(int)ScrollView::Direction::NONE);
|
||||||
tolua_constant(tolua_S,"kScrollViewDirectionHorizontal",kScrollViewDirectionHorizontal);
|
tolua_constant(tolua_S,"kScrollViewDirectionHorizontal",(int)ScrollView::Direction::HORIZONTAL);
|
||||||
tolua_constant(tolua_S,"kScrollViewDirectionVertical",kScrollViewDirectionVertical);
|
tolua_constant(tolua_S,"kScrollViewDirectionVertical",(int)ScrollView::Direction::VERTICAL);
|
||||||
tolua_constant(tolua_S,"kScrollViewDirectionBoth",kScrollViewDirectionBoth);
|
tolua_constant(tolua_S,"kScrollViewDirectionBoth",(int)ScrollView::Direction::BOTH);
|
||||||
tolua_constant(tolua_S,"kScrollViewScriptScroll",LuaScrollView::kScrollViewScriptScroll);
|
tolua_constant(tolua_S,"kScrollViewScriptScroll",LuaScrollView::kScrollViewScriptScroll);
|
||||||
tolua_constant(tolua_S,"kScrollViewScriptZoom",LuaScrollView::kScrollViewScriptZoom);
|
tolua_constant(tolua_S,"kScrollViewScriptZoom",LuaScrollView::kScrollViewScriptZoom);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue