mirror of https://github.com/axmolengine/axmol.git
issue #2430:use upper letters for enum item in Image
This commit is contained in:
parent
323af3c889
commit
b36a4f1df0
|
@ -50,7 +50,7 @@ public:
|
|||
Image();
|
||||
virtual ~Image();
|
||||
|
||||
enum Format
|
||||
typedef enum Format
|
||||
{
|
||||
FORMAT_JPG,
|
||||
FORMAT_PNG,
|
||||
|
@ -66,19 +66,29 @@ public:
|
|||
kFmtWebp = FORMAT_WEBP,
|
||||
kFmtRawData = FORMAT_RAW_DATA,
|
||||
kFmtUnKnown = FORMAT_UNKOWN
|
||||
};
|
||||
}EImageFormat;
|
||||
|
||||
typedef enum
|
||||
typedef enum TextAlign
|
||||
{
|
||||
kAlignCenter = 0x33, ///< Horizontal center and vertical center.
|
||||
kAlignTop = 0x13, ///< Horizontal center and vertical top.
|
||||
kAlignTopRight = 0x12, ///< Horizontal right and vertical top.
|
||||
kAlignRight = 0x32, ///< Horizontal right and vertical center.
|
||||
kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom.
|
||||
kAlignBottom = 0x23, ///< Horizontal center and vertical bottom.
|
||||
kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom.
|
||||
kAlignLeft = 0x31, ///< Horizontal left and vertical center.
|
||||
kAlignTopLeft = 0x11, ///< Horizontal left and vertical top.
|
||||
TEXT_ALIGN_CENTER = 0x33, ///< Horizontal center and vertical center.
|
||||
TEXT_ALIGN_TOP = 0x13, ///< Horizontal center and vertical top.
|
||||
TEXT_ALIGN_TOP_RIGHT = 0x12, ///< Horizontal right and vertical top.
|
||||
TEXT_ALIGN_RIGHT = 0x32, ///< Horizontal right and vertical center.
|
||||
TEXT_ALIGN_BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom.
|
||||
TEXT_ALIGN_BOTTOM = 0x23, ///< Horizontal center and vertical bottom.
|
||||
TEXT_ALIGN_BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom.
|
||||
TEXT_ALIGN_LEFT = 0x31, ///< Horizontal left and vertical center.
|
||||
TEXT_ALIGN_TOP_LEFT = 0x11, ///< Horizontal left and vertical top.
|
||||
|
||||
kAlignCenter = TEXT_ALIGN_CENTER,
|
||||
kAlignTop = TEXT_ALIGN_TOP,
|
||||
kAlignTopRight = TEXT_ALIGN_TOP_RIGHT,
|
||||
kAlignRight = TEXT_ALIGN_RIGHT,
|
||||
kAlignBottomRight = TEXT_ALIGN_BOTTOM_RIGHT,
|
||||
kAlignBottom = TEXT_ALIGN_BOTTOM,
|
||||
kAlignBottomLeft = TEXT_ALIGN_BOTTOM_LEFT,
|
||||
kAlignLeft = TEXT_ALIGN_LEFT,
|
||||
kAlignTopLeft = TEXT_ALIGN_TOP_LEFT,
|
||||
}ETextAlign;
|
||||
|
||||
/**
|
||||
|
@ -121,7 +131,7 @@ public:
|
|||
const char * pText,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
ETextAlign eAlignMask = kAlignCenter,
|
||||
TextAlign eAlignMask = TEXT_ALIGN_CENTER,
|
||||
const char * pFontName = 0,
|
||||
int nSize = 0);
|
||||
|
||||
|
@ -131,7 +141,7 @@ public:
|
|||
const char * pText,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
ETextAlign eAlignMask = kAlignCenter,
|
||||
TextAlign eAlignMask = TEXT_ALIGN_CENTER,
|
||||
const char * pFontName = 0,
|
||||
int nSize = 0,
|
||||
float textTintR = 1,
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
bool getBitmapFromJavaShadowStroke( const char *text,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
Image::ETextAlign eAlignMask,
|
||||
Image::TextAlign eAlignMask,
|
||||
const char * pFontName,
|
||||
float fontSize,
|
||||
float textTintR = 1.0,
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
{
|
||||
return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize );
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ bool Image::initWithString(
|
|||
const char * pText,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
||||
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||
const char * pFontName/* = nil*/,
|
||||
int nSize/* = 0*/)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ bool Image::initWithStringShadowStroke(
|
|||
const char * pText,
|
||||
int nWidth ,
|
||||
int nHeight ,
|
||||
ETextAlign eAlignMask ,
|
||||
TextAlign eAlignMask ,
|
||||
const char * pFontName ,
|
||||
int nSize ,
|
||||
float textTintR,
|
||||
|
|
|
@ -172,7 +172,7 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
|
|||
#define ALIGN_CENTER 3
|
||||
#define ALIGN_BOTTOM 2
|
||||
|
||||
static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo)
|
||||
static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
@ -543,7 +543,7 @@ bool Image::initWithString(
|
|||
const char * pText,
|
||||
int nWidth /* = 0 */,
|
||||
int nHeight /* = 0 */,
|
||||
ETextAlign eAlignMask /* = kAlignCenter */,
|
||||
TextAlign eAlignMask /* = kAlignCenter */,
|
||||
const char * pFontName /* = nil */,
|
||||
int nSize /* = 0 */)
|
||||
{
|
||||
|
@ -554,7 +554,7 @@ bool Image::initWithStringShadowStroke(
|
|||
const char * pText,
|
||||
int nWidth ,
|
||||
int nHeight ,
|
||||
ETextAlign eAlignMask ,
|
||||
TextAlign eAlignMask ,
|
||||
const char * pFontName ,
|
||||
int nSize ,
|
||||
float textTintR,
|
||||
|
|
|
@ -240,11 +240,11 @@ public:
|
|||
/**
|
||||
* compute the start pos of every line
|
||||
*/
|
||||
int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) {
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) {
|
||||
int lineWidth = textLines.at(line).lineWidth;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) {
|
||||
return (iMaxLineWidth - lineWidth) / 2;
|
||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT) {
|
||||
return (iMaxLineWidth - lineWidth);
|
||||
}
|
||||
|
||||
|
@ -252,12 +252,12 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) {
|
||||
//vertical center
|
||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT) {
|
||||
//vertical bottom
|
||||
return borderHeight - txtHeight + baseLinePos;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ public:
|
|||
return family_name;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
if (libError) {
|
||||
return false;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ bool Image::initWithString(
|
|||
const char * pText,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
||||
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||
const char * pFontName/* = nil*/,
|
||||
int nSize/* = 0*/)
|
||||
{
|
||||
|
|
|
@ -859,7 +859,7 @@ bool Image::initWithString(
|
|||
const char * pText,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
ETextAlign eAlignMask,
|
||||
TextAlign eAlignMask,
|
||||
const char * pFontName,
|
||||
int nSize)
|
||||
{
|
||||
|
|
|
@ -214,7 +214,7 @@ public:
|
|||
* while -1 means fail
|
||||
*
|
||||
*/
|
||||
int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, FT_UInt unicode,
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, FT_UInt unicode,
|
||||
int iLineIndex)
|
||||
{
|
||||
int iRet;
|
||||
|
@ -223,11 +223,11 @@ public:
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (eAlignMask == Image::kAlignCenter) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER) {
|
||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
|
||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||
|
||||
} else if (eAlignMask == Image::kAlignRight) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_RIGHT) {
|
||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
|
||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||
} else {
|
||||
|
@ -237,17 +237,17 @@ public:
|
|||
return iRet;
|
||||
}
|
||||
|
||||
int computeLineStartY(FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight)
|
||||
int computeLineStartY(FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight)
|
||||
{
|
||||
int iRet = 0;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft ||
|
||||
eAlignMask == Image::kAlignRight ) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT ||
|
||||
eAlignMask == Image::TEXT_ALIGN_RIGHT ) {
|
||||
//vertical center
|
||||
iRet = (borderHeight - txtHeight)/2;
|
||||
|
||||
} else if (eAlignMask == Image::kAlignBottomRight ||
|
||||
eAlignMask == Image::kAlignBottom ||
|
||||
eAlignMask == Image::kAlignBottomLeft ) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT ||
|
||||
eAlignMask == Image::TEXT_ALIGN_BOTTOM ||
|
||||
eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT ) {
|
||||
//vertical bottom
|
||||
iRet = borderHeight - txtHeight;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool renderLines(FT_Face face, Image::ETextAlign eAlignMask, int iCurYCursor)
|
||||
bool renderLines(FT_Face face, Image::TextAlign eAlignMask, int iCurYCursor)
|
||||
{
|
||||
size_t lines = vLines.size();
|
||||
for (size_t i = 0; i < lines; i++)
|
||||
|
@ -328,7 +328,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
{
|
||||
FT_Error iError;
|
||||
if (libError)
|
||||
|
|
|
@ -240,11 +240,11 @@ public:
|
|||
/**
|
||||
* compute the start pos of every line
|
||||
*/
|
||||
int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) {
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) {
|
||||
int lineWidth = textLines.at(line).lineWidth;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_TOP || eAlignMask == Image::TEXT_ALIGN_BOTTOM) {
|
||||
return (iMaxLineWidth - lineWidth) / 2;
|
||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_RIGHT || eAlignMask == Image::TEXT_ALIGN_TOP_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT) {
|
||||
return (iMaxLineWidth - lineWidth);
|
||||
}
|
||||
|
||||
|
@ -252,12 +252,12 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
||||
if (eAlignMask == Image::TEXT_ALIGN_CENTER || eAlignMask == Image::TEXT_ALIGN_LEFT || eAlignMask == Image::TEXT_ALIGN_RIGHT) {
|
||||
//vertical center
|
||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
||||
} else if (eAlignMask == Image::TEXT_ALIGN_BOTTOM_RIGHT || eAlignMask == Image::TEXT_ALIGN_BOTTOM || eAlignMask == Image::TEXT_ALIGN_BOTTOM_LEFT) {
|
||||
//vertical bottom
|
||||
return borderHeight - txtHeight + baseLinePos;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ public:
|
|||
return family_name;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
if (libError) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -459,22 +459,22 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
|||
#endif
|
||||
|
||||
bool bRet = false;
|
||||
Image::ETextAlign eAlign;
|
||||
Image::TextAlign eAlign;
|
||||
|
||||
if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_TOP_LEFT : Image::TEXT_ALIGN_TOP_RIGHT;
|
||||
}
|
||||
else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_CENTER
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_LEFT : Image::TEXT_ALIGN_RIGHT;
|
||||
}
|
||||
else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::TEXT_ALIGN_BOTTOM_LEFT : Image::TEXT_ALIGN_BOTTOM_RIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue