Nothing shown if parent is used in loadLayout

AshMcConnell

18-05-2010 15:08:12

Hi Folks,

I am attempting to load a layout to represent each menu page in my GUI. I was going to create a parent for each "page" / layout and then show / hide the appropriate one as I navigate the menus. Is this a "normal" way to do this sort of thing?

Here is some code I've been playing with

_mainMenuParent = _gui->createWidget<Widget>("Default",0,0,width,height,Align::Default, "Main", "ParentWidget");
VectorWidgetPtr widgetsVec = MyGUI::LayoutManager::getInstance().loadLayout("MainMenu.layout", "options_", _mainMenuParent);
_mainMenuParent->setPosition(0,0);
_mainMenuParent->setRealSize(1,1);
_mainMenuParent->show();


If I don't use _mainMenuParent then the menu is shown properly. Any ideas where I could be going wrong.

I am using 3.0.1

All the best,
Ash

AshMcConnell

18-05-2010 15:41:43

It seems that it is showing something, but my dark background layer is being shown on top of the other layers. Is there a way to stop this happening? It doesn't seem to be dealing with the layers properly.

*edit* I noticed when I log the layer name for each widget using widget->getLayerName() the layer is blank (despite being set in the XML file). The z order only seems to depend on the order that the widget is declared in the XML file

Thanks for your help
All the best,
Ash

Altren

18-05-2010 17:50:27

Root widgets (aka widgets without parents) on one layer shouldn't overlap to make everything clear. When you have some background you should use lower layer for it.
If you need predictable overlapping you should use layer with overlapped property enabled, but this is usually used for things like Message boxes, windows, etc.

AshMcConnell

18-05-2010 19:14:54

Hi Altren,

Thanks for the reply.

I am hoping to have a number of root widgets representing different menu pages (Main Menu / Options / Car Setup for example). There will only be one of these displayed at a time, so overlapping shouldn't be a problem.

The problem I am having is the layers for the widgets that are children of these root widgets. The layer properties of these children are being ignored in 3.0.1 as far as I can tell.

For example here is my Options page - http://tweetphoto.com/22928642

The structure is: -

root
|
- StaticImage (background texture in the bottom left) on Middle Layer
- Tabs on Main Layer

The root is a simple Widget with a dark grey background that blends with the top and right of the static image.

These should always appear in the order (from back) root, static image, tabs. This doesn't happen though if the Tabs Widget appears before the StaticImage in the XML layout file (the layer property seems to be ignored). The order is only ignored if you provide a parent as the last parameter in the loadLayout method.

I don't think this is how it was intended to work? I can work around it by carefully placing the XML structures.

All the best,
Ash

Altren

18-05-2010 21:49:33

Please show me your layout file.

AshMcConnell

19-05-2010 07:26:46

Hi Altren,

Thanks for the reply.

Here is the file when it "works" (ignore the misplaced back button) - http://tweetphoto.com/23033292
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="StaticImage" skin="StaticImage" position="0 300 1000 750" align="Left Bottom" layer="Overlapped" name="background">
<Property key="Image_Texture" value="racingbackdrop.png"/>
<Property key="Widget_Enabled" value="false"/>
<Widget type="Button" skin="ButtonBack" position="436 544 93 92" name="back"/>
</Widget>
<Widget type="Tab" skin="Tab" position="432 296 801 530" align="Center" layer="Main" name="optionsTab">
<Property key="Widget_Alpha" value="0.8"/>
<Property key="Tab_SmoothShow" value="true"/>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Controller"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="innerbackground.png"/>
<Widget type="HScroll" skin="HSlider" position="20 448 208 16" name="ffSlider">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="70"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="292 448 208 16" name="ffHarshness">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="75"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="560 448 208 16" name="steeringMultiplier">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="20"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="504 342 280 16">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="30"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="502 208 288 38" name="mouseControl">
<Property key="Edit_ReadOnly" value="true"/>
<Property key="ComboBox_AddItem" value="Test1"/>
<Property key="ComboBox_AddItem" value="Test2"/>
<Property key="ComboBox_ModeDrop" value="false"/>
</Widget>
<Widget type="Button" skin="ButtonMeshSmall" position="486 82 222 63">
<Widget type="StaticText" skin="StaticText" position="34 18 160 22">
<Property key="Text_TextColour" value="#CCCCCC"/>
<Property key="Widget_Caption" value="Select Steering"/>
<Property key="Widget_InheritsPick" value="false"/>
<Property key="Widget_Enabled" value="false"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
</Widget>
</Widget>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Graphics"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="graphicsbackdrop.png"/>
<Widget type="ComboBox" skin="ComboBox" position="2 46 380 40" name="resDropdown"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Sound"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="soundbackdrop2.png"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Network"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="networkbackdrop.png"/>
<Widget type="Edit" skin="Edit" position="20 120 344 34" name="proxyAddress">
<Property key="Widget_Alpha" value="1"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
<Widget type="Edit" skin="Edit" position="20 210 344 34">
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
<Widget type="Edit" skin="Edit" position="20 302 344 34">
<Property key="Edit_Password" value="true"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Driver Aids"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="driveraidsbackdrop.png"/>
<Widget type="Button" skin="CheckBox" position="296 92 220 42">
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Widget_Caption" value="Automatic Gears"/>
<Property key="Text_TextColour" value="#FFFFFF"/>
</Widget>
</Widget>
</Widget>
</Widget>
</MyGUI>


