2013-07-23 02:17:51 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga Inc.
|
2015-03-19 10:38:12 +08:00
|
|
|
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
2015-04-10 14:18:16 +08:00
|
|
|
|
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
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2015-08-04 21:49:14 +08:00
|
|
|
#include "renderer/CCQuadCommand.h"
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCFontAtlas.h"
|
2015-04-10 14:18:16 +08:00
|
|
|
#include "base/ccTypes.h"
|
2013-07-23 02:17:51 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2015-03-24 14:12:58 +08:00
|
|
|
* @addtogroup _2d
|
|
|
|
* @{
|
|
|
|
*/
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* @struct TTFConfig
|
2015-03-25 10:59:04 +08:00
|
|
|
* @see `GlyphCollection`
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2014-01-11 22:33:07 +08:00
|
|
|
typedef struct _ttfConfig
|
|
|
|
{
|
|
|
|
std::string fontFilePath;
|
2015-09-28 21:15:51 +08:00
|
|
|
float fontSize;
|
2015-03-25 10:59:04 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
GlyphCollection glyphs;
|
2014-01-11 22:33:07 +08:00
|
|
|
const char *customGlyphs;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
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
|
|
|
|
2016-01-20 12:41:31 +08:00
|
|
|
bool italics;
|
|
|
|
bool bold;
|
|
|
|
bool underline;
|
|
|
|
bool strikethrough;
|
|
|
|
|
2015-12-03 09:23:23 +08:00
|
|
|
_ttfConfig(const std::string& filePath = "",float size = 12, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
|
2016-01-20 12:41:31 +08:00
|
|
|
const char *customGlyphCollection = nullptr, bool useDistanceField = false, int outline = 0,
|
|
|
|
bool useItalics = false, bool useBold = false, bool useUnderline = false, bool useStrikethrough = false)
|
2015-12-03 09:23:23 +08:00
|
|
|
: fontFilePath(filePath)
|
|
|
|
, fontSize(size)
|
|
|
|
, glyphs(glyphCollection)
|
|
|
|
, customGlyphs(customGlyphCollection)
|
|
|
|
, distanceFieldEnabled(useDistanceField)
|
|
|
|
, outlineSize(outline)
|
2016-01-20 12:41:31 +08:00
|
|
|
, italics(useItalics)
|
|
|
|
, bold(useBold)
|
|
|
|
, underline(useUnderline)
|
|
|
|
, strikethrough(useStrikethrough)
|
2014-03-05 15:54:40 +08:00
|
|
|
{
|
|
|
|
if(outline > 0)
|
|
|
|
{
|
|
|
|
distanceFieldEnabled = false;
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 09:23:23 +08:00
|
|
|
} TTFConfig;
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
class Sprite;
|
|
|
|
class SpriteBatchNode;
|
2015-07-24 18:38:45 +08:00
|
|
|
class DrawNode;
|
|
|
|
class EventListenerCustom;
|
2015-07-07 14:20:23 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2015-07-08 15:30:34 +08:00
|
|
|
* @brief Label is a subclass of Node that knows how to render text labels.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* Label can be created with:
|
|
|
|
* - A true type font file.
|
|
|
|
* - A bitmap font file.
|
|
|
|
* - A char map file.
|
|
|
|
* - The built in system font.
|
|
|
|
*
|
|
|
|
* Bitmap Font supported editors:
|
|
|
|
* - http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
|
|
|
|
* - http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
|
|
|
|
* - http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
|
|
|
|
* - http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
2015-03-28 14:28:16 +08:00
|
|
|
* @js NA
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2015-07-08 15:30:34 +08:00
|
|
|
class CC_DLL Label : public Node, public LabelProtocol, public BlendProtocol
|
2013-07-23 02:17:51 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-11-19 16:06:13 +08:00
|
|
|
enum class Overflow
|
|
|
|
{
|
2016-01-04 21:43:37 +08:00
|
|
|
//In NONE mode, the dimensions is (0,0) and the content size will change dynamically to fit the label.
|
|
|
|
NONE,
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
*In CLAMP mode, when label content goes out of the bounding box, it will be clipped.
|
|
|
|
*/
|
|
|
|
CLAMP,
|
2016-01-04 21:43:37 +08:00
|
|
|
/**
|
|
|
|
* In SHRINK mode, the font size will change dynamically to adapt the content size.
|
|
|
|
*/
|
2016-01-05 10:20:05 +08:00
|
|
|
SHRINK,
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
*In RESIZE_HEIGHT mode, you can only change the width of label and the height is changed automatically.
|
|
|
|
*/
|
|
|
|
RESIZE_HEIGHT
|
|
|
|
};
|
2015-03-19 10:38:12 +08:00
|
|
|
/// @name Creators
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with default settings.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2014-01-11 22:33:07 +08:00
|
|
|
static Label* create();
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Allocates and initializes a Label, base on platform-dependent API.
|
|
|
|
*
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param font A font file or a font family name.
|
|
|
|
* @param fontSize The font size. This value must be > 0.
|
2015-04-10 14:18:16 +08:00
|
|
|
* @param dimensions
|
2015-03-19 10:38:12 +08:00
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param vAlignment The text vertical alignment.
|
|
|
|
*
|
|
|
|
* @warning It will generate texture by the platform-dependent code.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
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);
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, base on FreeType2.
|
|
|
|
*
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param fontFilePath A font file.
|
|
|
|
* @param fontSize The font size. This value must be > 0.
|
2015-04-10 14:18:16 +08:00
|
|
|
* @param dimensions
|
2015-03-19 10:38:12 +08:00
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param vAlignment The text vertical alignment.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
|
|
|
static Label * createWithTTF(const std::string& text, const std::string& fontFilePath, float fontSize,
|
2014-03-10 19:42:43 +08:00
|
|
|
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, base on FreeType2.
|
|
|
|
*
|
|
|
|
* @param ttfConfig A pointer to a TTFConfig object.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see TTFConfig setTTFConfig setMaxLineWidth
|
|
|
|
*/
|
2015-07-14 11:30:56 +08:00
|
|
|
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text,
|
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT, int maxLineWidth = 0);
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with a bitmap font file.
|
|
|
|
*
|
|
|
|
* @param bmfontPath A bitmap font file, it's a FNT format.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment Text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
2015-04-10 14:18:16 +08:00
|
|
|
* @param imageOffset
|
2015-03-19 10:38:12 +08:00
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see setBMFontFilePath setMaxLineWidth
|
|
|
|
*/
|
|
|
|
static Label* createWithBMFont(const std::string& bmfontPath, const std::string& text,
|
|
|
|
const TextHAlignment& hAlignment = TextHAlignment::LEFT, int maxLineWidth = 0,
|
2014-05-15 01:07:09 +08:00
|
|
|
const Vec2& imageOffset = Vec2::ZERO);
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param charMapFile A char map file, it's a PNG format.
|
|
|
|
* @param itemWidth The width in points of each element.
|
|
|
|
* @param itemHeight The height in points of each element.
|
|
|
|
* @param startCharMap The starting char of the char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2014-01-16 16:37:29 +08:00
|
|
|
static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param texture A pointer to an existing Texture2D object.
|
|
|
|
* @param itemWidth The width in points of each element.
|
|
|
|
* @param itemHeight The height in points of each element.
|
|
|
|
* @param startCharMap The starting char of the char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2014-01-16 16:37:29 +08:00
|
|
|
static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param plistFile A configuration file of char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2014-01-16 16:37:29 +08:00
|
|
|
static Label * createWithCharMap(const std::string& plistFile);
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
// end of creators group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
/// @{
|
|
|
|
/// @name Font methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a new TTF configuration to Label.
|
|
|
|
* @see `TTFConfig`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setTTFConfig(const TTFConfig& ttfConfig);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the TTF configuration object used by the Label.
|
|
|
|
* @see `TTFConfig`
|
|
|
|
*/
|
2014-04-10 10:23:00 +08:00
|
|
|
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets a new bitmap font to Label */
|
2015-11-19 16:06:13 +08:00
|
|
|
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO, float fontSize = 0);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the bitmap font used by the Label.*/
|
2014-03-17 18:33:15 +08:00
|
|
|
const std::string& getBMFontFilePath() const { return _bmFontPath;}
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Sets a new char map configuration to Label.
|
|
|
|
*
|
|
|
|
* @see `createWithCharMap(const std::string&,int,int,int)`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a new char map configuration to Label.
|
|
|
|
*
|
|
|
|
* @see `createWithCharMap(Texture2D*,int,int,int)`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
2015-04-10 14:18:16 +08:00
|
|
|
* Sets a new char map configuration to Label.
|
2015-03-19 10:38:12 +08:00
|
|
|
*
|
|
|
|
* @see `createWithCharMap(const std::string&)`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setCharMap(const std::string& plistFile);
|
2014-01-16 16:37:29 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Sets a new system font to Label.
|
|
|
|
*
|
|
|
|
* @param font A font file or a font family name.
|
|
|
|
* @warning
|
|
|
|
*/
|
|
|
|
virtual void setSystemFontName(const std::string& font);
|
|
|
|
|
|
|
|
/** Returns the system font used by the Label.*/
|
2014-04-10 10:23:00 +08:00
|
|
|
virtual const std::string& getSystemFontName() const { return _systemFont;}
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/* Sets the system font size of Label.*/
|
2014-04-09 23:31:05 +08:00
|
|
|
virtual void setSystemFontSize(float fontSize);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the bitmap font path used by the Label.*/
|
2014-04-09 23:31:05 +08:00
|
|
|
virtual float getSystemFontSize() const { return _systemFontSize;}
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* @warning This method is not recommended for game developers.
|
|
|
|
*/
|
2014-10-09 18:28:09 +08:00
|
|
|
virtual void requestSystemFontRefresh() { _systemFontDirty = true;}
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
// end of font methods
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
/** Sets the text that this Label is to display.*/
|
2014-01-23 13:42:27 +08:00
|
|
|
virtual void setString(const std::string& text) override;
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Return the text the Label is displaying.*/
|
2015-07-24 18:38:45 +08:00
|
|
|
virtual const std::string& getString() const override { return _utf8Text; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
/**
|
|
|
|
* Return the number of lines of text.
|
|
|
|
*/
|
|
|
|
int getStringNumLines();
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
/**
|
|
|
|
* Return length of string.
|
|
|
|
*/
|
|
|
|
int getStringLength();
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Sets the text color of Label.
|
|
|
|
*
|
|
|
|
* The text color is different from the color of Node.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
|
|
|
* @warning Limiting use to only when the Label created with true type font or system font.
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
virtual void setTextColor(const Color4B &color);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the text color of the Label.*/
|
2014-06-12 12:01:15 +08:00
|
|
|
const Color4B& getTextColor() const { return _textColor;}
|
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Enable shadow effect to Label.
|
2014-03-05 15:54:40 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* @todo Support blur for shadow effect.
|
2014-03-05 15:54:40 +08:00
|
|
|
*/
|
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
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Enable outline effect to Label.
|
|
|
|
* @warning Limiting use to only when the Label created with true type font or system font.
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual void enableOutline(const Color4B& outlineColor,int outlineSize = -1);
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Enable glow effect to Label.
|
|
|
|
* @warning Limiting use to only when the Label created with true type font.
|
|
|
|
*/
|
2014-03-20 20:56:10 +08:00
|
|
|
virtual void enableGlow(const Color4B& glowColor);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2016-01-20 12:41:31 +08:00
|
|
|
/**
|
|
|
|
* Enable italics rendering
|
|
|
|
*/
|
|
|
|
void enableItalics();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable bold rendering
|
|
|
|
*/
|
|
|
|
void enableBold();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable underline
|
|
|
|
*/
|
|
|
|
void enableUnderline();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables strikethrough.
|
|
|
|
* Underline and Strikethrough cannot be enabled at the same time.
|
|
|
|
* Strikethough is like an underline but at the middle of the glyph
|
|
|
|
*/
|
|
|
|
void enableStrikethrough();
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Disable all effect to Label.
|
2015-04-17 14:39:52 +08:00
|
|
|
* @warning Please use disableEffect(LabelEffect::ALL) instead of this API.
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual void disableEffect();
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-04-07 15:51:57 +08:00
|
|
|
/**
|
|
|
|
* Disable effect to Label.
|
|
|
|
*
|
|
|
|
* @see `LabelEffect`
|
|
|
|
*/
|
|
|
|
virtual void disableEffect(LabelEffect effect);
|
|
|
|
|
2015-12-11 12:04:54 +08:00
|
|
|
/**
|
|
|
|
* Return whether the shadow effect is enabled.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
bool isShadowEnabled() const { return _shadowEnabled; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return shadow effect offset value.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
Size getShadowOffset() const { return _shadowOffset; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the shadow effect blur radius.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
float getShadowBlurRadius() const { return _shadowBlurRadius; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the shadow effect color value.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
Color4F getShadowColor() const { return _shadowColor4F; }
|
|
|
|
|
2015-12-11 12:04:54 +08:00
|
|
|
/**
|
|
|
|
* Return the outline effect size value.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
int getOutlineSize() const { return _outlineSize; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return current effect type.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
LabelEffect getLabelEffectType() const { return _currLabelEffect; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2016-01-11 18:15:34 +08:00
|
|
|
* Return current effect color value.
|
2015-12-11 12:04:54 +08:00
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
Color4F getEffectColor() const { return _effectColorF; }
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text horizontal alignment.*/
|
2014-03-10 20:35:36 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment);}
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text horizontal alignment.*/
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment getTextAlignment() const { return _hAlignment;}
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text alignment.*/
|
2014-03-11 14:32:07 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment,TextVAlignment vAlignment);
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text horizontal alignment.*/
|
2014-03-10 20:35:36 +08:00
|
|
|
void setHorizontalAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment); }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text horizontal alignment.*/
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment getHorizontalAlignment() const { return _hAlignment; }
|
2014-03-07 15:58:49 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text vertical alignment.*/
|
2014-03-10 20:35:36 +08:00
|
|
|
void setVerticalAlignment(TextVAlignment vAlignment) { setAlignment(_hAlignment,vAlignment); }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text vertical alignment.*/
|
2014-03-07 14:58:44 +08:00
|
|
|
TextVAlignment getVerticalAlignment() const { return _vAlignment; }
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Specify what happens when a line is too long for Label.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* @param breakWithoutSpace Lines are automatically broken between words if this value is false.
|
|
|
|
*/
|
2014-03-11 14:32:07 +08:00
|
|
|
void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
2013-08-13 07:16:34 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Makes the Label at most this line untransformed width.
|
|
|
|
* The Label's max line width be used for force line breaks if the value not equal zero.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2015-01-20 11:46:43 +08:00
|
|
|
void setMaxLineWidth(float maxLineWidth);
|
|
|
|
float getMaxLineWidth() { return _maxLineWidth; }
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
* Change font size of label type BMFONT
|
|
|
|
* Note: This function only scale the BMFONT letter to mimic the font size change effect.
|
|
|
|
*
|
|
|
|
* @param fontSize The desired font size in float.
|
|
|
|
*/
|
|
|
|
void setBMFontSize(float fontSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the user define BMFont size.
|
|
|
|
*
|
|
|
|
* @return The BMFont size in float value.
|
|
|
|
*/
|
|
|
|
float getBMFontSize()const;
|
|
|
|
|
|
|
|
/**
|
2015-11-20 10:54:05 +08:00
|
|
|
* Toggle wrap option of the label.
|
2015-11-19 16:06:13 +08:00
|
|
|
* Note: System font doesn't support manually toggle wrap.
|
|
|
|
*
|
|
|
|
* @param enable Set true to enable wrap and false to disable wrap.
|
|
|
|
*/
|
|
|
|
void enableWrap(bool enable);
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
* Query the wrap is enabled or not.
|
|
|
|
* Note: System font will always return true.
|
|
|
|
*/
|
|
|
|
bool isWrapEnabled()const;
|
|
|
|
|
|
|
|
/**
|
2015-11-20 10:54:05 +08:00
|
|
|
* Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type.
|
|
|
|
* Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size.
|
|
|
|
* System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT.
|
2015-11-19 16:06:13 +08:00
|
|
|
*
|
|
|
|
* @param overflow see `Overflow`
|
|
|
|
*/
|
|
|
|
void setOverflow(Overflow overflow);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the label's Overflow type.
|
|
|
|
*
|
|
|
|
* @return see `Overflow`
|
|
|
|
*/
|
|
|
|
Overflow getOverflow()const;
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Makes the Label exactly this untransformed width.
|
|
|
|
*
|
|
|
|
* The Label's width be used for text align if the value not equal zero.
|
2015-11-19 16:06:13 +08:00
|
|
|
*/
|
2015-01-20 11:46:43 +08:00
|
|
|
void setWidth(float width) { setDimensions(width,_labelHeight);}
|
|
|
|
float getWidth() const { return _labelWidth; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Makes the Label exactly this untransformed height.
|
|
|
|
*
|
|
|
|
* The Label's height be used for text align if the value not equal zero.
|
|
|
|
* The text will display of incomplete when the size of Label not enough to support display all text.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2015-01-20 11:46:43 +08:00
|
|
|
void setHeight(float height){ setDimensions(_labelWidth, height); }
|
|
|
|
float getHeight() const { return _labelHeight; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the untransformed size of the Label in a more efficient way. */
|
2015-01-20 11:46:43 +08:00
|
|
|
void setDimensions(float width, float height);
|
2014-03-11 14:32:07 +08:00
|
|
|
const Size& getDimensions() const{ return _labelDimensions;}
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Update content immediately.*/
|
2014-03-10 19:42:43 +08:00
|
|
|
virtual void updateContent();
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Provides a way to treats each character like a Sprite.
|
|
|
|
* @warning No support system font.
|
|
|
|
*/
|
2014-02-19 20:26:14 +08:00
|
|
|
virtual Sprite * getLetter(int lettetIndex);
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Makes the Label to clip upper and lower margin for reduce height of Label.*/
|
2014-03-24 14:16:27 +08:00
|
|
|
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2014-03-25 16:37:34 +08:00
|
|
|
bool isClipMarginEnabled() const { return _clipEnabled; }
|
2014-06-12 12:01:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the line height of the Label.
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
void setLineHeight(float height);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Returns the line height of this Label.
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
float getLineHeight() const;
|
|
|
|
|
2015-09-29 00:02:17 +08:00
|
|
|
void setLineSpacing(float height);
|
|
|
|
float getLineSpacing() const;
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Sets the additional kerning of the Label.
|
|
|
|
*
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
void setAdditionalKerning(float space);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Returns the additional kerning of the Label.
|
|
|
|
*
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
float getAdditionalKerning() const;
|
|
|
|
|
2014-04-02 14:57:00 +08:00
|
|
|
FontAtlas* getFontAtlas() { return _fontAtlas; }
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-08 15:30:34 +08:00
|
|
|
virtual const BlendFunc& getBlendFunc() const override { return _blendFunc; }
|
|
|
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual bool isOpacityModifyRGB() const override { return _isOpacityModifyRGB; }
|
2014-04-02 14:57:00 +08:00
|
|
|
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 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-28 15:58:28 +08:00
|
|
|
virtual Rect getBoundingBox() const override;
|
2014-03-28 11:03:39 +08:00
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
|
|
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2015-03-16 17:11:17 +08:00
|
|
|
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
|
2015-03-16 15:31:29 +08:00
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
|
|
|
virtual void removeChild(Node* child, bool cleanup = true) override;
|
2015-08-19 10:22:48 +08:00
|
|
|
virtual void setGlobalZOrder(float globalZOrder) override;
|
2015-07-07 14:20:23 +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-09 21:35:08 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
|
2015-07-14 11:30:56 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE FontDefinition getFontDefinition() const { return _getFontDefinition(); }
|
2014-10-23 17:54:15 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return (int)getLineHeight();}
|
2014-06-12 12:01:15 +08:00
|
|
|
|
2014-08-21 15:11:33 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Constructor of Label.
|
2014-08-21 15:11:33 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2015-07-14 11:30:56 +08:00
|
|
|
Label(TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2014-08-21 15:11:33 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Destructor of Label.
|
2014-08-21 15:11:33 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~Label();
|
|
|
|
|
2015-12-03 09:23:23 +08:00
|
|
|
bool initWithTTF(const std::string& text, const std::string& fontFilePath, float fontSize,
|
|
|
|
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
|
|
|
bool initWithTTF(const TTFConfig& ttfConfig, const std::string& text,
|
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT, int maxLineWidth = 0);
|
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
protected:
|
2014-02-19 20:26:14 +08:00
|
|
|
struct LetterInfo
|
|
|
|
{
|
2015-07-24 18:38:45 +08:00
|
|
|
char16_t utf16Char;
|
|
|
|
bool valid;
|
|
|
|
float positionX;
|
|
|
|
float positionY;
|
|
|
|
int atlasIndex;
|
|
|
|
int lineIndex;
|
2014-02-19 20:26:14 +08:00
|
|
|
};
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2015-07-14 11:30:56 +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
|
|
|
};
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual void setFontAtlas(FontAtlas* atlas, bool distanceFieldEnabled = false, bool useA8Shader = false);
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
void computeStringNumLines();
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
void onDraw(const Mat4& transform, bool transformUpdated);
|
2016-01-20 12:41:31 +08:00
|
|
|
void onDrawShadow(GLProgram* glProgram, const Color4F& shadowColor);
|
2015-07-17 17:45:11 +08:00
|
|
|
void drawSelf(bool visibleByCamera, Renderer* renderer, uint32_t flags);
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
bool multilineTextWrapByChar();
|
|
|
|
bool multilineTextWrapByWord();
|
2015-11-23 17:47:30 +08:00
|
|
|
bool multilineTextWrap(std::function<int(const std::u16string&, int, int)> lambda);
|
2015-11-19 16:06:13 +08:00
|
|
|
void shrinkLabelToContentSize(std::function<bool(void)> lambda);
|
|
|
|
bool isHorizontalClamp();
|
|
|
|
bool isVerticalClamp();
|
|
|
|
float getRenderingFontSize()const;
|
2015-11-20 16:39:48 +08:00
|
|
|
void rescaleWithOriginalFontSize();
|
2015-07-24 18:38:45 +08:00
|
|
|
|
2015-08-13 10:29:58 +08:00
|
|
|
void updateLabelLetters();
|
2015-11-19 16:06:13 +08:00
|
|
|
virtual bool alignText();
|
2015-07-24 18:38:45 +08:00
|
|
|
void computeAlignmentOffset();
|
2014-05-08 11:12:59 +08:00
|
|
|
bool computeHorizontalKernings(const std::u16string& stringToRender);
|
2015-07-24 18:38:45 +08:00
|
|
|
|
|
|
|
void recordLetterInfo(const cocos2d::Vec2& point, char16_t utf16Char, int letterIndex, int lineIndex);
|
|
|
|
void recordPlaceholderInfo(int letterIndex, char16_t utf16Char);
|
2015-07-14 11:30:56 +08:00
|
|
|
|
2015-11-19 16:06:13 +08:00
|
|
|
bool updateQuads();
|
2013-12-11 16:38:47 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
void createSpriteForSystemFont(const FontDefinition& fontDef);
|
|
|
|
void createShadowSpriteForSystemFont(const FontDefinition& fontDef);
|
2013-12-11 16:38:47 +08:00
|
|
|
|
2014-03-13 21:00:36 +08:00
|
|
|
virtual void updateShaderProgram();
|
2015-11-19 16:06:13 +08:00
|
|
|
void updateBMFontScale();
|
|
|
|
void scaleFontSizeDown(float fontSize);
|
|
|
|
bool setTTFConfigInternal(const TTFConfig& ttfConfig);
|
|
|
|
void setBMFontSizeInternal(float fontSize);
|
2015-12-07 18:13:03 +08:00
|
|
|
bool isHorizontalClamped(float letterPositionX, int lineInex);
|
2015-11-19 16:06:13 +08:00
|
|
|
void restoreFontSize();
|
2015-11-20 16:39:48 +08:00
|
|
|
void updateLetterSpriteScale(Sprite* sprite);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-03-13 18:46:35 +08:00
|
|
|
void reset();
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
FontDefinition _getFontDefinition() const;
|
2015-07-07 14:20:23 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual void updateColor() override;
|
2014-03-17 18:33:15 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
LabelType _currentLabelType;
|
2014-03-10 19:42:43 +08:00
|
|
|
bool _contentDirty;
|
2015-07-24 18:38:45 +08:00
|
|
|
std::u16string _utf16Text;
|
|
|
|
std::string _utf8Text;
|
|
|
|
int _numberOfLines;
|
2015-07-14 11:30:56 +08:00
|
|
|
|
|
|
|
std::string _bmFontPath;
|
|
|
|
TTFConfig _fontConfig;
|
|
|
|
float _outlineSize;
|
2014-04-09 23:31:05 +08:00
|
|
|
|
2014-05-08 21:30:12 +08:00
|
|
|
bool _systemFontDirty;
|
2014-04-09 23:31:05 +08:00
|
|
|
std::string _systemFont;
|
2015-07-14 11:30:56 +08:00
|
|
|
float _systemFontSize;
|
|
|
|
Sprite* _textSprite;
|
|
|
|
Sprite* _shadowNode;
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
FontAtlas* _fontAtlas;
|
2015-07-07 14:20:23 +08:00
|
|
|
Vector<SpriteBatchNode*> _batchNodes;
|
2015-07-14 11:30:56 +08:00
|
|
|
std::vector<LetterInfo> _lettersInfo;
|
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;
|
2015-07-24 18:38:45 +08:00
|
|
|
int _lengthOfString;
|
2014-01-15 17:21:08 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
//layout relevant properties.
|
2015-07-24 18:38:45 +08:00
|
|
|
float _lineHeight;
|
2015-09-29 00:02:17 +08:00
|
|
|
float _lineSpacing;
|
2015-07-24 18:38:45 +08:00
|
|
|
float _additionalKerning;
|
2015-07-14 11:30:56 +08:00
|
|
|
int* _horizontalKernings;
|
|
|
|
bool _lineBreakWithoutSpaces;
|
2015-01-20 11:46:43 +08:00
|
|
|
float _maxLineWidth;
|
2015-07-14 11:30:56 +08:00
|
|
|
Size _labelDimensions;
|
2015-01-20 11:46:43 +08:00
|
|
|
float _labelWidth;
|
|
|
|
float _labelHeight;
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment _hAlignment;
|
|
|
|
TextVAlignment _vAlignment;
|
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
float _textDesiredHeight;
|
|
|
|
std::vector<float> _linesWidth;
|
|
|
|
std::vector<float> _linesOffsetX;
|
|
|
|
float _letterOffsetY;
|
|
|
|
float _tailoredTopY;
|
|
|
|
float _tailoredBottomY;
|
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
LabelEffect _currLabelEffect;
|
2014-03-20 20:56:10 +08:00
|
|
|
Color4F _effectColorF;
|
2015-07-14 11:30:56 +08:00
|
|
|
Color4B _textColor;
|
|
|
|
Color4F _textColorF;
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-08-04 21:49:14 +08:00
|
|
|
QuadCommand _quadCommand;
|
2015-07-14 11:30:56 +08:00
|
|
|
CustomCommand _customCommand;
|
|
|
|
Mat4 _shadowTransform;
|
2014-01-17 13:35:58 +08:00
|
|
|
GLuint _uniformEffectColor;
|
2014-03-20 20:56:10 +08:00
|
|
|
GLuint _uniformTextColor;
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _useDistanceField;
|
|
|
|
bool _useA8Shader;
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _shadowDirty;
|
|
|
|
bool _shadowEnabled;
|
|
|
|
Size _shadowOffset;
|
|
|
|
|
2015-04-07 11:17:01 +08:00
|
|
|
Color4F _shadowColor4F;
|
|
|
|
Color3B _shadowColor3B;
|
|
|
|
GLubyte _shadowOpacity;
|
2015-07-14 11:30:56 +08:00
|
|
|
float _shadowBlurRadius;
|
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;
|
2015-07-07 14:20:23 +08:00
|
|
|
BlendFunc _blendFunc;
|
2015-07-14 11:30:56 +08:00
|
|
|
|
|
|
|
/// whether or not the label was inside bounds the previous frame
|
2015-03-19 10:38:12 +08:00
|
|
|
bool _insideBounds;
|
2014-03-24 14:16:27 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _isOpacityModifyRGB;
|
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
std::unordered_map<int, Sprite*> _letters;
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
EventListenerCustom* _purgeTextureListener;
|
|
|
|
EventListenerCustom* _resetTextureListener;
|
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
#if CC_LABEL_DEBUG_DRAW
|
|
|
|
DrawNode* _debugDrawNode;
|
|
|
|
#endif
|
2015-11-19 16:06:13 +08:00
|
|
|
|
|
|
|
bool _enableWrap;
|
|
|
|
float _bmFontSize;
|
|
|
|
float _bmfontScale;
|
|
|
|
Overflow _overflow;
|
|
|
|
float _originalFontSize;
|
2016-01-20 12:41:31 +08:00
|
|
|
|
|
|
|
bool _boldEnabled;
|
|
|
|
DrawNode* _underlineNode;
|
|
|
|
bool _strikethroughEnabled;
|
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
2013-07-23 02:17:51 +08:00
|
|
|
};
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
// end group
|
|
|
|
/// @}
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2013-07-23 02:17:51 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /*__COCOS2D_CCLABEL_H */
|