Page 1 of 1

StaticText not updating. Bug?

Posted: Thu Sep 16, 2010 21:35
by IR3uL
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()

Re: StaticText not updating. Bug?

Posted: Tue Sep 21, 2010 09:10
by CrazyEddie
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.

Re: StaticText not updating. Bug?

Posted: Thu Sep 23, 2010 16:45
by IR3uL
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!

Re: StaticText not updating. Bug?

Posted: Mon Sep 27, 2010 13:27
by CrazyEddie
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.

Re: StaticText not updating. Bug?

Posted: Tue Oct 05, 2010 13:32
by CrazyEddie
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.