add function for uiText and uiTextField

This commit is contained in:
Liam 2015-01-20 18:40:25 +08:00
parent e8fa6597df
commit a72e65b4de
4 changed files with 21 additions and 0 deletions

View File

@ -283,6 +283,11 @@ void Text::adaptRenderers()
}
Size Text::getVirtualRendererSize() const
{
return _labelRenderer->getContentSize();
}
Size Text::getAutoRenderSize()
{
Size virtualSize = _labelRenderer->getContentSize();
if (!_ignoreSize)

View File

@ -144,6 +144,8 @@ public:
//override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer() override;
virtual Size getAutoRenderSize();
/**
* Returns the "class name" of widget.
*/

View File

@ -768,6 +768,19 @@ void TextField::textfieldRendererScaleChangedWithSize()
_textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
}
Size TextField::getAutoRenderSize()
{
Size virtualSize = _textFieldRenderer->getContentSize();
if (!_ignoreSize)
{
_textFieldRenderer->setDimensions(0, 0);
virtualSize = _textFieldRenderer->getContentSize();
_textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
}
return virtualSize;
}
Size TextField::getVirtualRendererSize() const
{
return _textFieldRenderer->getContentSize();

View File

@ -187,6 +187,7 @@ public:
*/
virtual std::string getDescription() const override;
virtual Size getAutoRenderSize();
virtual Size getVirtualRendererSize() const override;
virtual Node* getVirtualRenderer() override;
void attachWithIME();