Page 1 of 1

Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 09:58
by Boost113
I tried to create a window with a TabControl in CEED, it crashed.
Then I looked at the samples and found out that they are using lots of C++ code to set up the tabs, not what I want.

I tried many different things to set the names for the tabs but it seems that nothing works.
What I think should work using AutoWindows to set the text fails with an exception:

Code: Select all

CEGUI::InvalidRequestException in function 'void __thiscall CEGUI::GUILayout_xmlHandler::elementAutoWindowStart(const class CEGUI::XMLAttributes &)' (C:\Users\OEM\Documents\Visual Studio 2010\Projects\cegui-for-ogre-v2-0\cegui\src\GUILayout_xmlHandler.cpp:282) : layout loading has been aborted since auto window '__auto_btnFirstTab' could not be referenced.


Which is obviously incorrect since when I print the window tree it looks like this:

Code: Select all

// ------------------ Layout of object "LobbyScreen/LobbyTabs" ------------------ //
   > LobbyTabs
      > __auto_TabPane__
         > FirstTab
            > Text
               > __auto_hscrollbar__
                  > __auto_incbtn__
                  > __auto_decbtn__
                  > __auto_thumb__
               > __auto_vscrollbar__
                  > __auto_incbtn__
                  > __auto_decbtn__
                  > __auto_thumb__
         > SecondTab
            > Text
               > __auto_hscrollbar__
                  > __auto_incbtn__
                  > __auto_decbtn__
                  > __auto_thumb__
               > __auto_vscrollbar__
                  > __auto_incbtn__
                  > __auto_decbtn__
                  > __auto_thumb__
      > __auto_TabPane__Buttons
         > __auto_btnFirstTab
         > __auto_btnSecondTab
      > __auto_TabPane__ScrollLeft
      > __auto_TabPane__ScrollRight



The layout that causes the error:

Code: Select all

    <AutoWindow namePath="__auto_TabPane__Buttons">
        <AutoWindow namePath="__auto_btnFirstTab">
            <Property name="Font" value="Simonetta-Black"/>
            <Property name="Text" value="First tab"/>
        </AutoWindow>
        <AutoWindow namePath="__auto_btnSecondTab">
            <Property name="Font" value="Simonetta-Black"/>
            <Property name="Text" value="Second tab"/>
        </AutoWindow>
    </AutoWindow>


This should work, right?
I tried setting different properties but it didn't really work.
However, I found a workaround for this issue.
Using this layout:

Code: Select all

        <Window name="LobbyTabs" type="TaharezLook/TabControl">
            <Property name="TabHeight" value="{0,-1}"/>
            <Property name="TabPanePosition" value="Bottom"/>
            <Property name="Area" value="{{0.02, 0}, {0, 0}, {0.98, 0}, {0.90, 0}}"/>
           
           
            <AutoWindow namePath="__auto_TabPane__Buttons">
                <AutoWindow namePath="__auto_btnFirstTab">
                    <Property name="Font" value="Simonetta-Black"/>
                    <Property name="Text" value="First tab"/>
                </AutoWindow>
                <AutoWindow namePath="__auto_btnSecondTab">
                    <Property name="Font" value="Simonetta-Black"/>
                    <Property name="Text" value="Second tab"/>
                </AutoWindow>
            </AutoWindow>
           
            <!-- The first tab -->
            <Window name="FirstTab" type="DefaultWindow">
                <Window name="Text" type="TaharezLook/StaticText">
                   
                   
                    <Property name="Area" value="{{0.15, 0}, {0.5, 0}, {0.85, 0}, {0.75, 0}}"/>
                   
                    <Property name="HorzFormatting" value="WordWrapCentreAligned"/>
                    <Property name="VertFormatting" value="CentreAligned"/>
                   
                    <Property name="Font" value="Simonetta-Black"/>
                    <Property name="Text" value="I'm a tab content"/>
                </Window>
            </Window>
           
            <!-- The second tab -->
            <Window name="SecondTab" type="DefaultWindow">
                <Window name="Text" type="TaharezLook/StaticText">
                   
                   
                    <Property name="Area" value="{{0.15, 0}, {0.5, 0}, {0.85, 0}, {0.75, 0}}"/>
                   
                    <Property name="HorzFormatting" value="WordWrapCentreAligned"/>
                    <Property name="VertFormatting" value="CentreAligned"/>
                   
                    <Property name="Font" value="Simonetta-Black"/>
                    <Property name="Text" value="I'm an another tab"/>
                </Window>
            </Window>
        </Window>


And this script which is executed after the layout is loaded

Code: Select all

        [@Listener="OnInit"]
        int PrintStuff(GuiObject@ instance, Event@ event){
            // This prints the tree of sub windows //
            instance.PrintWindowsRecursive();
           
            // Set the texts //
            instance.GetTargetElement().GetChildWindow("__auto_TabPane__Buttons/__auto_btnFirstTab").SetText("Tab1");
            instance.GetTargetElement().GetChildWindow("__auto_TabPane__Buttons/__auto_btnSecondTab").SetText("The second tab");
           
            // Fix the size issues //
            instance.GetTargetElement().SetSelectedTabIndex(0);
           
            return 1;
        }


I got the tab names set and sized correctly, without the SetSelectedTabIndex the tabs are too small to fit the text.
I'm pretty sure that there should be a better way to do this?
This is using the 0.8 branch from about a month ago (since in the latest default branch the Ogre renderer is broken)

btw Full CEGUI.log here http://pastebin.com/afkY2t2T

Re: Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 10:56
by Ident
Do I get you right that the problem only occurs in CEED?

Re: Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 12:04
by Boost113
No, the problem is in both CEED (it crashes/throws an exception) and my application (not getting the names to display without using the workaround).

Re: Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 12:08
by Ident
I guess that has to do with the internal way the tab control widget works. Probably, at least on the CEGUI (not CEED) part, it can easily be modified to work the way you want it to. I am not sure why CEED has issues with this but i remember general issues in CEED with autowindows.

Re: Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 12:10
by Boost113
Yeah, it would seem like there is some missing functionality when using only .layout files.
This might as well be a feature request for fixing the tab naming.

Re: Cannot set tab names with AutoWindows

Posted: Tue Jun 03, 2014 12:29
by Ident
Maybe you can look into the c++ code to see why it has issues with loading it from layout.

Also please file a bug on mantis. This is helpful in any case.

The optimum would of course be if you can provide a pull request if you find a way to fix this on your own!

Edited the post a bit