Need help with TabControl

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

jheld
Just popping in
Just popping in
Posts: 18
Joined: Sun Aug 09, 2009 04:06

Need help with TabControl

Postby jheld » Fri Feb 05, 2010 03:33

Hello everyone,

I'm having trouble getting a basic tabcontrol working....for some reason, only one tab shows up, while the rest remain hidden. I've looked through the tutorials, API, an swam through other posts on this forum. All other CEGUI elements are working fine, and since I can't get *any* tab sample code to work properly, clearly I'm missing something fundamental. Can someone please help?

What I've done:

1/ Created a layout using scriptkid's editor (ver ~0.7). Per instructions in the wiki, tabs are done as default windows, which are "unattached" in the editor
2/ Tabs are attached in code, using "addTab"

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<GUILayout >
    <Window Type="DefaultWindow" Name="Settings" >
        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
        <Window Type="DefaultWindow" Name="Settings/GraphicsTab" >
            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.069633,0},{0.8,0},{0.635079,0}}" />
            <Window Type="TaharezLook/StaticText" Name="Settings/graphics/" >
                <Property Name="Text" Value="Graphics" />
                <Property Name="HorzExtent" Value="41" />
                <Property Name="VertExtent" Value="11.7287" />
                <Property Name="UnifiedAreaRect" Value="{{0,0},{-0.00231481,0},{0.3,0},{0.117685,0}}" />
            </Window>
        </Window>
        <Window Type="DefaultWindow" Name="Settings/SoundTab" >
            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.119633,0},{0.8,0},{0.685078,0}}" />
            <Window Type="TaharezLook/StaticText" Name="Settings/Sound/text" >
                <Property Name="Text" Value="Sound" />
                <Property Name="HorzExtent" Value="28" />
                <Property Name="VertExtent" Value="11.7287" />
                <Property Name="UnifiedAreaRect" Value="{{0.296296,0},{-0.00462963,0},{0.596296,0},{0.11537,0}}" />
            </Window>
        </Window>
        <Window Type="DefaultWindow" Name="Settings/GameplayTab" >
            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.169633,0},{0.8,0},{0.735078,0}}" />
            <Window Type="TaharezLook/StaticText" Name="Settings/Gameplay/text" >
                <Property Name="Text" Value="Gameplay" />
                <Property Name="HorzExtent" Value="46" />
                <Property Name="VertExtent" Value="11.7287" />
                <Property Name="UnifiedAreaRect" Value="{{0.595082,0},{-0.00231482,0},{0.895082,0},{0.117685,0}}" />
            </Window>
        </Window>
        <Window Type="DefaultWindow" Name="Settings/HelpTab" >
            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.219633,0},{0.8,0},{0.785078,0}}" />
            <Window Type="TaharezLook/StaticText" Name="Settings/Help/text" >
                <Property Name="Text" Value="Help" />
                <Property Name="HorzExtent" Value="20" />
                <Property Name="VertExtent" Value="11.7287" />
                <Property Name="UnifiedAreaRect" Value="{{0.896359,0},{0,0},{1.19636,0},{0.12,0}}" />
            </Window>
        </Window>
        <Window Type="TaharezLook/TabControl" Name="Settings/TabControl" >
            <Property Name="TabHeight" Value="{0,19.7287}" />
            <Property Name="TabPanePosition" Value="Top" />
            <Property Name="UnifiedAreaRect" Value="{{0.0505859,0},{0.304712,0},{0.94707,0},{0.850524,0}}" />
        </Window>
    </Window>
</GUILayout>


Code: Select all

SettingsWindow::SettingsWindow(CEGUI::WindowManager * wmgrIn)
{
   wmgr = wmgrIn;

   myTabs = (CEGUI::TabControl*)wmgr->getWindow((CEGUI::utf8*)"Settings/TabControl");
   myTabs->setTabHeight((CEGUI::UDim(15, 27)));

   GraphicsTab = (CEGUI::Window*)wmgr->getWindow((CEGUI::utf8*)"Settings/GraphicsTab");
   SoundTab = (CEGUI::Window*)wmgr->getWindow((CEGUI::utf8*)"Settings/SoundTab");
   GameplayTab = (CEGUI::Window*)wmgr->getWindow((CEGUI::utf8*)"Settings/GameplayTab");
   HelpTab = (CEGUI::Window*)wmgr->getWindow((CEGUI::utf8*)"Settings/HelpTab");

   GraphicsTab->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(1.0f, 0.0f)));
   SoundTab->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(1.0f, 0.0f)));
   GameplayTab->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(1.0f, 0.0f)));
   HelpTab->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(1.0f, 0.0f)));

   GraphicsTab->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.0f, 0.0f)));
   SoundTab->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.25f), CEGUI::UDim(0.0f, 0.0f)));
   GameplayTab->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.5f), CEGUI::UDim(0.0f, 0.0f)));
   HelpTab->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.75f), CEGUI::UDim(0.0f, 0.0f)));

   myTabs->addTab(GraphicsTab);
   myTabs->addTab(SoundTab);
   myTabs->addTab(GameplayTab);
   myTabs->addTab(HelpTab);
   myTabs->setSelectedTabAtIndex(0);


Not quite sure what's missing, but I'm hoping it's something obvious to the rest of you. Thanks in advance,
Jason

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Need help with TabControl

Postby scriptkid » Fri Feb 05, 2010 09:15

Hi,

To me it's not entirely clear what the problem is. Does the tabcontrol show up? If so, does it not respond to any events?
Check out my released snake game using Cegui!

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

Re: Need help with TabControl

Postby Jamarr » Fri Feb 05, 2010 19:42

I'm not too familiar with the TabControl, however I have used it in v0.6.2. I don't understand why you need to have the pre-exisiting tabs "unattached". This doesn't make any sense to me. Just add them as child-windows of the TabControl in your layout, and CEGUI should automatically add/set up these tabs for you when you load the layout. This is precisely how I did it in my layout.

Aside from this, I cannot really see anything wrong with your code. The only other thing that stands out to me is that CEGUI has to re-parent the tab-windows when you call addTab, since they are initially immediate children of the Settings window. Perhaps there is some conflict there? I am only guessing, as I've never actually used addTab().

When you say that you cannot get any "sample code" to work, are you referring to code on this "wiki" page you talked about, or are you referring to the actual sample projects supplied with the SDK, or both?
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!

jheld
Just popping in
Just popping in
Posts: 18
Joined: Sun Aug 09, 2009 04:06

Re: Need help with TabControl

Postby jheld » Sat Feb 06, 2010 04:29

Thanks guys, for the quick reply!

Jamarr- I was following the method in the wiki and another forum post suggesting to have the tabs as unattached first. I've also tried just using the default tabcontrols in the editor, but have the same problem as this post: viewtopic.php?f=10&t=4498&hilit=tabcontrol
this way, I don't see *any* tabs and the top part of the tabcontrol is missing. From reading the wiki and other posts, it's a bit unclear as to the "proper" way of setting up the tabcontrol. I'm also unclear as to what's automatically generated and what requires manual setup. Apologies for my own lack of understanding here....especially knowing that others have managed to set them up in the past.

Scriptkid- When setting up myself (via "Addtab"), I can at least see the first tab....but not the others. The tabcontrol doesn't seem to respond to clicks but that may be because I don't understand basic issues of what should overlap what. I've spent hours experimenting with the sizes and dimensions, but it's feeling like stumbling in the dark....

BTW....the new layout editor is working great. WOuld much prefer to set up the tabcontrol using the editor, if possible..

Jason.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 20 guests