From 7ece807a63118286edbd9dd851f3de1e2c11feac Mon Sep 17 00:00:00 2001 From: "Frank.Xu" Date: Thu, 5 Jun 2014 19:20:16 +0800 Subject: [PATCH] Add shadow, outline, glow filter support for UITextField --- cocos/ui/UIText.cpp | 18 ++++++++++++++++++ cocos/ui/UIText.h | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index 88b0aafa36..57bdb052e9 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -336,6 +336,24 @@ void Text::updateTextureRGBA() { updateRGBAToRenderer(_labelRenderer); } + +void Text::enableShadow(const Color4B& shadowColor,const Size &offset, int blurRadius) { + _labelRenderer->enableShadow(shadowColor, offset, blurRadius); +} + +void Text::enableOutline(const Color4B& outlineColor,int outlineSize) { + if (_type == Type::TTF) + _labelRenderer->enableOutline(outlineColor, outlineSize); +} + +void Text::enableGlow(const Color4B& glowColor) { + if (_type == Type::TTF) + _labelRenderer->enableGlow(glowColor); +} + +void Text::disableEffect() { + _labelRenderer->disableEffect(); +} Widget* Text::createCloneInstance() { diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index d0bc342a08..88084666c1 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -158,6 +158,22 @@ public: TextVAlignment getTextVerticalAlignment(); + /** + * Enable shadow for the label + * + * @todo support blur for shadow effect + */ + void enableShadow(const Color4B& shadowColor = Color4B::BLACK,const Size &offset = Size(2,-2), int blurRadius = 0); + + /** only support for TTF */ + void enableOutline(const Color4B& outlineColor,int outlineSize = -1); + + /** only support for TTF */ + void enableGlow(const Color4B& glowColor); + + /** disable shadow/outline/glow rendering */ + void disableEffect(); + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& textContent,