axmol/cocos/2d/CCLabel.cpp

2232 lines
64 KiB
C++
Raw Normal View History

2013-07-23 02:17:51 +08:00
/****************************************************************************
Copyright (c) 2013 Zynga Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
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.
****************************************************************************/
#include "2d/CCLabel.h"
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
#include <algorithm>
#include "2d/CCFont.h"
Squashed commit of the following: commit c16dcfaaea0922039aad05bce1f4efed18e04871 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 19:05:18 2014 -0700 more linux fixes commit 1553795976c9090a1b46deb53d12910fe0676008 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 19:04:04 2014 -0700 more linux fixes commit 1e43a8cabff33cbf25aa5eb5412f53a878222d83 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 19:02:07 2014 -0700 fixes linux isuses commit 723a445dd6411f91846da2b801248ad8298174f1 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:58:50 2014 -0700 more linux fixes commit 533c8025e794fc76cef02f396b3a93b3d7f4cfc8 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:57:33 2014 -0700 more linux fixes commit 4ba1e84959670bcbf044f18d1c0d4b3cb3be4090 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:53:43 2014 -0700 more linux fixes commit 1f8e011f306a47ed4134224e5e349929201f0539 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:49:28 2014 -0700 more linux fixes commit 3e2033100822ff6d532a1b4f012337491dc11920 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:47:43 2014 -0700 more linux fixes commit 2e708863c75fd032f1b2396dfdf1d31f7a62b713 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:46:00 2014 -0700 more linux fixes commit 861b5b92a6efd4de7b926c20d636ce9d749b293f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:43:15 2014 -0700 more linux fixes commit 2a43365a0c1755e9b9cada53301be1a20adb31cf Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:36:06 2014 -0700 more fixes for linux commit 7d332bf911892f87c7824d2a5da7bf73ce7ec411 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:35:29 2014 -0700 more fixes for linux commit f1becc17d3316dfe3678c23c9dcedb7a447d9235 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:34:44 2014 -0700 more fixes for linux commit d2e5959bb0dde921dd5e73be1d8acc3b3f50e51d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:33:45 2014 -0700 fixes for linux commit ad9b633c352107cf0e8b060a0e23d6e6a3f5e80f Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:16:48 2014 -0700 compiles on Windows commit 4425ee8e5de8f42a2d6050e4470109600dce8b5d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Apr 30 18:07:20 2014 -0700 fix builder
2014-05-01 10:09:13 +08:00
#include "2d/CCFontAtlasCache.h"
#include "2d/CCFontAtlas.h"
#include "2d/CCSprite.h"
2015-07-07 15:41:54 +08:00
#include "2d/CCSpriteBatchNode.h"
#include "2d/CCDrawNode.h"
2015-07-30 13:59:50 +08:00
#include "2d/CCCamera.h"
Squashed commit of the following: commit a794d107ad85667e3d754f0b6251fc864dfbf288 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 14:33:49 2014 -0700 Yeah... everything compiles on win32 and wp8 commit 4740be6e4a0d16f742c27996e7ab2c100adc76af Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:58:38 2014 -0700 CCIME moved to base and compiles on Android commit ff3e1bf1eb27a01019f4e1b56d1aebbe2d385f72 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:02:57 2014 -0700 compiles Ok for Windows Phone 8 commit 8160a4eb2ecdc61b5bd1cf56b90d2da6f11e3ebd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 12:25:31 2014 -0700 fixes for Windows Phone 8 commit 418197649efc93032aee0adc205e502101cdb53d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 11:15:13 2014 -0700 Compiles on Win32 commit 08813ed7cf8ac1079ffadeb1ce78ea9e833e1a33 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 10:08:31 2014 -0700 Compiles on linux! commit 118896521e5b335a5257090b6863f1fb2a2002fe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 09:30:42 2014 -0700 moves cocos/2d/platform -> cocos/platform commit 4fe9319d7717b0c1bccb2db0156eeb86255a89e0 Merge: bd68ec2 511295e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 08:24:41 2014 -0700 Merge remote-tracking branch 'cocos2d/v3' into files commit bd68ec2f0e3a826d8b2f4b60564ba65ce766bc56 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu May 15 19:36:23 2014 -0700 files in the correct directory
2014-05-17 05:36:00 +08:00
#include "base/ccUTF8.h"
#include "platform/CCFileUtils.h"
2014-04-30 08:37:36 +08:00
#include "renderer/CCRenderer.h"
2014-05-10 12:29:24 +08:00
#include "base/CCDirector.h"
2014-04-30 08:37:36 +08:00
#include "base/CCEventListenerCustom.h"
#include "base/CCEventDispatcher.h"
#include "base/CCEventCustom.h"
2018-09-11 14:39:30 +08:00
#include "base/ccUtils.h"
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
#include "2d/CCFontFNT.h"
2014-05-10 12:29:24 +08:00
2013-07-23 02:17:51 +08:00
NS_CC_BEGIN
2015-07-08 15:30:34 +08:00
/**
* LabelLetter used to update the quad in texture atlas without SpriteBatchNode.
*/
2015-07-07 14:20:23 +08:00
class LabelLetter : public Sprite
{
public:
LabelLetter()
{
_textureAtlas = nullptr;
_letterVisible = true;
2015-07-07 14:20:23 +08:00
}
static LabelLetter* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated = false)
{
auto letter = new (std::nothrow) LabelLetter();
if (letter && letter->initWithTexture(texture, rect, rotated))
{
letter->Sprite::setVisible(false);
2015-07-07 14:20:23 +08:00
letter->autorelease();
return letter;
}
CC_SAFE_DELETE(letter);
return nullptr;
}
CREATE_FUNC(LabelLetter);
2015-07-07 14:20:23 +08:00
virtual void updateTransform() override
{
if (isDirty())
{
_transformToBatch = getNodeToParentTransform();
Size &size = _rect.size;
float x1 = _offsetPosition.x;
float y1 = _offsetPosition.y;
float x2 = x1 + size.width;
float y2 = y1 + size.height;
// issue #17022: don't flip, again, the letter since they are flipped in sprite's code
//if (_flippedX) std::swap(x1, x2);
//if (_flippedY) std::swap(y1, y2);
2015-08-11 10:06:14 +08:00
2015-07-07 14:20:23 +08:00
float x = _transformToBatch.m[12];
float y = _transformToBatch.m[13];
float cr = _transformToBatch.m[0];
float sr = _transformToBatch.m[1];
float cr2 = _transformToBatch.m[5];
float sr2 = -_transformToBatch.m[4];
float ax = x1 * cr - y1 * sr2 + x;
float ay = x1 * sr + y1 * cr2 + y;
float bx = x2 * cr - y1 * sr2 + x;
float by = x2 * sr + y1 * cr2 + y;
float cx = x2 * cr - y2 * sr2 + x;
float cy = x2 * sr + y2 * cr2 + y;
float dx = x1 * cr - y2 * sr2 + x;
float dy = x1 * sr + y2 * cr2 + y;
2015-07-08 15:30:34 +08:00
_quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ);
_quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ);
_quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ);
_quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ);
2015-07-07 14:20:23 +08:00
if (_textureAtlas)
{
_textureAtlas->updateQuad(&_quad, _atlasIndex);
}
_recursiveDirty = false;
setDirty(false);
}
Node::updateTransform();
}
2015-10-02 16:59:12 +08:00
virtual void updateColor() override
2015-07-07 14:20:23 +08:00
{
if (_textureAtlas == nullptr)
{
return;
}
auto displayedOpacity = _displayedOpacity;
if(!_letterVisible)
{
displayedOpacity = 0.0f;
}
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, displayedOpacity);
2015-07-07 14:20:23 +08:00
// special opacity for premultiplied textures
if (_opacityModifyRGB)
{
color4.r *= displayedOpacity / 255.0f;
color4.g *= displayedOpacity / 255.0f;
color4.b *= displayedOpacity / 255.0f;
2015-07-07 14:20:23 +08:00
}
_quad.bl.colors = color4;
_quad.br.colors = color4;
_quad.tl.colors = color4;
_quad.tr.colors = color4;
_textureAtlas->updateQuad(&_quad, _atlasIndex);
}
void setVisible(bool visible) override
{
_letterVisible = visible;
updateColor();
}
bool isVisible() const override
{
return _letterVisible;
}
//LabelLetter doesn't need to draw directly.
void draw(Renderer* /*renderer*/, const Mat4 & /*transform*/, uint32_t /*flags*/) override
{
}
private:
bool _letterVisible;
2015-07-07 14:20:23 +08:00
};
Label* Label::create()
2013-07-23 02:17:51 +08:00
{
2015-12-03 09:23:23 +08:00
auto ret = new (std::nothrow) Label;
if (ret)
{
ret->autorelease();
}
return ret;
2013-07-23 02:17:51 +08:00
}
Label* 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 */)
{
if (FileUtils::getInstance()->isFileExist(font))
{
return createWithTTF(text,font,fontSize,dimensions,hAlignment,vAlignment);
}
else
{
return createWithSystemFont(text,font,fontSize,dimensions,hAlignment,vAlignment);
}
}
Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
2015-07-14 11:30:56 +08:00
auto ret = new (std::nothrow) Label(hAlignment,vAlignment);
if (ret)
{
ret->setSystemFontName(font);
ret->setSystemFontSize(fontSize);
ret->setDimensions(dimensions.width, dimensions.height);
ret->setString(text);
ret->autorelease();
return ret;
}
return nullptr;
}
Label* Label::createWithTTF(const std::string& text, const std::string& fontFile, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
2015-07-14 11:30:56 +08:00
auto ret = new (std::nothrow) Label(hAlignment,vAlignment);
2015-12-03 09:23:23 +08:00
if (ret && ret->initWithTTF(text, fontFile, fontSize, dimensions, hAlignment, vAlignment))
{
2015-12-03 09:23:23 +08:00
ret->autorelease();
return ret;
}
2015-12-03 09:23:23 +08:00
CC_SAFE_DELETE(ret);
return nullptr;
}
2015-07-14 11:30:56 +08:00
Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment hAlignment /* = TextHAlignment::CENTER */, int maxLineWidth /* = 0 */)
2013-07-23 02:17:51 +08:00
{
2015-07-14 11:30:56 +08:00
auto ret = new (std::nothrow) Label(hAlignment);
2015-12-03 09:23:23 +08:00
if (ret && ret->initWithTTF(ttfConfig, text, hAlignment, maxLineWidth))
{
ret->autorelease();
return ret;
}
2013-07-23 02:17:51 +08:00
2015-12-03 09:23:23 +08:00
CC_SAFE_DELETE(ret);
return nullptr;
}
2015-07-14 11:30:56 +08:00
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& hAlignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vec2& imageOffset /* = Vec2::ZERO */)
{
2015-07-14 11:30:56 +08:00
auto ret = new (std::nothrow) Label(hAlignment);
if (ret && ret->setBMFontFilePath(bmfontFilePath,imageOffset))
{
ret->setMaxLineWidth(maxLineWidth);
ret->setString(text);
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}
Label* Label::createWithCharMap(const std::string& plistFile)
{
auto ret = new (std::nothrow) Label();
if (ret && ret->setCharMap(plistFile))
{
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}
Label* Label::createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
{
auto ret = new (std::nothrow) Label();
if (ret && ret->setCharMap(texture,itemWidth,itemHeight,startCharMap))
{
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}
Label* Label::createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
auto ret = new (std::nothrow) Label();
if (ret && ret->setCharMap(charMapFile,itemWidth,itemHeight,startCharMap))
{
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}
bool Label::setCharMap(const std::string& plistFile)
{
auto newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile);
if (!newAtlas)
{
reset();
return false;
}
_currentLabelType = LabelType::CHARMAP;
setFontAtlas(newAtlas);
return true;
}
2015-12-03 09:23:23 +08:00
bool Label::initWithTTF(const std::string& text,
const std::string& fontFilePath, float fontSize,
const Size& dimensions,
TextHAlignment /*hAlignment*/, TextVAlignment /*vAlignment*/)
2015-12-03 09:23:23 +08:00
{
if (FileUtils::getInstance()->isFileExist(fontFilePath))
{
TTFConfig ttfConfig(fontFilePath, fontSize, GlyphCollection::DYNAMIC);
if (setTTFConfig(ttfConfig))
{
setDimensions(dimensions.width, dimensions.height);
setString(text);
}
return true;
}
return false;
}
bool Label::initWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment /*hAlignment*/, int maxLineWidth)
2015-12-03 09:23:23 +08:00
{
if (FileUtils::getInstance()->isFileExist(ttfConfig.fontFilePath) && setTTFConfig(ttfConfig))
{
setMaxLineWidth(maxLineWidth);
setString(text);
return true;
}
return false;
}
bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
{
auto newAtlas = FontAtlasCache::getFontAtlasCharMap(texture,itemWidth,itemHeight,startCharMap);
if (!newAtlas)
{
reset();
return false;
}
_currentLabelType = LabelType::CHARMAP;
setFontAtlas(newAtlas);
return true;
}
bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
auto newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap);
if (!newAtlas)
{
reset();
return false;
}
_currentLabelType = LabelType::CHARMAP;
setFontAtlas(newAtlas);
return true;
}
2015-07-14 11:30:56 +08:00
Label::Label(TextHAlignment hAlignment /* = TextHAlignment::LEFT */,
TextVAlignment vAlignment /* = TextVAlignment::TOP */)
: _textSprite(nullptr)
, _shadowNode(nullptr)
, _fontAtlas(nullptr)
, _reusedLetter(nullptr)
, _horizontalKernings(nullptr)
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
, _boldEnabled(false)
, _underlineNode(nullptr)
, _strikethroughEnabled(false)
2013-07-23 02:17:51 +08:00
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
reset();
2015-07-14 11:30:56 +08:00
_hAlignment = hAlignment;
_vAlignment = vAlignment;
#if CC_LABEL_DEBUG_DRAW
_debugDrawNode = DrawNode::create();
addChild(_debugDrawNode);
#endif
_purgeTextureListener = EventListenerCustom::create(FontAtlas::CMD_PURGE_FONTATLAS, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-07 14:20:23 +08:00
{
it.second->setTexture(nullptr);
}
_batchNodes.clear();
if (_fontAtlas)
{
FontAtlasCache::releaseFontAtlas(_fontAtlas);
}
}
});
_eventDispatcher->addEventListenerWithFixedPriority(_purgeTextureListener, 1);
_resetTextureListener = EventListenerCustom::create(FontAtlas::CMD_RESET_FONTATLAS, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{
_fontAtlas = nullptr;
auto lineHeight = _lineHeight;
this->setTTFConfig(_fontConfig);
if (_currentLabelType != LabelType::STRING_TEXTURE)
{
setLineHeight(lineHeight);
}
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-07 14:20:23 +08:00
{
getLetter(it.first);
}
}
});
_eventDispatcher->addEventListenerWithFixedPriority(_resetTextureListener, 2);
2013-07-23 02:17:51 +08:00
}
Label::~Label()
{
delete [] _horizontalKernings;
if (_fontAtlas)
{
2015-07-14 11:30:56 +08:00
Node::removeAllChildrenWithCleanup(true);
CC_SAFE_RELEASE_NULL(_reusedLetter);
_batchNodes.clear();
FontAtlasCache::releaseFontAtlas(_fontAtlas);
}
_eventDispatcher->removeEventListener(_purgeTextureListener);
_eventDispatcher->removeEventListener(_resetTextureListener);
2015-07-07 14:20:23 +08:00
CC_SAFE_RELEASE_NULL(_textSprite);
CC_SAFE_RELEASE_NULL(_shadowNode);
}
void Label::reset()
{
2015-07-14 11:30:56 +08:00
CC_SAFE_RELEASE_NULL(_textSprite);
CC_SAFE_RELEASE_NULL(_shadowNode);
Node::removeAllChildrenWithCleanup(true);
CC_SAFE_RELEASE_NULL(_reusedLetter);
_letters.clear();
_batchNodes.clear();
2015-07-14 11:30:56 +08:00
_lettersInfo.clear();
if (_fontAtlas)
{
FontAtlasCache::releaseFontAtlas(_fontAtlas);
_fontAtlas = nullptr;
}
_currentLabelType = LabelType::STRING_TEXTURE;
_currLabelEffect = LabelEffect::NORMAL;
2015-07-14 11:30:56 +08:00
_contentDirty = false;
_numberOfLines = 0;
_lengthOfString = 0;
_utf32Text.clear();
_utf8Text.clear();
2015-07-14 11:30:56 +08:00
TTFConfig temp;
_fontConfig = temp;
_outlineSize = 0.f;
_bmFontPath = "";
_systemFontDirty = false;
_systemFont = "Helvetica";
_systemFontSize = CC_DEFAULT_FONT_LABEL_SIZE;
2015-07-14 11:30:56 +08:00
if (_horizontalKernings)
{
delete[] _horizontalKernings;
_horizontalKernings = nullptr;
}
_additionalKerning = 0.f;
_lineHeight = 0.f;
2015-09-29 00:02:17 +08:00
_lineSpacing = 0.f;
2015-07-14 11:30:56 +08:00
_maxLineWidth = 0.f;
_labelDimensions.width = 0.f;
_labelDimensions.height = 0.f;
_labelWidth = 0.f;
_labelHeight = 0.f;
_lineBreakWithoutSpaces = false;
_hAlignment = TextHAlignment::LEFT;
_vAlignment = TextVAlignment::TOP;
_effectColorF = Color4F::BLACK;
_textColor = Color4B::WHITE;
_textColorF = Color4F::WHITE;
setColor(Color3B::WHITE);
2015-07-14 11:30:56 +08:00
_shadowDirty = false;
_shadowEnabled = false;
2015-07-14 11:30:56 +08:00
_shadowBlurRadius = 0.f;
_uniformEffectColor = -1;
_uniformEffectType = -1;
_uniformTextColor = -1;
2015-07-14 11:30:56 +08:00
_useDistanceField = false;
_useA8Shader = false;
_clipEnabled = false;
2014-03-31 15:45:06 +08:00
_blendFuncDirty = false;
2015-07-14 11:30:56 +08:00
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_isOpacityModifyRGB = false;
_insideBounds = true;
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_enableWrap = true;
_bmFontSize = -1;
_bmfontScale = 1.0f;
_overflow = Overflow::NONE;
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_originalFontSize = 0.0f;
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
_boldEnabled = false;
if (_underlineNode)
{
removeChild(_underlineNode);
_underlineNode = nullptr;
}
_strikethroughEnabled = false;
setRotationSkewX(0); // reverse italics
}
// ETC1 ALPHA supports, for LabelType::BMFONT & LabelType::CHARMAP
static Texture2D* _getTexture(Label* label)
{
auto fontAtlas = label->getFontAtlas();
Texture2D* texture = nullptr;
if (fontAtlas != nullptr) {
auto textures = fontAtlas->getTextures();
if(!textures.empty()) {
texture = textures.begin()->second;
}
}
return texture;
}
2014-03-13 21:00:36 +08:00
void Label::updateShaderProgram()
{
switch (_currLabelEffect)
{
case cocos2d::LabelEffect::NORMAL:
if (_useDistanceField)
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL));
else if (_useA8Shader)
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_NORMAL));
2015-08-05 00:21:06 +08:00
else if (_shadowEnabled)
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR, _getTexture(this)));
2015-08-05 00:21:06 +08:00
else
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, _getTexture(this)));
break;
case cocos2d::LabelEffect::OUTLINE:
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_OUTLINE));
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_effectColor");
_uniformEffectType = glGetUniformLocation(getGLProgram()->getProgram(), "u_effectType");
break;
case cocos2d::LabelEffect::GLOW:
if (_useDistanceField)
{
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW));
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_effectColor");
}
break;
default:
return;
}
_uniformTextColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_textColor");
}
2014-03-13 20:52:33 +08:00
void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */)
{
if(atlas)
{
_systemFontDirty = false;
}
if (atlas == _fontAtlas)
2014-03-13 20:52:33 +08:00
return;
CC_SAFE_RETAIN(atlas);
if (_fontAtlas)
{
_batchNodes.clear();
FontAtlasCache::releaseFontAtlas(_fontAtlas);
}
_fontAtlas = atlas;
if (_reusedLetter == nullptr)
{
_reusedLetter = Sprite::create();
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
_reusedLetter->retain();
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
}
if (_fontAtlas)
{
_lineHeight = _fontAtlas->getLineHeight();
_contentDirty = true;
_systemFontDirty = false;
}
_useDistanceField = distanceFieldEnabled;
_useA8Shader = useA8Shader;
if (_currentLabelType != LabelType::TTF)
{
_currLabelEffect = LabelEffect::NORMAL;
updateShaderProgram();
}
}
2014-01-15 17:21:08 +08:00
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_originalFontSize = ttfConfig.fontSize;
return setTTFConfigInternal(ttfConfig);
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset, float fontSize)
{
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
if (!newAtlas)
{
reset();
return false;
}
2015-12-09 00:45:39 +08:00
//assign the default fontSize
if (std::abs(fontSize) < FLT_EPSILON) {
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
FontFNT *bmFont = (FontFNT*)newAtlas->getFont();
if (bmFont) {
float originalFontSize = bmFont->getOriginalFontSize();
2015-12-13 13:59:42 +08:00
_bmFontSize = originalFontSize / CC_CONTENT_SCALE_FACTOR();
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
}
}
if(fontSize > 0.0f){
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_bmFontSize = fontSize;
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_bmFontPath = bmfontFilePath;
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_currentLabelType = LabelType::BMFONT;
setFontAtlas(newAtlas);
return true;
}
2014-03-10 20:35:36 +08:00
void Label::setString(const std::string& text)
{
if (text.compare(_utf8Text))
2014-05-08 21:30:12 +08:00
{
_utf8Text = text;
2014-05-14 16:41:26 +08:00
_contentDirty = true;
std::u32string utf32String;
if (StringUtils::UTF8ToUTF32(_utf8Text, utf32String))
2014-05-14 16:41:26 +08:00
{
_utf32Text = utf32String;
2014-05-14 16:41:26 +08:00
}
2014-05-08 21:30:12 +08:00
}
}
void Label::setAlignment(TextHAlignment hAlignment,TextVAlignment vAlignment)
{
if (hAlignment != _hAlignment || vAlignment != _vAlignment)
{
_hAlignment = hAlignment;
_vAlignment = vAlignment;
_contentDirty = true;
}
}
void Label::setMaxLineWidth(float maxLineWidth)
{
if (_labelWidth == 0 && _maxLineWidth != maxLineWidth)
{
_maxLineWidth = maxLineWidth;
_contentDirty = true;
}
}
void Label::setDimensions(float width, float height)
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(_overflow == Overflow::RESIZE_HEIGHT){
height = 0;
}
if (height != _labelHeight || width != _labelWidth)
{
_labelWidth = width;
_labelHeight = height;
_labelDimensions.width = width;
_labelDimensions.height = height;
_maxLineWidth = width;
_contentDirty = true;
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(_overflow == Overflow::SHRINK){
if (_originalFontSize > 0) {
this->restoreFontSize();
}
}
}
}
void Label::restoreFontSize()
{
if(_currentLabelType == LabelType::TTF){
auto ttfConfig = this->getTTFConfig();
ttfConfig.fontSize = _originalFontSize;
this->setTTFConfigInternal(ttfConfig);
}else if(_currentLabelType == LabelType::BMFONT){
this->setBMFontSizeInternal(_originalFontSize);
}else if(_currentLabelType == LabelType::STRING_TEXTURE){
this->setSystemFontSize(_originalFontSize);
}
}
void Label::setLineBreakWithoutSpace(bool breakWithoutSpace)
{
if (breakWithoutSpace != _lineBreakWithoutSpaces)
{
_lineBreakWithoutSpaces = breakWithoutSpace;
_contentDirty = true;
}
}
void Label::updateLabelLetters()
{
if (!_letters.empty())
{
Rect uvRect;
LabelLetter* letterSprite;
int letterIndex;
for (auto it = _letters.begin(); it != _letters.end();)
{
letterIndex = it->first;
letterSprite = (LabelLetter*)it->second;
if (letterIndex >= _lengthOfString)
{
Node::removeChild(letterSprite, true);
it = _letters.erase(it);
}
else
{
auto& letterInfo = _lettersInfo[letterIndex];
if (letterInfo.valid)
{
auto& letterDef = _fontAtlas->_letterDefinitions[letterInfo.utf32Char];
uvRect.size.height = letterDef.height;
uvRect.size.width = letterDef.width;
uvRect.origin.x = letterDef.U;
uvRect.origin.y = letterDef.V;
auto batchNode = _batchNodes.at(letterDef.textureID);
letterSprite->setTextureAtlas(batchNode->getTextureAtlas());
letterSprite->setTexture(_fontAtlas->getTexture(letterDef.textureID));
if (letterDef.width <= 0.f || letterDef.height <= 0.f)
{
letterSprite->setTextureAtlas(nullptr);
}
else
{
letterSprite->setTextureRect(uvRect, false, uvRect.size);
letterSprite->setTextureAtlas(_batchNodes.at(letterDef.textureID)->getTextureAtlas());
letterSprite->setAtlasIndex(_lettersInfo[letterIndex].atlasIndex);
}
auto px = letterInfo.positionX + letterDef.width / 2 + _linesOffsetX[letterInfo.lineIndex];
auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY;
letterSprite->setPosition(px, py);
}
else
{
letterSprite->setTextureAtlas(nullptr);
}
this->updateLetterSpriteScale(letterSprite);
++it;
}
}
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool Label::alignText()
{
if (_fontAtlas == nullptr || _utf32Text.empty())
{
setContentSize(Size::ZERO);
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return true;
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool ret = true;
do {
_fontAtlas->prepareLetterDefinitions(_utf32Text);
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
auto& textures = _fontAtlas->getTextures();
auto size = textures.size();
if (size > static_cast<size_t>(_batchNodes.size()))
{
for (auto index = static_cast<size_t>(_batchNodes.size()); index < size; ++index)
2015-07-07 14:20:23 +08:00
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index));
if (batchNode)
{
_isOpacityModifyRGB = batchNode->getTexture()->hasPremultipliedAlpha();
_blendFunc = batchNode->getBlendFunc();
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
batchNode->setPosition(Vec2::ZERO);
_batchNodes.pushBack(batchNode);
}
2015-07-07 14:20:23 +08:00
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if (_batchNodes.empty())
{
return true;
}
// optimize for one-texture-only scenario
// if multiple textures, then we should count how many chars
// are per texture
if (_batchNodes.size()==1)
_batchNodes.at(0)->reserveCapacity(_utf32Text.size());
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_reusedLetter->setBatchNode(_batchNodes.at(0));
_lengthOfString = 0;
_textDesiredHeight = 0.f;
_linesWidth.clear();
if (_maxLineWidth > 0.f && !_lineBreakWithoutSpaces)
{
multilineTextWrapByWord();
}
else
{
multilineTextWrapByChar();
}
computeAlignmentOffset();
if(_overflow == Overflow::SHRINK){
2015-11-20 10:54:05 +08:00
float fontSize = this->getRenderingFontSize();
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(fontSize > 0 && isVerticalClamp()){
this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isVerticalClamp, this));
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(!updateQuads()){
ret = false;
2015-12-07 18:13:03 +08:00
if(_overflow == Overflow::SHRINK){
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
this->shrinkLabelToContentSize(CC_CALLBACK_0(Label::isHorizontalClamp, this));
}
break;
}
updateLabelLetters();
updateColor();
}while (0);
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return ret;
2013-07-23 02:17:51 +08:00
}
bool Label::computeHorizontalKernings(const std::u32string& stringToRender)
{
if (_horizontalKernings)
{
delete [] _horizontalKernings;
_horizontalKernings = nullptr;
}
int letterCount = 0;
_horizontalKernings = _fontAtlas->getFont()->getHorizontalKerningForTextUTF32(stringToRender, letterCount);
if(!_horizontalKernings)
return false;
else
return true;
}
2015-12-07 18:13:03 +08:00
bool Label::isHorizontalClamped(float letterPositionX, int lineIndex)
{
auto wordWidth = this->_linesWidth[lineIndex];
bool letterOverClamp = (letterPositionX > _contentSize.width || letterPositionX < 0);
if (!_enableWrap) {
return letterOverClamp;
}else{
return (wordWidth > this->_contentSize.width && letterOverClamp);
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool Label::updateQuads()
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool ret = true;
for (auto&& batchNode : _batchNodes)
{
batchNode->getTextureAtlas()->removeAllQuads();
}
for (int ctr = 0; ctr < _lengthOfString; ++ctr)
{
if (_lettersInfo[ctr].valid)
{
auto& letterDef = _fontAtlas->_letterDefinitions[_lettersInfo[ctr].utf32Char];
_reusedRect.size.height = letterDef.height;
_reusedRect.size.width = letterDef.width;
_reusedRect.origin.x = letterDef.U;
_reusedRect.origin.y = letterDef.V;
2015-07-13 22:44:41 +08:00
auto py = _lettersInfo[ctr].positionY + _letterOffsetY;
if (_labelHeight > 0.f) {
if (py > _tailoredTopY)
{
auto clipTop = py - _tailoredTopY;
_reusedRect.origin.y += clipTop;
_reusedRect.size.height -= clipTop;
py -= clipTop;
}
if (py - letterDef.height * _bmfontScale < _tailoredBottomY)
{
_reusedRect.size.height = (py < _tailoredBottomY) ? 0.f : (py - _tailoredBottomY);
}
}
2015-12-07 18:13:03 +08:00
auto lineIndex = _lettersInfo[ctr].lineIndex;
auto px = _lettersInfo[ctr].positionX + letterDef.width/2 * _bmfontScale + _linesOffsetX[lineIndex];
if(_labelWidth > 0.f){
if (this->isHorizontalClamped(px, lineIndex)) {
if(_overflow == Overflow::CLAMP){
_reusedRect.size.width = 0;
}else if(_overflow == Overflow::SHRINK){
if (_contentSize.width > letterDef.width) {
ret = false;
break;
}else{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_reusedRect.size.width = 0;
}
2015-12-07 18:13:03 +08:00
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
}
}
}
2015-12-07 18:13:03 +08:00
if (_reusedRect.size.height > 0.f && _reusedRect.size.width > 0.f)
{
_reusedLetter->setTextureRect(_reusedRect, false, _reusedRect.size);
float letterPositionX = _lettersInfo[ctr].positionX + _linesOffsetX[_lettersInfo[ctr].lineIndex];
_reusedLetter->setPosition(letterPositionX, py);
auto index = static_cast<int>(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads());
_lettersInfo[ctr].atlasIndex = index;
2015-12-07 18:13:03 +08:00
this->updateLetterSpriteScale(_reusedLetter);
_batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter, index);
}
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return ret;
}
bool Label::setTTFConfigInternal(const TTFConfig& ttfConfig)
{
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(&ttfConfig);
if (!newAtlas)
{
reset();
return false;
}
_currentLabelType = LabelType::TTF;
setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
_fontConfig = ttfConfig;
if (_fontConfig.outlineSize > 0)
{
_fontConfig.distanceFieldEnabled = false;
_useDistanceField = false;
_useA8Shader = false;
_currLabelEffect = LabelEffect::OUTLINE;
updateShaderProgram();
}
else
{
_currLabelEffect = LabelEffect::NORMAL;
updateShaderProgram();
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_fontConfig.italics)
this->enableItalics();
if (_fontConfig.bold)
this->enableBold();
if (_fontConfig.underline)
this->enableUnderline();
if (_fontConfig.strikethrough)
this->enableStrikethrough();
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return true;
}
void Label::setBMFontSizeInternal(float fontSize)
{
if(_currentLabelType == LabelType::BMFONT){
this->setBMFontFilePath(_bmFontPath, Vec2::ZERO, fontSize);
_contentDirty = true;
}
}
void Label::scaleFontSizeDown(float fontSize)
{
bool shouldUpdateContent = true;
if(_currentLabelType == LabelType::TTF){
auto ttfConfig = this->getTTFConfig();
ttfConfig.fontSize = fontSize;
this->setTTFConfigInternal(ttfConfig);
}else if(_currentLabelType == LabelType::BMFONT){
if (std::abs(fontSize) < FLT_EPSILON) {
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
fontSize = 0.1f;
shouldUpdateContent = false;
}
this->setBMFontSizeInternal(fontSize);
}else if (_currentLabelType == LabelType::STRING_TEXTURE){
this->setSystemFontSize(fontSize);
}
if (shouldUpdateContent) {
this->updateContent();
}
}
void Label::enableGlow(const Color4B& glowColor)
{
if (_currentLabelType == LabelType::TTF)
{
if (_fontConfig.distanceFieldEnabled == false)
{
auto config = _fontConfig;
config.outlineSize = 0;
config.distanceFieldEnabled = true;
setTTFConfig(config);
_contentDirty = true;
}
_currLabelEffect = LabelEffect::GLOW;
2015-07-14 11:30:56 +08:00
_effectColorF.r = glowColor.r / 255.0f;
_effectColorF.g = glowColor.g / 255.0f;
_effectColorF.b = glowColor.b / 255.0f;
_effectColorF.a = glowColor.a / 255.0f;
updateShaderProgram();
}
}
void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */)
{
2014-06-12 14:41:01 +08:00
CCASSERT(_currentLabelType == LabelType::STRING_TEXTURE || _currentLabelType == LabelType::TTF, "Only supported system font and TTF!");
if (outlineSize > 0 || _currLabelEffect == LabelEffect::OUTLINE)
{
2014-03-10 20:35:36 +08:00
if (_currentLabelType == LabelType::TTF)
{
_effectColorF.r = outlineColor.r / 255.0f;
_effectColorF.g = outlineColor.g / 255.0f;
_effectColorF.b = outlineColor.b / 255.0f;
_effectColorF.a = outlineColor.a / 255.0f;
if (outlineSize > 0 && _fontConfig.outlineSize != outlineSize)
{
_fontConfig.outlineSize = outlineSize;
setTTFConfig(_fontConfig);
}
}
2015-07-14 11:30:56 +08:00
else if (_effectColorF != outlineColor || _outlineSize != outlineSize)
{
2015-07-14 11:30:56 +08:00
_effectColorF.r = outlineColor.r / 255.f;
_effectColorF.g = outlineColor.g / 255.f;
_effectColorF.b = outlineColor.b / 255.f;
_effectColorF.a = outlineColor.a / 255.f;
_currLabelEffect = LabelEffect::OUTLINE;
_contentDirty = true;
}
2015-12-10 13:17:31 +08:00
_outlineSize = outlineSize;
}
}
void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,
const Size &offset /* = Size(2 ,-2)*/,
int /* blurRadius = 0 */)
{
_shadowEnabled = true;
_shadowDirty = true;
2015-09-28 01:12:50 +08:00
_shadowOffset.width = offset.width;
_shadowOffset.height = offset.height;
//TODO: support blur for shadow
_shadowColor3B.r = shadowColor.r;
_shadowColor3B.g = shadowColor.g;
_shadowColor3B.b = shadowColor.b;
_shadowOpacity = shadowColor.a;
if (!_systemFontDirty && !_contentDirty && _textSprite)
{
2015-07-14 13:47:35 +08:00
auto fontDef = _getFontDefinition();
if (_shadowNode)
{
if (shadowColor != _shadowColor4F)
{
2015-07-07 14:20:23 +08:00
_shadowNode->release();
_shadowNode = nullptr;
2015-07-14 11:30:56 +08:00
createShadowSpriteForSystemFont(fontDef);
}
else
{
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
}
}
else
{
2015-07-14 11:30:56 +08:00
createShadowSpriteForSystemFont(fontDef);
}
}
_shadowColor4F.r = shadowColor.r / 255.0f;
_shadowColor4F.g = shadowColor.g / 255.0f;
_shadowColor4F.b = shadowColor.b / 255.0f;
_shadowColor4F.a = shadowColor.a / 255.0f;
2015-08-05 00:21:06 +08:00
if (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP)
{
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(_shadowEnabled ? GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR : GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, _getTexture(this)));
2015-08-05 00:21:06 +08:00
}
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
void Label::enableItalics()
{
setRotationSkewX(12);
}
void Label::enableBold()
{
if (!_boldEnabled)
{
// bold is implemented with outline
enableShadow(Color4B::WHITE, Size(0.9f, 0), 0);
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
// add one to kerning
setAdditionalKerning(_additionalKerning+1);
_boldEnabled = true;
}
}
void Label::enableUnderline()
{
// remove it, just in case to prevent adding two or more
if (!_underlineNode)
{
_underlineNode = DrawNode::create();
addChild(_underlineNode, 100000);
_contentDirty = true;
}
}
void Label::enableStrikethrough()
{
if (!_strikethroughEnabled)
{
enableUnderline();
_strikethroughEnabled = true;
}
}
void Label::disableEffect()
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
disableEffect(LabelEffect::ALL);
}
void Label::disableEffect(LabelEffect effect)
{
switch (effect)
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
case cocos2d::LabelEffect::NORMAL:
break;
case cocos2d::LabelEffect::OUTLINE:
if (_currLabelEffect == LabelEffect::OUTLINE)
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_currentLabelType == LabelType::TTF)
{
_fontConfig.outlineSize = 0;
setTTFConfig(_fontConfig);
}
_currLabelEffect = LabelEffect::NORMAL;
_contentDirty = true;
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
break;
case cocos2d::LabelEffect::SHADOW:
if (_shadowEnabled)
{
_shadowEnabled = false;
CC_SAFE_RELEASE_NULL(_shadowNode);
2016-01-21 11:08:31 +08:00
updateShaderProgram();
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
}
break;
case cocos2d::LabelEffect::GLOW:
if (_currLabelEffect == LabelEffect::GLOW)
{
_currLabelEffect = LabelEffect::NORMAL;
updateShaderProgram();
}
break;
case cocos2d::LabelEffect::ITALICS:
setRotationSkewX(0);
break;
case cocos2d::LabelEffect::BOLD:
if (_boldEnabled) {
_boldEnabled = false;
_additionalKerning -= 1;
disableEffect(LabelEffect::SHADOW);
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
break;
case cocos2d::LabelEffect::UNDERLINE:
if (_underlineNode) {
removeChild(_underlineNode);
_underlineNode = nullptr;
}
break;
case cocos2d::LabelEffect::STRIKETHROUGH:
_strikethroughEnabled = false;
// since it is based on underline, disable it as well
disableEffect(LabelEffect::UNDERLINE);
break;
case LabelEffect::ALL:
{
disableEffect(LabelEffect::SHADOW);
disableEffect(LabelEffect::GLOW);
disableEffect(LabelEffect::OUTLINE);
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
disableEffect(LabelEffect::ITALICS);
disableEffect(LabelEffect::BOLD);
disableEffect(LabelEffect::UNDERLINE);
disableEffect(LabelEffect::STRIKETHROUGH);
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
break;
default:
break;
}
}
2015-07-14 11:30:56 +08:00
void Label::createSpriteForSystemFont(const FontDefinition& fontDef)
2015-03-16 15:31:29 +08:00
{
_currentLabelType = LabelType::STRING_TEXTURE;
auto texture = new (std::nothrow) Texture2D;
texture->initWithString(_utf8Text.c_str(), fontDef);
_textSprite = Sprite::createWithTexture(texture);
2015-03-18 11:58:36 +08:00
//set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label
2015-03-18 11:41:43 +08:00
_textSprite->setCameraMask(getCameraMask());
_textSprite->setGlobalZOrder(getGlobalZOrder());
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
_textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->setContentSize(_textSprite->getContentSize());
texture->release();
2014-03-31 15:45:06 +08:00
if (_blendFuncDirty)
{
_textSprite->setBlendFunc(_blendFunc);
}
2015-07-07 14:20:23 +08:00
_textSprite->retain();
_textSprite->updateDisplayedColor(_displayedColor);
_textSprite->updateDisplayedOpacity(_displayedOpacity);
}
2015-07-14 11:30:56 +08:00
void Label::createShadowSpriteForSystemFont(const FontDefinition& fontDef)
{
2015-07-14 11:30:56 +08:00
if (!fontDef._stroke._strokeEnabled && fontDef._fontFillColor == _shadowColor3B
&& (fontDef._fontAlpha == _shadowOpacity))
{
_shadowNode = Sprite::createWithTexture(_textSprite->getTexture());
}
else
{
2015-07-14 11:30:56 +08:00
FontDefinition shadowFontDefinition = fontDef;
shadowFontDefinition._fontFillColor.r = _shadowColor3B.r;
shadowFontDefinition._fontFillColor.g = _shadowColor3B.g;
shadowFontDefinition._fontFillColor.b = _shadowColor3B.b;
shadowFontDefinition._fontAlpha = _shadowOpacity;
shadowFontDefinition._stroke._strokeColor = shadowFontDefinition._fontFillColor;
shadowFontDefinition._stroke._strokeAlpha = shadowFontDefinition._fontAlpha;
auto texture = new (std::nothrow) Texture2D;
texture->initWithString(_utf8Text.c_str(), shadowFontDefinition);
_shadowNode = Sprite::createWithTexture(texture);
texture->release();
}
if (_shadowNode)
{
if (_blendFuncDirty)
{
_shadowNode->setBlendFunc(_blendFunc);
}
_shadowNode->setCameraMask(getCameraMask());
_shadowNode->setGlobalZOrder(getGlobalZOrder());
_shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
2015-07-07 14:20:23 +08:00
_shadowNode->retain();
_shadowNode->updateDisplayedColor(_displayedColor);
_shadowNode->updateDisplayedOpacity(_displayedOpacity);
}
}
void Label::setCameraMask(unsigned short mask, bool applyChildren)
{
2015-07-07 14:20:23 +08:00
Node::setCameraMask(mask, applyChildren);
if (_textSprite)
{
_textSprite->setCameraMask(mask, applyChildren);
}
if (_shadowNode)
{
_shadowNode->setCameraMask(mask, applyChildren);
}
}
void Label::setFontDefinition(const FontDefinition& textDefinition)
{
2015-07-14 11:30:56 +08:00
_systemFont = textDefinition._fontName;
_systemFontSize = textDefinition._fontSize;
_hAlignment = textDefinition._alignment;
_vAlignment = textDefinition._vertAlignment;
setDimensions(textDefinition._dimensions.width, textDefinition._dimensions.height);
Color4B textColor = Color4B(textDefinition._fontFillColor);
textColor.a = textDefinition._fontAlpha;
setTextColor(textColor);
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
2015-07-14 11:30:56 +08:00
if (textDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Stroke Currently only supported on iOS and Android!");
}
2015-07-14 11:30:56 +08:00
_outlineSize = 0.f;
#else
if (textDefinition._stroke._strokeEnabled && textDefinition._stroke._strokeSize > 0.f)
{
Color4B outlineColor = Color4B(textDefinition._stroke._strokeColor);
outlineColor.a = textDefinition._stroke._strokeAlpha;
enableOutline(outlineColor, textDefinition._stroke._strokeSize);
}
#endif
2015-07-14 11:30:56 +08:00
if (textDefinition._shadow._shadowEnabled)
{
2015-07-14 11:30:56 +08:00
enableShadow(Color4B(0, 0, 0, 255 * textDefinition._shadow._shadowOpacity),
textDefinition._shadow._shadowOffset, textDefinition._shadow._shadowBlur);
}
}
void Label::updateContent()
{
if (_systemFontDirty)
2014-05-12 14:34:25 +08:00
{
if (_fontAtlas)
{
_batchNodes.clear();
CC_SAFE_RELEASE_NULL(_reusedLetter);
FontAtlasCache::releaseFontAtlas(_fontAtlas);
_fontAtlas = nullptr;
}
_systemFontDirty = false;
}
2015-07-07 14:20:23 +08:00
CC_SAFE_RELEASE_NULL(_textSprite);
CC_SAFE_RELEASE_NULL(_shadowNode);
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
bool updateFinished = true;
if (_fontAtlas)
{
std::u32string utf32String;
if (StringUtils::UTF8ToUTF32(_utf8Text, utf32String))
{
_utf32Text = utf32String;
}
computeHorizontalKernings(_utf32Text);
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
updateFinished = alignText();
}
else
{
2015-07-14 13:47:35 +08:00
auto fontDef = _getFontDefinition();
2015-07-14 11:30:56 +08:00
createSpriteForSystemFont(fontDef);
if (_shadowEnabled)
2014-03-31 15:45:06 +08:00
{
2015-07-14 11:30:56 +08:00
createShadowSpriteForSystemFont(fontDef);
2014-03-31 15:45:06 +08:00
}
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_underlineNode)
{
_underlineNode->clear();
if (_numberOfLines)
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
{
// This is the logic for TTF fonts
const float charheight = (_textDesiredHeight / _numberOfLines);
_underlineNode->setLineWidth(charheight/6);
// atlas font
for (int i=0; i<_numberOfLines; ++i)
{
float offsety = 0;
if (_strikethroughEnabled)
offsety += charheight / 2;
// FIXME: Might not work with different vertical alignments
float y = (_numberOfLines - i - 1) * charheight + offsety;
// Github issue #15214. Uses _displayedColor instead of _textColor for the underline.
// This is to have the same behavior of SystemFonts.
_underlineNode->drawLine(Vec2(_linesOffsetX[i],y), Vec2(_linesWidth[i] + _linesOffsetX[i],y), Color4F(_displayedColor));
}
}
else if (_textSprite)
{
// ...and is the logic for System fonts
float y = 0;
const auto spriteSize = _textSprite->getContentSize();
_underlineNode->setLineWidth(spriteSize.height/6);
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_strikethroughEnabled)
// FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT
y += spriteSize.height / 2;
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
// FIXME: Might not work with different vertical alignments
_underlineNode->drawLine(Vec2(0,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(updateFinished){
_contentDirty = false;
}
#if CC_LABEL_DEBUG_DRAW
_debugDrawNode->clear();
Vec2 vertices[4] =
{
Vec2::ZERO,
Vec2(_contentSize.width, 0),
Vec2(_contentSize.width, _contentSize.height),
Vec2(0, _contentSize.height)
};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F::WHITE);
#endif
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
void Label::setBMFontSize(float fontSize)
{
this->setBMFontSizeInternal(fontSize);
_originalFontSize = fontSize;
}
float Label::getBMFontSize()const
{
return _bmFontSize;
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
void Label::onDrawShadow(GLProgram* glProgram, const Color4F& shadowColor)
2015-07-07 14:20:23 +08:00
{
2015-07-08 17:59:24 +08:00
if (_currentLabelType == LabelType::TTF)
2015-07-07 14:20:23 +08:00
{
if (_currLabelEffect == LabelEffect::OUTLINE)
2015-07-08 17:59:24 +08:00
{
glProgram->setUniformLocationWith1i(_uniformEffectType, 2); // 2: shadow
glProgram->setUniformLocationWith4f(_uniformEffectColor, shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a);
}
else
2015-07-08 17:59:24 +08:00
{
glProgram->setUniformLocationWith4f(_uniformTextColor, shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a);
if (_currLabelEffect == LabelEffect::GLOW)
{
glProgram->setUniformLocationWith4f(_uniformEffectColor, shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a);
}
2015-07-08 17:59:24 +08:00
}
glProgram->setUniformsForBuiltins(_shadowTransform);
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-08 17:59:24 +08:00
{
it.second->updateTransform();
}
2015-07-16 14:08:59 +08:00
for (auto&& batchNode : _batchNodes)
2015-07-08 17:59:24 +08:00
{
batchNode->getTextureAtlas()->drawQuads();
}
}
else
{
Color3B oldColor = _realColor;
GLubyte oldOPacity = _displayedOpacity;
_displayedOpacity = shadowColor.a * (oldOPacity / 255.0f) * 255;
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
setColor(Color3B(shadowColor));
2015-07-08 17:59:24 +08:00
glProgram->setUniformsForBuiltins(_shadowTransform);
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-08 17:59:24 +08:00
{
it.second->updateTransform();
}
2015-07-16 14:08:59 +08:00
for (auto&& batchNode : _batchNodes)
2015-07-08 17:59:24 +08:00
{
batchNode->getTextureAtlas()->drawQuads();
}
_displayedOpacity = oldOPacity;
setColor(oldColor);
2015-07-07 14:20:23 +08:00
}
2015-07-08 17:59:24 +08:00
}
2015-07-07 14:20:23 +08:00
void Label::onDraw(const Mat4& transform, bool /*transformUpdated*/)
2015-07-08 17:59:24 +08:00
{
2015-07-07 14:20:23 +08:00
auto glprogram = getGLProgram();
glprogram->use();
2018-09-11 14:39:30 +08:00
utils::setBlending(_blendFunc.src, _blendFunc.dst);
2015-07-07 14:20:23 +08:00
if (_shadowEnabled)
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_boldEnabled)
onDrawShadow(glprogram, _textColorF);
else
onDrawShadow(glprogram, _shadowColor4F);
2015-07-07 14:20:23 +08:00
}
glprogram->setUniformsForBuiltins(transform);
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-07 14:20:23 +08:00
{
it.second->updateTransform();
}
if (_currentLabelType == LabelType::TTF)
{
switch (_currLabelEffect) {
case LabelEffect::OUTLINE:
// draw outline of text
glprogram->setUniformLocationWith1i(_uniformEffectType, 1); // 1: outline
2015-07-07 14:20:23 +08:00
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
2015-07-16 14:08:59 +08:00
for (auto&& batchNode : _batchNodes)
2015-07-07 14:20:23 +08:00
{
batchNode->getTextureAtlas()->drawQuads();
}
// draw text without outline
glprogram->setUniformLocationWith1i(_uniformEffectType, 0); // 0: text
glprogram->setUniformLocationWith4f(_uniformTextColor, _textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a);
2015-07-07 14:20:23 +08:00
break;
case LabelEffect::GLOW:
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
case LabelEffect::NORMAL:
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a);
break;
default:
break;
}
}
2015-07-16 14:08:59 +08:00
for (auto&& batchNode : _batchNodes)
2015-07-07 14:20:23 +08:00
{
batchNode->getTextureAtlas()->drawQuads();
}
}
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_batchNodes.empty() || _lengthOfString <= 0)
2015-07-08 17:59:24 +08:00
{
return;
}
2015-07-07 14:20:23 +08:00
// Don't do calculate the culling if the transform was not updated
bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY;
#if CC_USE_CULLING
2015-07-30 13:59:50 +08:00
auto visitingCamera = Camera::getVisitingCamera();
auto defaultCamera = Camera::getDefaultCamera();
if (visitingCamera == defaultCamera) {
_insideBounds = (transformUpdated || visitingCamera->isViewProjectionUpdated()) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
}
else
{
_insideBounds = renderer->checkVisibility(transform, _contentSize);
}
2015-07-07 14:20:23 +08:00
if (_insideBounds)
#endif
{
if (!_shadowEnabled && (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP))
{
2015-08-05 00:21:06 +08:00
for (auto&& it : _letters)
{
it.second->updateTransform();
}
// ETC1 ALPHA supports for BMFONT & CHARMAP
auto textureAtlas = _batchNodes.at(0)->getTextureAtlas();
auto texture = textureAtlas->getTexture();
_quadCommand.init(_globalZOrder, texture, getGLProgramState(),
_blendFunc, textureAtlas->getQuads(), textureAtlas->getTotalQuads(), transform, flags);
renderer->addCommand(&_quadCommand);
}
else
{
_customCommand.init(_globalZOrder, transform, flags);
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
2015-07-07 14:20:23 +08:00
renderer->addCommand(&_customCommand);
}
2015-07-07 14:20:23 +08:00
}
}
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (! _visible || (_utf8Text.empty() && _children.empty()) )
{
return;
}
if (_systemFontDirty || _contentDirty)
{
updateContent();
}
uint32_t flags = processParentFlags(parentTransform, parentFlags);
if (!_utf8Text.empty() && _shadowEnabled && (_shadowDirty || (flags & FLAGS_DIRTY_MASK)))
{
_position.x += _shadowOffset.width;
_position.y += _shadowOffset.height;
_transformDirty = _inverseDirty = true;
_shadowTransform = transform(parentTransform);
_position.x -= _shadowOffset.width;
_position.y -= _shadowOffset.height;
_transformDirty = _inverseDirty = true;
_shadowDirty = false;
}
2015-07-07 14:20:23 +08:00
bool visibleByCamera = isVisitableByVisitingCamera();
if (_children.empty() && !_textSprite && !visibleByCamera)
{
return;
}
// IMPORTANT:
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
_director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
2015-07-07 14:20:23 +08:00
if (!_children.empty())
{
sortAllChildren();
int i = 0;
// draw children zOrder < 0
for (auto size = _children.size(); i < size; ++i)
2015-07-07 14:20:23 +08:00
{
auto node = _children.at(i);
if (node && node->getLocalZOrder() < 0)
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
this->drawSelf(visibleByCamera, renderer, flags);
2015-07-07 14:20:23 +08:00
for (auto it = _children.cbegin() + i, itCend = _children.cend(); it != itCend; ++it)
2015-07-07 14:20:23 +08:00
{
(*it)->visit(renderer, _modelViewTransform, flags);
}
}
else
2015-07-07 14:20:23 +08:00
{
this->drawSelf(visibleByCamera, renderer, flags);
2015-07-07 14:20:23 +08:00
}
_director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
void Label::drawSelf(bool visibleByCamera, Renderer* renderer, uint32_t flags)
2015-07-07 14:20:23 +08:00
{
if (_textSprite)
{
if (_shadowNode)
{
2015-04-13 16:28:55 +08:00
_shadowNode->visit(renderer, _modelViewTransform, flags);
}
2015-04-13 16:28:55 +08:00
_textSprite->visit(renderer, _modelViewTransform, flags);
}
else if (visibleByCamera && !_utf8Text.empty())
{
draw(renderer, _modelViewTransform, flags);
}
}
void Label::setSystemFontName(const std::string& systemFont)
{
if (systemFont != _systemFont)
{
_systemFont = systemFont;
_currentLabelType = LabelType::STRING_TEXTURE;
2014-05-08 21:30:12 +08:00
_systemFontDirty = true;
}
}
void Label::setSystemFontSize(float fontSize)
{
if (_systemFontSize != fontSize)
{
_systemFontSize = fontSize;
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_originalFontSize = fontSize;
_currentLabelType = LabelType::STRING_TEXTURE;
2014-05-08 21:30:12 +08:00
_systemFontDirty = true;
}
}
///// PROTOCOL STUFF
Sprite* Label::getLetter(int letterIndex)
{
2015-07-07 14:20:23 +08:00
Sprite* letter = nullptr;
do
{
2015-07-07 14:20:23 +08:00
if (_systemFontDirty || _currentLabelType == LabelType::STRING_TEXTURE)
{
break;
}
2015-07-07 14:20:23 +08:00
auto contentDirty = _contentDirty;
if (contentDirty)
{
updateContent();
}
if (_textSprite == nullptr && letterIndex < _lengthOfString)
2015-07-07 14:20:23 +08:00
{
const auto &letterInfo = _lettersInfo[letterIndex];
2017-05-05 22:50:04 +08:00
if (!letterInfo.valid || letterInfo.atlasIndex<0)
2015-07-07 14:20:23 +08:00
{
break;
}
2015-07-07 14:20:23 +08:00
if (_letters.find(letterIndex) != _letters.end())
{
letter = _letters[letterIndex];
}
2015-07-07 14:20:23 +08:00
if (letter == nullptr)
{
auto& letterDef = _fontAtlas->_letterDefinitions[letterInfo.utf32Char];
auto textureID = letterDef.textureID;
Rect uvRect;
uvRect.size.height = letterDef.height;
uvRect.size.width = letterDef.width;
uvRect.origin.x = letterDef.U;
uvRect.origin.y = letterDef.V;
if (letterDef.width <= 0.f || letterDef.height <= 0.f)
{
letter = LabelLetter::create();
}
else
{
this->updateBMFontScale();
letter = LabelLetter::createWithTexture(_fontAtlas->getTexture(textureID), uvRect);
letter->setTextureAtlas(_batchNodes.at(textureID)->getTextureAtlas());
letter->setAtlasIndex(letterInfo.atlasIndex);
auto px = letterInfo.positionX + _bmfontScale * uvRect.size.width / 2 + _linesOffsetX[letterInfo.lineIndex];
auto py = letterInfo.positionY - _bmfontScale * uvRect.size.height / 2 + _letterOffsetY;
letter->setPosition(px,py);
letter->setOpacity(_realOpacity);
this->updateLetterSpriteScale(letter);
}
2015-07-07 14:20:23 +08:00
addChild(letter);
_letters[letterIndex] = letter;
}
}
2015-07-07 14:20:23 +08:00
} while (false);
2015-07-07 14:20:23 +08:00
return letter;
}
void Label::setLineHeight(float height)
{
2014-06-12 14:41:01 +08:00
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
if (_lineHeight != height)
{
_lineHeight = height;
_contentDirty = true;
}
}
float Label::getLineHeight() const
{
2014-06-12 14:41:01 +08:00
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
return _textSprite ? 0.0f : _lineHeight * _bmfontScale;
}
2015-09-29 00:02:17 +08:00
void Label::setLineSpacing(float height)
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if (_lineSpacing != height)
{
_lineSpacing = height;
_contentDirty = true;
}
2015-09-29 00:02:17 +08:00
}
float Label::getLineSpacing() const
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return _lineSpacing;
2015-09-29 00:02:17 +08:00
}
void Label::setAdditionalKerning(float space)
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_currentLabelType != LabelType::STRING_TEXTURE)
{
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
if (_additionalKerning != space)
{
_additionalKerning = space;
_contentDirty = true;
}
}
Adds xml support in UIRichText Supported tags: - <small>: makes the font 20% smaller - <big>: makes the font 25% bigger - <img src="" />: to add an image - <font face="path to font" size="size" color="#00ffaa">: font attributes - <i>: italics - <b>: bold - <u>: underline - <del> strike-through - </br>: new line Also adds support for strikethrough, italics, bold and underlie to `Label` Contains tests for UIRichText and Label Squashed commit of the following: commit a0d6ae0513d40dbf414930210ab032a49d8984a0 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:39:21 2016 -0800 cleanup LabelTestNew commit 0cf423af85d88a42fc1317207feeb3d05da7f8ab Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 19 20:34:53 2016 -0800 adds maaaany tests ...and fixes width and height in <img src=""> commit e8ba6acd5d79bbc766d7aa02ef166e166c801d01 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 19:41:37 2016 -0800 Label + URL working Ok commit 36689e29ee3d77310e92264a09084cc06e30664c Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 15 18:24:44 2016 -0800 adding this code just in case... ... should use a listener component instead commit af03708950e74483b875d0baad593aa6ed242a04 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 14 20:23:36 2016 -0800 URL node plus <de><u> and <a img commit e3a4930b012c0b3756752dac6ffb5ad43d24ae99 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed Jan 13 18:42:18 2016 -0800 strikethrough and underline implemented they support multiline and horizontal alignment as well includes test however vertical alignment might not work commit 640ccf39f56e153db46785a61be7000e898174c7 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 18:14:57 2016 -0800 bug fixes commit 5e41fb76e91c571639585a609a255eb41797a302 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 16:47:20 2016 -0800 adds italics and bold "disable test" commit 202c5a45bb9c8ea160b9f6880ef858874e07814b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Tue Jan 12 14:40:13 2016 -0800 adds italics test commit d1a8b421445053cc36860fc376f52692a3672dfe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Mon Jan 11 20:53:23 2016 -0800 italics is working ok commit fdd02087fce920c27c2409301ec88685fe68085b Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri Jan 8 17:18:56 2016 -0800 color, size and face working commit c01bdef6b1d49f8805b69d4c162b74cd00c8f5b3 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu Jan 7 19:02:16 2016 -0800 initial commit
2016-01-20 12:41:31 +08:00
else
CCLOG("Label::setAdditionalKerning not supported on LabelType::STRING_TEXTURE");
}
float Label::getAdditionalKerning() const
{
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
return _additionalKerning;
}
void Label::computeStringNumLines()
{
int quantityOfLines = 1;
if (_utf32Text.empty())
{
_numberOfLines = 0;
return;
}
// count number of lines
size_t stringLen = _utf32Text.length();
for (size_t i = 0; i < stringLen - 1; ++i)
{
if (_utf32Text[i] == StringUtils::UnicodeCharacters::NewLine)
{
quantityOfLines++;
}
}
_numberOfLines = quantityOfLines;
}
int Label::getStringNumLines()
{
if (_contentDirty)
{
updateContent();
}
if (_currentLabelType == LabelType::STRING_TEXTURE)
{
computeStringNumLines();
}
return _numberOfLines;
}
int Label::getStringLength()
{
_lengthOfString = static_cast<int>(_utf32Text.length());
return _lengthOfString;
}
// RGBA protocol
void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
{
2014-10-09 10:54:35 +08:00
if (isOpacityModifyRGB != _isOpacityModifyRGB)
{
_isOpacityModifyRGB = isOpacityModifyRGB;
updateColor();
}
}
void Label::updateDisplayedColor(const Color3B& parentColor)
{
2015-07-07 14:20:23 +08:00
Node::updateDisplayedColor(parentColor);
if (_textSprite)
{
_textSprite->updateDisplayedColor(_displayedColor);
}
if (_shadowNode)
{
_shadowNode->updateDisplayedColor(_displayedColor);
}
if (_underlineNode)
{
// FIXME: _underlineNode is not a sprite/label. It is a DrawNode
// and updating its color doesn't work. it must be re-drawn,
// which makes it super expensive to change update it frequently
// Correct solution is to update the DrawNode directly since we know it is
// a line. Returning a pointer to the line is an option
_contentDirty = true;
}
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
{
2016-09-12 09:45:34 +08:00
it.second->updateDisplayedColor(_displayedColor);
}
}
void Label::updateDisplayedOpacity(GLubyte parentOpacity)
{
2015-07-07 14:20:23 +08:00
Node::updateDisplayedOpacity(parentOpacity);
if (_textSprite)
{
_textSprite->updateDisplayedOpacity(_displayedOpacity);
if (_shadowNode)
{
_shadowNode->updateDisplayedOpacity(_displayedOpacity);
}
}
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
{
2016-09-12 09:45:34 +08:00
it.second->updateDisplayedOpacity(_displayedOpacity);
}
}
// FIXME: it is not clear what is the difference between setTextColor() and setColor()
// if setTextColor() only changes the text and nothing but the text (no glow, no outline, not underline)
// that's fine but it should be documented
void Label::setTextColor(const Color4B &color)
{
2014-06-12 14:41:01 +08:00
CCASSERT(_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::STRING_TEXTURE, "Only supported system font and ttf!");
2015-07-14 11:30:56 +08:00
if (_currentLabelType == LabelType::STRING_TEXTURE && _textColor != color)
{
_contentDirty = true;
}
_textColor = color;
_textColorF.r = _textColor.r / 255.0f;
_textColorF.g = _textColor.g / 255.0f;
_textColorF.b = _textColor.b / 255.0f;
_textColorF.a = _textColor.a / 255.0f;
}
void Label::updateColor()
{
2015-07-07 14:20:23 +08:00
if (_batchNodes.empty())
{
return;
}
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
// special opacity for premultiplied textures
if (_isOpacityModifyRGB)
{
color4.r *= _displayedOpacity/255.0f;
color4.g *= _displayedOpacity/255.0f;
color4.b *= _displayedOpacity/255.0f;
}
cocos2d::TextureAtlas* textureAtlas;
V3F_C4B_T2F_Quad *quads;
2015-07-16 14:08:59 +08:00
for (auto&& batchNode:_batchNodes)
{
textureAtlas = batchNode->getTextureAtlas();
quads = textureAtlas->getQuads();
auto count = textureAtlas->getTotalQuads();
for (int index = 0; index < count; ++index)
{
quads[index].bl.colors = color4;
quads[index].br.colors = color4;
quads[index].tl.colors = color4;
quads[index].tr.colors = color4;
textureAtlas->updateQuad(&quads[index], index);
}
}
}
std::string Label::getDescription() const
{
char tmp[50];
sprintf(tmp, "<Label | Tag = %d, Label = >", _tag);
std::string ret = tmp;
ret += _utf8Text;
return ret;
}
const Size& Label::getContentSize() const
{
if (_systemFontDirty || _contentDirty)
{
const_cast<Label*>(this)->updateContent();
}
return _contentSize;
}
Rect Label::getBoundingBox() const
{
const_cast<Label*>(this)->getContentSize();
return Node::getBoundingBox();
}
2014-03-31 15:45:06 +08:00
void Label::setBlendFunc(const BlendFunc &blendFunc)
{
_blendFunc = blendFunc;
_blendFuncDirty = true;
if (_textSprite)
{
_textSprite->setBlendFunc(blendFunc);
if (_shadowNode)
{
_shadowNode->setBlendFunc(blendFunc);
}
}
}
2015-07-07 14:20:23 +08:00
void Label::removeAllChildrenWithCleanup(bool cleanup)
{
Node::removeAllChildrenWithCleanup(cleanup);
_letters.clear();
}
void Label::removeChild(Node* child, bool cleanup /* = true */)
{
Node::removeChild(child, cleanup);
2015-07-16 14:08:59 +08:00
for (auto&& it : _letters)
2015-07-07 14:20:23 +08:00
{
if (it.second == child)
{
_letters.erase(it.first);
break;
}
}
}
2015-07-14 11:30:56 +08:00
FontDefinition Label::_getFontDefinition() const
{
FontDefinition systemFontDef;
std::string fontName = _systemFont;
if (_fontAtlas && !_fontAtlas->getFontName().empty()) fontName = _fontAtlas->getFontName();
systemFontDef._fontName = fontName;
2015-07-14 11:30:56 +08:00
systemFontDef._fontSize = _systemFontSize;
systemFontDef._alignment = _hAlignment;
systemFontDef._vertAlignment = _vAlignment;
systemFontDef._dimensions.width = _labelWidth;
systemFontDef._dimensions.height = _labelHeight;
systemFontDef._fontFillColor.r = _textColor.r;
systemFontDef._fontFillColor.g = _textColor.g;
systemFontDef._fontFillColor.b = _textColor.b;
systemFontDef._fontAlpha = _textColor.a;
systemFontDef._shadow._shadowEnabled = false;
systemFontDef._enableWrap = _enableWrap;
systemFontDef._overflow = (int)_overflow;
2015-07-14 11:30:56 +08:00
if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0.f)
{
systemFontDef._stroke._strokeEnabled = true;
systemFontDef._stroke._strokeSize = _outlineSize;
systemFontDef._stroke._strokeColor.r = _effectColorF.r * 255;
systemFontDef._stroke._strokeColor.g = _effectColorF.g * 255;
systemFontDef._stroke._strokeColor.b = _effectColorF.b * 255;
systemFontDef._stroke._strokeAlpha = _effectColorF.a * 255;
}
else
{
systemFontDef._stroke._strokeEnabled = false;
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
if (systemFontDef._stroke._strokeEnabled)
{
CCLOGERROR("Stroke Currently only supported on iOS and Android!");
2015-07-14 11:30:56 +08:00
}
systemFontDef._stroke._strokeEnabled = false;
#endif
return systemFontDef;
}
void Label::setGlobalZOrder(float globalZOrder)
{
Node::setGlobalZOrder(globalZOrder);
if (_textSprite)
{
_textSprite->setGlobalZOrder(globalZOrder);
if (_shadowNode)
{
_shadowNode->setGlobalZOrder(globalZOrder);
}
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
float Label::getRenderingFontSize()const
{
float fontSize;
if (_currentLabelType == LabelType::BMFONT) {
fontSize = _bmFontSize;
}else if(_currentLabelType == LabelType::TTF){
fontSize = this->getTTFConfig().fontSize;
}else if(_currentLabelType == LabelType::STRING_TEXTURE){
fontSize = _systemFontSize;
2015-12-09 00:45:39 +08:00
}else{ //FIXME: find a way to calculate char map font size
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
fontSize = this->getLineHeight();
}
return fontSize;
}
void Label::enableWrap(bool enable)
{
if(enable == _enableWrap || _overflow == Overflow::RESIZE_HEIGHT){
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return;
}
this->_enableWrap = enable;
this->rescaleWithOriginalFontSize();
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
_contentDirty = true;
}
bool Label::isWrapEnabled()const
{
return this->_enableWrap;
}
void Label::setOverflow(Overflow overflow)
{
2015-11-20 10:54:05 +08:00
if(_overflow == overflow){
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
return;
}
2015-11-20 10:54:05 +08:00
if (_currentLabelType == LabelType::CHARMAP) {
if (overflow == Overflow::SHRINK) {
return;
}
}
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
if(overflow == Overflow::RESIZE_HEIGHT){
this->setDimensions(_labelDimensions.width,0);
this->enableWrap(true);
}
_overflow = overflow;
this->rescaleWithOriginalFontSize();
_contentDirty = true;
}
void Label::rescaleWithOriginalFontSize()
{
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
auto renderingFontSize = this->getRenderingFontSize();
if (_originalFontSize - renderingFontSize >= 1) {
Add Label Overflow and wrap option. Squashed commit of the following: commit 7176582def3686f78701f92ead4d0976bccd115d Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 19 10:30:54 2015 +0800 add char map font test commit 7ea7c251ff549e4a74d5c5c3faa49893fe5defc4 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 15:00:17 2015 +0800 system font overflow is not supported commit a02fe0c7f94692b95a0bfd6f194a94c4519cee3a Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 18 11:04:15 2015 +0800 add system font test commit eb098da8b16f485c86929a9b2ba00a64068264e9 Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 17 10:29:35 2015 +0800 Finish resize height mode commit ca78ba35abdbacc23bf6f8315454ec0a356a6aca Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 16 11:01:27 2015 +0800 fix wrap issue commit baf1a5e0dc3a08da0a13500aea5afc82017b054a Author: zilongshanren <guanghui8827@126.com> Date: Sat Nov 14 08:28:57 2015 +0800 horizontal shrink still has a issue commit 7e8abc0990cdf299d23c8072c5c1d4aa561bf798 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 11:42:34 2015 +0800 finish shrink without wrap commit c9c45bd1f304ba00a6f9a274fa5631659a075bc1 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 13 10:09:46 2015 +0800 update shrink commit ad82010ea846679e4d1a09f5127be29ae2e6adae Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 12 17:55:15 2015 +0800 refactor shrink logic commit effc1ee1cd9f06eaa4f46dd5c2a1401f6a285af6 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 18:25:34 2015 +0800 add resize overflow type commit 194d552adc2a4ba2c439eff969b082556315e0ae Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 11 11:49:51 2015 +0800 no wrap, shrink is working. commit e2222ef14d5392817bd727895b3c2caec5ce4faf Author: zilongshanren <guanghui8827@126.com> Date: Tue Nov 10 16:16:27 2015 +0800 add overflow type to label. 1. optimize the testcase commit b65e2de4bfb3cb86a0d0cfa118be891a3f9fe858 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:22:34 2015 +0800 finish bmfont wrap by char commit f339ff0309dc9e2ca2871f03f4551d329afce5e1 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 17:04:51 2015 +0800 finish bmfont wrap by word commit 4c8edc65204a1294ac81315e72f1299acbdf43c0 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 11:29:21 2015 +0800 add BMFont size support commit 3282481bda9dcb0f88b41f2568f7e5c856af6d53 Author: zilongshanren <guanghui8827@126.com> Date: Mon Nov 9 09:58:01 2015 +0800 add font size support for BMFONT commit 0c8e2a0374983625507a183cb2eb53a0b1709e25 Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 16:36:27 2015 +0800 add toggle wrap option. 1. make hirozontal clamp working commit 19dcd3e80a34c54b20934d08937eb270e689a7db Author: zilongshanren <guanghui8827@126.com> Date: Fri Nov 6 15:12:59 2015 +0800 tweak label layout commit e36a40babf4817ea7e9830614ac7560f2e69c583 Author: zilongshanren <guanghui8827@126.com> Date: Thu Nov 5 11:11:02 2015 +0800 finish the test skeleton commit a144a3a5d388d15c4f37cbfc12563eccabffb8e1 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 16:38:54 2015 +0800 add setFontSize api to label. 1. add new chinese-english bmfont 2. beautify base test commit b22551c9eb3738fbb1c38ae4a3bfd07a202dcaf0 Author: zilongshanren <guanghui8827@126.com> Date: Wed Nov 4 11:27:18 2015 +0800 add label layout test skeleton
2015-11-19 16:06:13 +08:00
this->scaleFontSizeDown(_originalFontSize);
}
}
Label::Overflow Label::getOverflow()const
{
return _overflow;
}
void Label::updateLetterSpriteScale(Sprite* sprite)
{
if (_currentLabelType == LabelType::BMFONT && _bmFontSize > 0)
{
sprite->setScale(_bmfontScale);
}
else
{
if (std::abs(_bmFontSize) < FLT_EPSILON)
{
sprite->setScale(0);
}
else
{
sprite->setScale(1.0);
}
}
}
NS_CC_END