[BUG] StaticText scrollbars not shown until element resized

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Timo
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Sun Feb 14, 2010 09:38

[BUG] StaticText scrollbars not shown until element resized

Postby Timo » Sun Feb 14, 2010 11:18

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

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

Postby CrazyEddie » Sun Feb 14, 2010 19:25

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

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

Postby CrazyEddie » Sat Feb 20, 2010 11:18

I have this fixed in branches/v0-7 r2432.

The fix was basically as you said - thanks ;)

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 11 guests