Merge pull request #6044 from Dhilan007/develop_label

fixed getting wrong Rect by LabelTTF(LabelBMFont)::getBoundingBox.
This commit is contained in:
James Chen 2014-03-28 16:16:03 +08:00
commit 79d1bc5e88
6 changed files with 23 additions and 2 deletions

View File

@ -1361,7 +1361,7 @@ const Size& Label::getContentSize() const
{
const_cast<Label*>(this)->updateContent();
}
return Node::getContentSize();
return _contentSize;
}
Rect Label::getBoundingBox() const

View File

@ -243,7 +243,7 @@ public:
virtual const Size& getContentSize() const override;
virtual Rect getBoundingBox() const;
virtual Rect getBoundingBox() const override;
FontAtlas* getFontAtlas() { return _fontAtlas; }
/** Listen "come to background" message

View File

@ -191,6 +191,17 @@ void LabelBMFont::setColor(const Color3B& color)
_label->setColor(color);
}
const Size& LabelBMFont::getContentSize() const
{
const_cast<LabelBMFont*>(this)->setContentSize(_label->getContentSize());
return _contentSize;
}
Rect LabelBMFont::getBoundingBox() const
{
return _label->getBoundingBox();
}
//LabelBMFont - Debug draw
#if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::draw()

View File

@ -116,6 +116,9 @@ public:
virtual void setColor(const Color3B& color) override;
virtual const Size& getContentSize() const override;
virtual Rect getBoundingBox() const override;
virtual std::string getDescription() const override;
#if CC_LABELBMFONT_DEBUG_DRAW

View File

@ -278,6 +278,11 @@ const Size& LabelTTF::getContentSize() const
return _contentSize;
}
Rect LabelTTF::getBoundingBox() const
{
return _renderLabel->getBoundingBox();
}
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher

View File

@ -143,6 +143,8 @@ public:
virtual void setFlippedX(bool flippedX);
virtual void setFlippedY(bool flippedY);
virtual Rect getBoundingBox() const override;
/**
* @js NA
* @lua NA