2013-07-23 02:17:51 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga Inc.
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
2013-07-23 02:17:51 +08:00
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
2013-07-27 07:04:21 +08:00
|
|
|
#ifndef _COCOS2D_CCLABEL_H_
|
|
|
|
#define _COCOS2D_CCLABEL_H_
|
2013-07-23 02:17:51 +08:00
|
|
|
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCSpriteBatchNode.h"
|
2013-08-08 07:36:04 +08:00
|
|
|
#include "ccTypes.h"
|
2014-01-04 10:56:14 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2014-01-22 14:57:11 +08:00
|
|
|
#include "CCFontAtlas.h"
|
2013-07-23 02:17:51 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
enum class GlyphCollection {
|
2013-07-27 07:04:21 +08:00
|
|
|
|
2013-07-23 02:17:51 +08:00
|
|
|
DYNAMIC,
|
|
|
|
NEHE,
|
|
|
|
ASCII,
|
|
|
|
CUSTOM
|
|
|
|
};
|
|
|
|
|
2013-12-13 12:42:15 +08:00
|
|
|
enum class LabelEffect {
|
|
|
|
|
|
|
|
NORMAL,
|
|
|
|
OUTLINE,
|
|
|
|
SHADOW,
|
|
|
|
GLOW
|
|
|
|
};
|
|
|
|
|
2014-01-11 22:33:07 +08:00
|
|
|
typedef struct _ttfConfig
|
|
|
|
{
|
|
|
|
std::string fontFilePath;
|
|
|
|
int fontSize;
|
|
|
|
GlyphCollection glyphs;
|
|
|
|
const char *customGlyphs;
|
2014-01-15 17:21:08 +08:00
|
|
|
bool distanceFieldEnabled;
|
2014-03-05 15:54:40 +08:00
|
|
|
int outlineSize;
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2014-03-13 18:46:35 +08:00
|
|
|
_ttfConfig(const char* filePath = "",int size = 12, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
|
2014-03-05 15:54:40 +08:00
|
|
|
const char *customGlyphCollection = nullptr,bool useDistanceField = false,int outline = 0)
|
2014-01-11 22:33:07 +08:00
|
|
|
:fontFilePath(filePath)
|
2014-01-16 16:37:29 +08:00
|
|
|
,fontSize(size)
|
|
|
|
,glyphs(glyphCollection)
|
|
|
|
,customGlyphs(customGlyphCollection)
|
2014-01-15 17:21:08 +08:00
|
|
|
,distanceFieldEnabled(useDistanceField)
|
2014-03-05 15:54:40 +08:00
|
|
|
,outlineSize(outline)
|
|
|
|
{
|
|
|
|
if(outline > 0)
|
|
|
|
{
|
|
|
|
distanceFieldEnabled = false;
|
|
|
|
}
|
|
|
|
}
|
2014-01-11 22:33:07 +08:00
|
|
|
}TTFConfig;
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2014-01-23 13:42:27 +08:00
|
|
|
class CC_DLL Label : public SpriteBatchNode, public LabelProtocol
|
2013-07-23 02:17:51 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-03-13 20:52:33 +08:00
|
|
|
static const int DistanceFieldFontSize;
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-01-11 22:33:07 +08:00
|
|
|
static Label* create();
|
|
|
|
|
2014-04-09 21:35:08 +08:00
|
|
|
/** Creates a label with an initial string,font[font name or font file],font size, dimension in points, horizontal alignment and vertical alignment.
|
2014-04-09 23:31:05 +08:00
|
|
|
* @warning It will generate texture by the platform-dependent code
|
2014-03-10 19:42:43 +08:00
|
|
|
*/
|
2014-04-09 23:31:05 +08:00
|
|
|
static Label* createWithSystemFont(const std::string& text, const std::string& font, float fontSize,
|
2014-03-10 19:42:43 +08:00
|
|
|
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
/** Creates a label with an initial string,font file,font size, dimension in points, horizontal alignment and vertical alignment.
|
|
|
|
* @warning Not support font name.
|
|
|
|
*/
|
|
|
|
static Label * createWithTTF(const std::string& text, const std::string& fontFile, float fontSize,
|
2014-03-10 19:42:43 +08:00
|
|
|
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
2014-04-09 21:35:08 +08:00
|
|
|
/** Create a label with TTF configuration
|
2014-04-09 23:31:05 +08:00
|
|
|
* @warning Not support font name.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2014-04-02 14:57:00 +08:00
|
|
|
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment = TextHAlignment::LEFT, int maxLineWidth = 0);
|
2013-07-23 05:43:45 +08:00
|
|
|
|
2014-04-09 21:35:08 +08:00
|
|
|
/* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/
|
2014-03-07 14:58:44 +08:00
|
|
|
static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,
|
2014-04-02 14:57:00 +08:00
|
|
|
const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0,
|
2014-04-15 18:08:29 +08:00
|
|
|
const Vector2& imageOffset = Vector2::ZERO);
|
2013-07-23 05:43:45 +08:00
|
|
|
|
2014-01-16 16:37:29 +08:00
|
|
|
static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
|
|
|
static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
|
|
|
static Label * createWithCharMap(const std::string& plistFile);
|
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
/** set TTF configuration for Label */
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setTTFConfig(const TTFConfig& ttfConfig);
|
2014-04-10 10:23:00 +08:00
|
|
|
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2014-04-15 18:08:29 +08:00
|
|
|
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset = Vector2::ZERO);
|
2014-03-17 18:33:15 +08:00
|
|
|
const std::string& getBMFontFilePath() const { return _bmFontPath;}
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
|
|
|
virtual bool setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
|
|
|
virtual bool setCharMap(const std::string& plistFile);
|
2014-01-16 16:37:29 +08:00
|
|
|
|
2014-04-10 10:23:00 +08:00
|
|
|
/* Sets the system font[font name or font file] of label*/
|
|
|
|
virtual void setSystemFontName(const std::string& systemFont);
|
|
|
|
virtual const std::string& getSystemFontName() const { return _systemFont;}
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2014-04-10 10:23:00 +08:00
|
|
|
/* Sets the system font size of label.*/
|
2014-04-09 23:31:05 +08:00
|
|
|
virtual void setSystemFontSize(float fontSize);
|
|
|
|
virtual float getSystemFontSize() const { return _systemFontSize;}
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
/** changes the string to render
|
2014-03-11 14:32:07 +08:00
|
|
|
* @warning It is as expensive as changing the string if you haven't set up TTF/BMFont/CharMap for the label.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2014-01-23 13:42:27 +08:00
|
|
|
virtual void setString(const std::string& text) override;
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
virtual const std::string& getString() const override { return _originalUTF8String; }
|
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
/**
|
|
|
|
* Enable shadow for the label
|
|
|
|
*
|
|
|
|
* @todo support blur for shadow effect
|
|
|
|
*/
|
2014-03-20 20:56:10 +08:00
|
|
|
virtual void enableShadow(const Color4B& shadowColor = Color4B::BLACK,const Size &offset = Size(2,-2), int blurRadius = 0);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
|
|
|
/** only support for TTF */
|
|
|
|
virtual void enableOutline(const Color4B& outlineColor,int outlineSize = -1);
|
|
|
|
|
|
|
|
/** only support for TTF */
|
2014-03-20 20:56:10 +08:00
|
|
|
virtual void enableGlow(const Color4B& glowColor);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
|
|
|
/** disable shadow/outline/glow rendering */
|
|
|
|
virtual void disableEffect();
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2014-03-10 20:35:36 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment);}
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment getTextAlignment() const { return _hAlignment;}
|
|
|
|
|
2014-03-11 14:32:07 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment,TextVAlignment vAlignment);
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2014-03-10 20:35:36 +08:00
|
|
|
void setHorizontalAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment); }
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment getHorizontalAlignment() const { return _hAlignment; }
|
2014-03-07 15:58:49 +08:00
|
|
|
|
2014-03-10 20:35:36 +08:00
|
|
|
void setVerticalAlignment(TextVAlignment vAlignment) { setAlignment(_hAlignment,vAlignment); }
|
2014-03-07 14:58:44 +08:00
|
|
|
TextVAlignment getVerticalAlignment() const { return _vAlignment; }
|
|
|
|
|
2014-03-11 14:32:07 +08:00
|
|
|
void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
2013-08-13 07:16:34 +08:00
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
/** Sets the max line width of the label.
|
|
|
|
* The label's max line width be used for force line breaks if the set value not equal zero.
|
|
|
|
* The label's width and max line width has not always to be equal.
|
|
|
|
*/
|
2014-03-11 14:32:07 +08:00
|
|
|
void setMaxLineWidth(unsigned int maxLineWidth);
|
2014-03-07 14:58:44 +08:00
|
|
|
unsigned int getMaxLineWidth() { return _maxLineWidth;}
|
|
|
|
|
|
|
|
/** Sets the untransformed size of the label.
|
|
|
|
* The label's width be used for text align if the set value not equal zero.
|
|
|
|
* The label's max line width will be equal to the same value.
|
|
|
|
*/
|
2014-03-10 20:35:36 +08:00
|
|
|
void setWidth(unsigned int width) { setDimensions(width,_labelHeight);}
|
2014-03-07 14:58:44 +08:00
|
|
|
unsigned int getWidth() const { return _labelWidth; }
|
|
|
|
|
|
|
|
/** Sets the untransformed size of the label.
|
|
|
|
* The label's height be used for text align if the set value not equal zero.
|
|
|
|
* The text will display of incomplete when the size of label not enough to support display all text.
|
|
|
|
*/
|
2014-03-10 20:35:36 +08:00
|
|
|
void setHeight(unsigned int height){ setDimensions(_labelWidth,height);}
|
2014-03-07 14:58:44 +08:00
|
|
|
unsigned int getHeight() const { return _labelHeight;}
|
|
|
|
|
|
|
|
/** Sets the untransformed size of the label in a more efficient way. */
|
2014-03-11 14:32:07 +08:00
|
|
|
void setDimensions(unsigned int width,unsigned int height);
|
|
|
|
const Size& getDimensions() const{ return _labelDimensions;}
|
|
|
|
|
2014-03-10 19:42:43 +08:00
|
|
|
/** update content immediately.*/
|
|
|
|
virtual void updateContent();
|
|
|
|
|
2014-03-20 20:56:10 +08:00
|
|
|
/** Sets the text color
|
|
|
|
*
|
|
|
|
*/
|
2014-03-31 11:16:12 +08:00
|
|
|
virtual void setTextColor(const Color4B &color);
|
2014-03-20 20:56:10 +08:00
|
|
|
|
|
|
|
const Color4B& getTextColor() const { return _textColor;}
|
|
|
|
|
2014-02-19 20:26:14 +08:00
|
|
|
virtual Sprite * getLetter(int lettetIndex);
|
|
|
|
|
2014-03-24 14:16:27 +08:00
|
|
|
/** clip upper and lower margin for reduce height of label.
|
|
|
|
*/
|
|
|
|
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
|
2014-03-25 16:37:34 +08:00
|
|
|
bool isClipMarginEnabled() const { return _clipEnabled; }
|
2013-08-08 07:36:04 +08:00
|
|
|
// font related stuff
|
2014-03-07 14:58:44 +08:00
|
|
|
int getCommonLineHeight() const;
|
2013-08-08 07:36:04 +08:00
|
|
|
|
|
|
|
// string related stuff
|
2014-03-10 20:35:36 +08:00
|
|
|
int getStringNumLines() const { return _currNumLines;}
|
2014-03-07 14:58:44 +08:00
|
|
|
int getStringLength() const;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
|
|
|
FontAtlas* getFontAtlas() { return _fontAtlas; }
|
2013-07-26 08:58:13 +08:00
|
|
|
|
2014-04-02 14:57:00 +08:00
|
|
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
|
|
|
|
|
|
|
virtual bool isOpacityModifyRGB() const override;
|
|
|
|
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
|
|
|
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
|
|
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
2013-12-13 06:30:22 +08:00
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
virtual void setScale(float scale) override;
|
|
|
|
virtual void setScaleX(float scaleX) override;
|
|
|
|
virtual void setScaleY(float scaleY) override;
|
|
|
|
virtual float getScaleX() const override;
|
|
|
|
virtual float getScaleY() const override;
|
|
|
|
|
|
|
|
virtual void addChild(Node * child, int zOrder=0, int tag=0) override;
|
2014-03-26 16:23:23 +08:00
|
|
|
virtual void sortAllChildren() override;
|
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
virtual std::string getDescription() const override;
|
2014-01-22 14:57:11 +08:00
|
|
|
|
2014-03-11 15:03:16 +08:00
|
|
|
virtual const Size& getContentSize() const override;
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2014-03-28 15:58:28 +08:00
|
|
|
virtual Rect getBoundingBox() const override;
|
2014-03-28 11:03:39 +08:00
|
|
|
|
2014-04-08 21:45:54 +08:00
|
|
|
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
2014-04-08 22:07:35 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2014-04-10 10:58:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
|
|
|
|
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2014-04-09 21:35:08 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
|
|
|
|
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
protected:
|
2014-04-09 10:06:30 +08:00
|
|
|
void onDraw(const Matrix& transform, bool transformUpdated);
|
2014-03-06 07:49:08 +08:00
|
|
|
|
2014-02-19 20:26:14 +08:00
|
|
|
struct LetterInfo
|
|
|
|
{
|
|
|
|
FontLetterDefinition def;
|
|
|
|
|
2014-04-15 18:08:29 +08:00
|
|
|
Vector2 position;
|
2014-02-19 20:26:14 +08:00
|
|
|
Size contentSize;
|
2014-03-17 18:33:15 +08:00
|
|
|
int atlasIndex;
|
2014-02-19 20:26:14 +08:00
|
|
|
};
|
2014-03-10 19:42:43 +08:00
|
|
|
enum class LabelType {
|
|
|
|
|
2014-03-10 20:35:36 +08:00
|
|
|
TTF,
|
|
|
|
BMFONT,
|
|
|
|
CHARMAP,
|
|
|
|
STRING_TEXTURE
|
2014-03-10 19:42:43 +08:00
|
|
|
};
|
|
|
|
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
2014-02-19 20:26:14 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2014-03-12 16:11:12 +08:00
|
|
|
Label(FontAtlas *atlas = nullptr, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP,bool useDistanceField = false,bool useA8Shader = false);
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
2014-02-19 20:26:14 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual ~Label();
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2014-03-13 20:52:33 +08:00
|
|
|
virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false);
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2014-04-15 18:08:29 +08:00
|
|
|
bool recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex);
|
2014-03-05 15:54:40 +08:00
|
|
|
bool recordPlaceholderInfo(int spriteIndex);
|
2014-02-19 20:26:14 +08:00
|
|
|
|
|
|
|
void setFontScale(float fontScale);
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual void alignText();
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2014-01-21 17:55:49 +08:00
|
|
|
bool computeHorizontalKernings(unsigned short int *stringToRender);
|
2013-08-08 07:36:04 +08:00
|
|
|
bool setCurrentString(unsigned short *stringToSet);
|
|
|
|
bool setOriginalString(unsigned short *stringToSet);
|
2014-02-10 11:21:54 +08:00
|
|
|
void computeStringNumLines();
|
2013-12-06 18:07:16 +08:00
|
|
|
|
2014-03-17 18:33:15 +08:00
|
|
|
void updateQuads();
|
2013-12-11 16:38:47 +08:00
|
|
|
|
|
|
|
virtual void updateColor() override;
|
|
|
|
|
2014-03-13 21:00:36 +08:00
|
|
|
virtual void updateShaderProgram();
|
2014-03-05 15:54:40 +08:00
|
|
|
|
|
|
|
void drawShadowWithoutBlur();
|
|
|
|
|
2014-03-26 11:09:16 +08:00
|
|
|
void drawTextSprite(Renderer *renderer, bool parentTransformUpdated);
|
|
|
|
|
2014-03-10 19:42:43 +08:00
|
|
|
void createSpriteWithFontDefinition();
|
|
|
|
|
2014-03-13 18:46:35 +08:00
|
|
|
void updateFont();
|
|
|
|
void reset();
|
|
|
|
|
2014-03-17 18:33:15 +08:00
|
|
|
std::string _bmFontPath;
|
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
bool _isOpacityModifyRGB;
|
2014-03-10 19:42:43 +08:00
|
|
|
bool _contentDirty;
|
2014-04-09 23:31:05 +08:00
|
|
|
|
2014-03-13 18:46:35 +08:00
|
|
|
bool _fontDirty;
|
2014-04-09 23:31:05 +08:00
|
|
|
std::string _systemFont;
|
|
|
|
float _systemFontSize;
|
2014-03-10 20:35:36 +08:00
|
|
|
LabelType _currentLabelType;
|
2014-03-07 14:58:44 +08:00
|
|
|
|
|
|
|
std::vector<SpriteBatchNode*> _batchNodes;
|
|
|
|
FontAtlas * _fontAtlas;
|
|
|
|
std::vector<LetterInfo> _lettersInfo;
|
|
|
|
|
|
|
|
TTFConfig _fontConfig;
|
|
|
|
|
2014-03-10 19:42:43 +08:00
|
|
|
//compatibility with older LabelTTF
|
|
|
|
Sprite* _textSprite;
|
|
|
|
FontDefinition _fontDefinition;
|
2014-04-14 13:42:37 +08:00
|
|
|
bool _compatibleMode;
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2013-10-29 20:25:03 +08:00
|
|
|
//! used for optimization
|
2014-01-17 13:35:58 +08:00
|
|
|
Sprite *_reusedLetter;
|
2014-02-19 20:26:14 +08:00
|
|
|
Rect _reusedRect;
|
2014-03-07 14:58:44 +08:00
|
|
|
int _limitShowCount;
|
2014-01-15 17:21:08 +08:00
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
float _commonLineHeight;
|
2014-02-19 20:26:14 +08:00
|
|
|
bool _lineBreakWithoutSpaces;
|
2014-03-07 14:58:44 +08:00
|
|
|
int * _horizontalKernings;
|
|
|
|
|
|
|
|
unsigned int _maxLineWidth;
|
2014-03-11 14:32:07 +08:00
|
|
|
Size _labelDimensions;
|
2014-03-07 14:58:44 +08:00
|
|
|
unsigned int _labelWidth;
|
|
|
|
unsigned int _labelHeight;
|
|
|
|
TextHAlignment _hAlignment;
|
|
|
|
TextVAlignment _vAlignment;
|
|
|
|
|
|
|
|
int _currNumLines;
|
2014-01-17 13:35:58 +08:00
|
|
|
unsigned short int * _currentUTF16String;
|
|
|
|
unsigned short int * _originalUTF16String;
|
2014-01-23 13:42:27 +08:00
|
|
|
std::string _originalUTF8String;
|
2014-03-07 14:58:44 +08:00
|
|
|
|
|
|
|
float _fontScale;
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
bool _useDistanceField;
|
|
|
|
bool _useA8Shader;
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
LabelEffect _currLabelEffect;
|
2014-03-20 20:56:10 +08:00
|
|
|
Color4B _effectColor;
|
|
|
|
Color4F _effectColorF;
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
GLuint _uniformEffectColor;
|
2014-03-20 20:56:10 +08:00
|
|
|
GLuint _uniformTextColor;
|
2014-03-07 14:58:44 +08:00
|
|
|
CustomCommand _customCommand;
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2014-03-31 18:16:08 +08:00
|
|
|
bool _shadowDirty;
|
2014-03-26 11:09:16 +08:00
|
|
|
bool _shadowEnabled;
|
2014-03-05 15:54:40 +08:00
|
|
|
Size _shadowOffset;
|
|
|
|
int _shadowBlurRadius;
|
2014-04-09 10:06:30 +08:00
|
|
|
Matrix _shadowTransform;
|
2014-03-26 11:09:16 +08:00
|
|
|
Color3B _shadowColor;
|
2014-04-01 14:15:35 +08:00
|
|
|
float _shadowOpacity;
|
2014-03-31 11:47:28 +08:00
|
|
|
Sprite* _shadowNode;
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-04-09 21:35:08 +08:00
|
|
|
int _outlineSize;
|
|
|
|
|
2014-03-20 20:56:10 +08:00
|
|
|
Color4B _textColor;
|
|
|
|
Color4F _textColorF;
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-03-24 14:16:27 +08:00
|
|
|
bool _clipEnabled;
|
2014-03-31 15:45:06 +08:00
|
|
|
bool _blendFuncDirty;
|
2014-04-26 10:00:22 +08:00
|
|
|
bool _insideBounds; /// whether or not the sprite was inside bounds the previous frame
|
2014-03-24 14:16:27 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
|
|
|
|
2014-02-19 20:26:14 +08:00
|
|
|
friend class LabelTextFormatter;
|
2013-07-23 02:17:51 +08:00
|
|
|
};
|
|
|
|
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2013-07-23 02:17:51 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /*__COCOS2D_CCLABEL_H */
|