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