Now, I would expect the scrollbar to be immidiately visible since there are more lines of text that the element can show at once. Unfortunately it doesn't show up until I manually do something that causes the element to update itself (resizing the element or setting the text or font).
So I started digging through the falagard renderer source code. Here's the part in FalagardStaticText::configureScrollbars() that decides whether to show the scrollbars or not:
Code: Select all
Size documentSize(getDocumentSize(renderArea));
// show or hide vertical scroll bar as required (or as specified by option)
bool showVert = ((documentSize.d_height > renderAreaSize.d_height) && d_enableVertScrollbar);
bool showHorz = ((documentSize.d_width > renderAreaSize.d_width) && d_enableHorzScrollbar);
It uses documentSize that is returned by getDocumentSize function:
Code: Select all
Size FalagardStaticText::getDocumentSize(const Rect& renderArea) const
{
// we need a formatted string to really measure anything
if (!d_formattedRenderedString)
return Size(0, 0);
if (!d_formatValid)
updateFormatting(renderArea.getSize());
return Size(d_formattedRenderedString->getHorizontalExtent(),
d_formattedRenderedString->getVerticalExtent());
}
which returns (0,0) if d_formattedRenderedString is not set. And it seems that it's not set until the element is rendered for the first time. Thus the scrollbars won't be visible until configureScrollbars() is triggered again.
I didn't put much thought to this, but wouldn't removing the nil check for d_formattedRenderedString fix the problem? It's kind of redundant cause updateFormatting() will ensure that it exists.