[Solved] Much faster static text widget

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

ShadowTiger
Quite a regular
Quite a regular
Posts: 46
Joined: Fri Mar 19, 2010 05:31

[Solved] Much faster static text widget

Postby ShadowTiger » Sat Jul 30, 2011 07:03

I need to do what CE suggested in this thread... however I have no idea how to do this.

" I would suggest skinning DefaultWindow using the Falagard/Default window renderer to create a basic label class and replace the static text instances with that, since - unless you want scrollbars and a bunch of other bloat in your labels - this will lighten the load considerably IMO."

viewtopic.php?f=10&t=5229&p=25505&hilit=static+text#p25505

Right now, I create all my windows using the create("") function in C++, I don't usually mess with layouts, looknfeels or schemes.

I tried modifying the existing windows such as WindowsLook/StaticText but it gives errors, I'm guessing i would have to change the CEGUI source code for this method to work.

the reason why I am doing this is for performance reasons, it seems like static text is about 10 times slower to create than a static image. Hopefully I can make them equal.

I am really lost here... maybe someone can give me a list of steps on how to do this?

Heres what I have:

1. Add a new entry to windowslook.looknfeel.
2. Add a new entry to windowslook.scheme and windowslookwidgets.scheme (why is there 2?)
3. Start using it in the code.

I'm using cegui 7.5.
Last edited by ShadowTiger on Tue Aug 02, 2011 23:14, edited 4 times in total.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: How do i create a lighter static text widget?

Postby Jamarr » Mon Aug 01, 2011 20:36

I believe this post covers everything: viewtopic.php?p=22795#p22795
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

ShadowTiger
Quite a regular
Quite a regular
Posts: 46
Joined: Fri Mar 19, 2010 05:31

Re: How do i create a lighter static text widget?

Postby ShadowTiger » Mon Aug 01, 2011 22:35

Hey, thanks to Jamarr for the link... great success.

I reduced the load time of my GUI from 1.156 seconds to 0.051 seconds... 95% reduction in load times!!!

That was with 61 Static Text widgets being used (in addition to dozens of image windows).

If you are using a static text widget... I highly recommend you implement this change immediately.

Heres the code to put in your looknfeel, I put in some properties for backwards compatibility. Note that frame enabled and background enabled don't do anything.

Edit: It looks like the spacing is different... trying to fix that now...

VertFormatProperty and HorzFormatProperty are not being used on the window...

to be specific, you can left/right and top/bottom align the text, but you cannot centre align them or word wrap them... making this window almost useless to me.

Code: Select all

<!--
    ***************************************************
        WindowsLook/StaticLabel
    ***************************************************
    -->
    <WidgetLook name="WindowsLook/StaticLabel">
    <PropertyDefinition name="FrameEnabled" initialValue="false" redrawOnWrite="false" />
    <PropertyDefinition name="BackgroundEnabled" initialValue="false" redrawOnWrite="false" />
    <PropertyDefinition name="TextColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF"  redrawOnWrite="true" />
    <PropertyDefinition name="VertFormatting" initialValue="CentreAligned" redrawOnWrite="true" />
    <PropertyDefinition name="HorzFormatting" initialValue="CentreAligned" redrawOnWrite="true" />
    <ImagerySection name="label">
        <TextComponent>
            <Area>
                <Dim type="LeftEdge"><AbsoluteDim value="0" /></Dim>
                <Dim type="TopEdge"><AbsoluteDim value="0" /></Dim>
                <Dim type="Width"><UnifiedDim scale="1" type="Width" /></Dim>
                <Dim type="Height"><UnifiedDim scale="1" type="Height" /></Dim>
            </Area>
            <VertFormatProperty name="VertFormatting" />
            <HorzFormatProperty name="HorzFormatting" />
        </TextComponent>
    </ImagerySection>
    <StateImagery name="Enabled">
        <Layer>
            <Section section="label">
         <ColourRectProperty name="TextColours" />
         </Section>
        </Layer>
    </StateImagery>
    <StateImagery name="Disabled">
        <Layer>
            <Section section="label">
         <ColourRectProperty name="TextColours" />
         </Section>
        </Layer>
    </StateImagery>
    </WidgetLook>



here is the addition to the .scheme file... pretty basic

Code: Select all

<FalagardMapping WindowType="WindowsLook/StaticLabel"      TargetType="DefaultWindow" Renderer="Falagard/Default"      LookNFeel="WindowsLook/StaticLabel" />

ShadowTiger
Quite a regular
Quite a regular
Posts: 46
Joined: Fri Mar 19, 2010 05:31

Re: [Almost Solved] How to create a lighter static text widg

Postby ShadowTiger » Tue Aug 02, 2011 00:24

Does anyone know if the default window renderer will allow me to use Word wrap and and centering of text?

It doesn't seem to work. Also, I tried using a static window renderer and that didn't seem to support this either, and I couldn't get colours to show up but maybe im doing it wrong.

I really feel like I should just modify the cegui library directly at this point since its so difficult to figure out what will work and what wont with the xml.

However I would like to avoid this if possible because it makes upgrading to new version harder. It would also be alot of work figuring out what to change and where.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: [Almost Solved] How to create a lighter static text widg

Postby Kulik » Tue Aug 02, 2011 08:33

ShadowTiger wrote:Does anyone know if the default window renderer will allow me to use Word wrap and and centering of text?


It will. See the code in this thread.

ShadowTiger
Quite a regular
Quite a regular
Posts: 46
Joined: Fri Mar 19, 2010 05:31

Re: Problem with WordWrap and Centering

Postby ShadowTiger » Tue Aug 02, 2011 23:14

I was using stuff like "HorzCentred" and "VertCentred"

Maybe these are deprecated and left for backwards compatibility in the static-text widget... but not for other widgets

switching to "centreAligned" seems to fix this.

Yeah... thanks for pointing out that what I had was correct.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests