From a9a16b3ee5091b25df516e560947899fc8f27c18 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 24 Jul 2014 11:51:47 +0800 Subject: [PATCH] fix RichText visit issue --- cocos/ui/UIRichText.cpp | 14 +++++--------- cocos/ui/UIRichText.h | 4 +++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 47ba055369..9f24571d79 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -461,6 +461,11 @@ void RichText::formarRenderers() _elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } +void RichText::adaptRenderers() +{ + this->formatText(); +} + void RichText::pushToContainer(cocos2d::Node *renderer) { if (_elementRenders.size() <= 0) @@ -469,15 +474,6 @@ void RichText::pushToContainer(cocos2d::Node *renderer) } _elementRenders[_elementRenders.size()-1]->pushBack(renderer); } - -void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) -{ - if (_enabled) - { - formatText(); - Widget::visit(renderer, parentTransform, parentFlags); - } -} void RichText::setVerticalSpace(float space) { diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index aa0ad7c410..62aca834a0 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -103,7 +103,7 @@ public: void pushBackElement(RichElement* element); void removeElement(int index); void removeElement(RichElement* element); - virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + void setVerticalSpace(float space); virtual void setAnchorPoint(const Vec2 &pt); virtual const Size& getVirtualRendererSize() const override; @@ -115,6 +115,8 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init() override; protected: + virtual void adaptRenderers(); + virtual void initRenderer(); void pushToContainer(Node* renderer); void handleTextRenderer(const std::string& text, const std::string& fontName, float fontSize, const Color3B& color, GLubyte opacity);