Page 1 of 1

[Solved] Problem with word wrap and new widget embedding?

Posted: Tue Oct 20, 2009 03:32
by Serilyn
I used the new CEGUI (v0-7 branch revision 2298, since updated to 2328) for my Ludum Dare Mini entry last weekend. The widget embedding markup was helpful in making a wiki-browser-like window for game information, but I noticed a problem with word wrap and widgets. The green words are StaticText widgets. The first cutoff green widget should say "finback" and the second cutoff green widget should be "Mendelian Traits"
Image

I am using the Ogre renderer. The widget with the wrapping text is a WindowsLook/StaticText and the embedded widgets are also WindowsLook/StaticText widgets. Is there something I'm missing here or did I stumble on a bug?

Here is the essential section of my CEGUI log:

Code: Select all

19/10/2009 20:10:18 (Std)    ---- Version 0.7.1 (Build: Oct 17 2009 Debug Microsoft Windows MSVC++ 9.0 32 bit) ----
19/10/2009 20:10:18 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
19/10/2009 20:10:18 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
19/10/2009 20:10:18 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
19/10/2009 20:10:18 (Std)    ---- Scripting module is: None ----
19/10/2009 20:10:18 (Std)    

Re: Problem with word wrap and new widget embedding?

Posted: Tue Oct 20, 2009 07:10
by scriptkid
Hi and welcome :)

Do you mean that you are using a widget for the black text, and others for the green text? Word-wrapping only applies to strings, not to widgets. If you are using different widgets, do you know about the string colouring functionality?

For example you can now say:

Code: Select all

setText("This is black, [colour='FF00FF00']and this is green.");


That way, maybe you can simplify your widget so that it uses only one text box.

HTH.

Re: Problem with word wrap and new widget embedding?

Posted: Tue Oct 20, 2009 08:53
by CrazyEddie
Actually, the new string formatting can take child windows and reposition them dynamically in-line with the text and apply the formatting also to those windows (as demoed in some videos a while ago). I think OP is using this technique in order to detect clicks on that green text - like hyper-links.

Why the formatting is not working, I do not know, although I'll run a test. If it turns out to be a bug, I can't guarantee a fix until after the 0.7.1 release, since the code is frozen while that release is worked on. BTW, we don't normally work quite like this, but this release is a little different since myself and scriptkid are unable to sync-up for this release (because I am going away at the end of this week - see announcement later!) - so the code is frozen to ensure that whenever we make our packages we use the same code.

I'll let you know if I can reproduce the issue.

CE.

Re: Problem with word wrap and new widget embedding?

Posted: Tue Oct 20, 2009 10:41
by CrazyEddie
Yes, this is a bug that was introduced when I fixed another bug (as is the way ;)). The fix for this one is:

Code: Select all

Index: cegui/src/CEGUIRenderedString.cpp
===================================================================
--- cegui/src/CEGUIRenderedString.cpp   (revision 2330)
+++ cegui/src/CEGUIRenderedString.cpp   (working copy)
@@ -206,12 +206,14 @@
             ++left.d_lines[left_line].second;
         }
     }
-    // can't split, so xfer the whole component to the left (FIX #306)
-    else
+    // can't split, if component width is >= split_point xfer the whole
+    // component to it's own line in the left part (FIX #306)
+    else if (c->getPixelSize().d_width >= split_point)
     {
+        left.appendLineBreak();
         left.d_components.push_back(d_components[0]);
         d_components.erase(d_components.begin());
-        ++left.d_lines[left_line].second;
+        ++left.d_lines[left_line + 1].second;
         --d_lines[0].second;
     }


CE.

RE: Problem with word wrap and new widget embedding?

Posted: Tue Oct 20, 2009 16:55
by Serilyn
Yes using the widgets like hyper-links was precisely what I was doing. The fix works great. Thanks CE :D

Re: [Solved] Problem with word wrap and new widget embedding?

Posted: Wed Oct 21, 2009 08:37
by CrazyEddie
Great, glad it's working for you. And better than that, in spite of what I said above, we managed to get it in for the soon to be released 0.7.1 too :)

CE.

Re: [Solved] Problem with word wrap and new widget embedding?

Posted: Fri Nov 06, 2009 07:24
by kili
Hi CE,

There are still something strange:
Image
the words after [hyper-link] should follow it like:
Image

Would you please add one tag to separate English/Non-English Letters?
I've hacked such things in Font and MultiLineEditbox in 0.6x version,
but don't want to do the same thing in each new version. :(