If _ignoreSize is false Rich text sets _elementRenderersContainer size to content size instead of new size.
It is strange, because new height is already calculated inside this method and newer used.
Is it a bug?
please, add more info.
What is the expected result? what is the current result? could you post a screenshot?
in RichTextTest:
_richText = RichText::create();
_richText->ignoreContentAdaptWithSize(false);
_richText->setContentSize(Size(50, 100));
…
_widget->addChild(_richText);
_richText->formatText();
auto size = _richText->getVirtualRendererSize();
after adding a lot of text to _richText, so text height exceeds 100 pixels limit, returned virtual renderer size is steel 50x100
in RichText::formarRenderers, in the second branch ( _ignoreSize == false ):
... else
{
float newContentSizeHeight = 0.0f;
float *maxHeights = new float[_elementRenders.size()];
for (size_t i=0; i<_elementRenders.size(); i++)
{
Vector<Node*>* row = (_elementRenders[i]);
float maxHeight = 0.0f;
for (ssize_t j=0; j<row->size(); j++)
{
Node* l = row->at(j);
maxHeight = MAX(l->getContentSize().height, maxHeight);
}
maxHeights[i] = maxHeight;
newContentSizeHeight += maxHeights[i];
}
float nextPosY = _customSize.height;
for (size_t i=0; i<_elementRenders.size(); i++)
{
Vector<Node*>* row = (_elementRenders[i]);
float nextPosX = 0.0f;
nextPosY -= (maxHeights[i] + _verticalSpace);
for (ssize_t j=0; j<row->size(); j++)
{
Node* l = row->at(j);
l->setAnchorPoint(Vec2::ZERO);
l->setPosition(nextPosX, nextPosY);
_elementRenderersContainer->addChild(l, 1);
nextPosX += l->getContentSize().width;
}
}
_elementRenderersContainer->setContentSize(_contentSize);
delete [] maxHeights;
}...
looks like it must be:
_elementRenderersContainer->setContentSize(Size(_contentSize.width, newContentSizeHeight));
so it is possible to know new size of container after formatting text.
sorry, could you post an screenshot with the bug? Thanks.
Sorry for possible misunderstanding:
X is more than 100, but object’s virtual renderer size is still 100x100.
yes. thanks. seems to be a bug. could you open a ticket? thanks.
This seems to be happening into the JS as well… any news about any fix?