When I move the StaticImage (background) to the bottom of the XML file I get: - http://tweetphoto.com/23033324
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">

<Widget type="Tab" skin="Tab" position="432 296 801 530" align="Center" layer="Main" name="optionsTab">
<Property key="Widget_Alpha" value="0.8"/>
<Property key="Tab_SmoothShow" value="true"/>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Controller"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="innerbackground.png"/>
<Widget type="HScroll" skin="HSlider" position="20 448 208 16" name="ffSlider">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="70"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="292 448 208 16" name="ffHarshness">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="75"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="560 448 208 16" name="steeringMultiplier">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="20"/>
</Widget>
<Widget type="HScroll" skin="HSlider" position="504 342 280 16">
<Property key="Scroll_Range" value="100"/>
<Property key="Scroll_Position" value="30"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="502 208 288 38" name="mouseControl">
<Property key="Edit_ReadOnly" value="true"/>
<Property key="ComboBox_AddItem" value="Test1"/>
<Property key="ComboBox_AddItem" value="Test2"/>
<Property key="ComboBox_ModeDrop" value="false"/>
</Widget>
<Widget type="Button" skin="ButtonMeshSmall" position="486 82 222 63">
<Widget type="StaticText" skin="StaticText" position="34 18 160 22">
<Property key="Text_TextColour" value="#CCCCCC"/>
<Property key="Widget_Caption" value="Select Steering"/>
<Property key="Widget_InheritsPick" value="false"/>
<Property key="Widget_Enabled" value="false"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
</Widget>
</Widget>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Graphics"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="graphicsbackdrop.png"/>
<Widget type="ComboBox" skin="ComboBox" position="2 46 380 40" name="resDropdown"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Sound"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="soundbackdrop2.png"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Network"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="networkbackdrop.png"/>
<Widget type="Edit" skin="Edit" position="20 120 344 34" name="proxyAddress">
<Property key="Widget_Alpha" value="1"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
<Widget type="Edit" skin="Edit" position="20 210 344 34">
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
<Widget type="Edit" skin="Edit" position="20 302 344 34">
<Property key="Edit_Password" value="true"/>
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Text_FontHeight" value="18"/>
</Widget>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 26 792 498">
<Property key="Widget_Caption" value="Driver Aids"/>
<Widget type="StaticImage" skin="StaticImage" position="0 0 792 499">
<Property key="Image_Texture" value="driveraidsbackdrop.png"/>
<Widget type="Button" skin="CheckBox" position="296 92 220 42">
<Property key="Text_FontName" value="font_Eurostib.25"/>
<Property key="Widget_Caption" value="Automatic Gears"/>
<Property key="Text_TextColour" value="#FFFFFF"/>
</Widget>
</Widget>
</Widget>
</Widget>
<Widget type="StaticImage" skin="StaticImage" position="0 300 1000 750" align="Left Bottom" layer="Overlapped" name="background">
<Property key="Image_Texture" value="racingbackdrop.png"/>
<Property key="Widget_Enabled" value="false"/>
<Widget type="Button" skin="ButtonBack" position="436 544 93 92" name="back"/>
</Widget>
</MyGUI>


I would have thought that the Layers property would be taken into consideration.

Thanks for your help
All the best,
Ash!

Altren

19-05-2010 15:50:52

Oh, I understand your problem now. Layout Editor ignore layers because it's possible that you may have custom layers and LE don't know about that. So it creates all widgets on one layer.

But when you load layout in your application it works fine in both cases. Just try it.

Also I changed Layout Editor a bit to try using Layers in test mode.

AshMcConnell

19-05-2010 16:27:51

Hi Altren,

The tweet photos are shown in-game and NOT in the Layout Editor, so there is still a problem somewhere.

Perhaps I should get the latest code from SVN? I am currently using 3.0.1

All the best,
Ash

Altren

19-05-2010 17:05:43

Oh, Child widgets don't have layers. Their layer is same as parent's layer by default, so you actually loading two widgets on same level and loader ignore "layer" property.
So you either shouldn't give them parents, or split it into two layouts and attach to different parent widgets on different layers.