Page 1 of 1

[BUG] StaticText scrollbars not shown until element resized

Posted: Sun Feb 14, 2010 11:18
by Timo
First of all, I'm using version 0.7.1. I have a TaharezLook/StaticText element with several lines of text and the property "VertScrollbar" set to "True" in layout file. I load the layout before a single frame is rendered by the app.

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.

Re: [BUG] StaticText scrollbars not shown until element resized

Posted: Sun Feb 14, 2010 19:25
by CrazyEddie
Hi,

Thanks for raising the issue. Firstly I confirm this as an issue - it had been mentioned previously, and I was able to reproduce it, but did not add a ticket for it at the time. I have now added the ticket and the issue should get fixed soon.

I didn't think about the suggested fix too much, though on the surface it sounds a plausible solution ;)

Thanks,

CE.

Re: [BUG] StaticText scrollbars not shown until element resized

Posted: Sat Feb 20, 2010 11:18
by CrazyEddie
I have this fixed in branches/v0-7 r2432.

The fix was basically as you said - thanks ;)

CE.