StaticText not updating. Bug?

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

IR3uL
Not too shy to talk
Not too shy to talk
Posts: 45
Joined: Wed Aug 25, 2010 00:32
Location: Buenos Aires - Argentina

StaticText not updating. Bug?

Postby IR3uL » Thu Sep 16, 2010 21:35

I was having an issue with the StaticText widget. Perhaps is the way i manage the windows in my project, perhaps it's me doing something wrong.

This thing is, when i resize my window (the application, not in-game window), the StaticText components does not get updated, causing the text to not be re-formatted; so, depending the case, i get a part of the control empty, or text outside of it (not visible of course).

I'm using the following layout in case is significant:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<GUILayout >
    <Window Type="TaharezLook/FrameWindow" Name="NotImplemented" >
        <Property Name="TitlebarFont" Value="DejaVuSans-10" />
        <Property Name="TitlebarEnabled" Value="True" />
        <Property Name="UnifiedAreaRect" Value="{{0.384664,0},{0.318391,0},{0.634664,0},{0.568391,0}}" />
        <Window Type="TaharezLook/StaticText">
            <Property Name="Text" Value="This is not implemented yet! Sorry =D" />
            <Property Name="HorzFormatting" Value="WordWrapCentred" />
            <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{0.75,0}}" />
            <Property Name="HorizontalAlignment" Value="Centre" />
        </Window>
        <Window Type="TaharezLook/Button" Name="NotImplemented/Close" >
            <Property Name="Text" Value="Close" />
            <Property Name="UnifiedAreaRect" Value="{{0,0},{0.75,0},{1,0},{1,0}}" />
        </Window>
    </Window>
</GUILayout>


I think it must be something to do with StaticText not beign a Window object per-se (which is the case with falagard controls, please someone correct me if i'm wrong), so when System::notifyDisplaySizeChanged() invalidates all windows, the StaticText does not know about this change.

I patched my code to handle the EventRenderingStarted to cause the StaticText to reformat the contents but i'm not sure if this is the corrent approach or i'm missing something ^^.

In case someone wants to check this issue (CE, *coff* *coff*), here's a patch. I'm working with svn rev. 2614 (basically 0.7.2 release).

Code: Select all

Index: cegui/include/WindowRendererSets/Falagard/FalStaticText.h
===================================================================
--- cegui/include/WindowRendererSets/Falagard/FalStaticText.h   (revisión: 2614)
+++ cegui/include/WindowRendererSets/Falagard/FalStaticText.h   (copia de trabajo)
@@ -187,6 +187,7 @@
         bool onSized(const EventArgs& e);
         bool onFontChanged(const EventArgs& e);
         bool onMouseWheel(const EventArgs& e);
+   bool onRenderingStarted(const EventArgs& e);
 
         // event subscribers
         bool handleScrollbarChange(const EventArgs& e);
Index: cegui/src/WindowRendererSets/Falagard/FalStaticText.cpp
===================================================================
--- cegui/src/WindowRendererSets/Falagard/FalStaticText.cpp   (revisión: 2614)
+++ cegui/src/WindowRendererSets/Falagard/FalStaticText.cpp   (copia de trabajo)
@@ -407,6 +407,17 @@
 
         return true;
     }
+   
+    /*************************************************************************
+        Handler called when d_window redraws
+    *************************************************************************/
+    bool FalagardStaticText::onRenderingStarted(const EventArgs&)
+    {
+   d_formatValid = false;
+   configureScrollbars();
+   
+   return true;
+    }
 
 
     /*************************************************************************
@@ -454,6 +465,10 @@
         d_connections.push_back(
             d_window->subscribeEvent(Window::EventMouseWheel,
                 Event::Subscriber(&FalagardStaticText::onMouseWheel, this)));
+   
+   d_connections.push_back(
+       d_window->subscribeEvent(Window::EventRenderingStarted,
+      Event::Subscriber(&FalagardStaticText::onRenderingStarted, this)));
     }
 
     void FalagardStaticText::onLookNFeelUnassigned()

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

Re: StaticText not updating. Bug?

Postby CrazyEddie » Tue Sep 21, 2010 09:10

Thanks for raising the issue and for a potential solution. I did not look into it yet, but I generally agree with your analysis as to why this type of issue might come up. I'll be adding a ticket for it, and assuming I can reproduce this issue, it should be fixed for the coming 0.7.3 release :)

CE.

IR3uL
Not too shy to talk
Not too shy to talk
Posts: 45
Joined: Wed Aug 25, 2010 00:32
Location: Buenos Aires - Argentina

Re: StaticText not updating. Bug?

Postby IR3uL » Thu Sep 23, 2010 16:45

Hi CE, i was making some more tests today with this and i found the error might be mine and not actually a bug, so i have a question now:

The function call order should be:
System::notifyDisplaySizeChanged()
Font::SetNativeResolution()
or the other way (works fine this way)? or it should not care?

When i handle resizing in my app a make calls to this functions to keep the aspect ratio consistent (with Imagesets too). If you want to reproduce this (in case you haven't done it yet) try this patch with the Sample helper

Code: Select all

Index: src/CEGuiOpenGLBaseApplication.cpp
===================================================================
--- src/CEGuiOpenGLBaseApplication.cpp  (revisión: 2614)
+++ src/CEGuiOpenGLBaseApplication.cpp  (copia de trabajo)
@@ -311,6 +311,7 @@
     glMatrixMode(GL_MODELVIEW);
     CEGUI::System::getSingleton().
         notifyDisplaySizeChanged(CEGUI::Size((float)w,(float)h));
+    CEGUI::System::getSingleton().getDefaultFont()->setNativeResolution(CEGUI::Size(w, h));
 }
 
 void CEGuiOpenGLBaseApplication::mouseMotion(int x, int y)


Btw, i'm getting a lot of fun hacking CEGUI ^^, thanks!

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

Re: StaticText not updating. Bug?

Postby CrazyEddie » Mon Sep 27, 2010 13:27

Well, really it should not matter which order the functions are called. I think (without having looked yet) it's basically to related to fonts and images not having any way to notify some window using them that they've changed size (because they don't know which windows are using them).

Thanks for the patch to recreate this, I will look into it soon (and hopefully it will not be our issue :lol: )

CE.

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

Re: StaticText not updating. Bug?

Postby CrazyEddie » Tue Oct 05, 2010 13:32

I looked into this today, and was able to reproduce an issue with the help of the change to the sample base app.

It's definitely an issue, and is related to the font changing size and having no way to report this information. I already had an existing ticket for similar cases, but not specifically this, although it definitely falls into the same general category of issue. There's elegant ways of implementing fixes and brute force methods also, I need to consider the options carefully ;)

What this means is that in the mean time you'll need to work around this issue :(

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 4 guests