Blaxar
28-09-2014 12:57:51
Hello everyone.
Here's the issue, I'm setting up my GUI the following way:
"WideWorlds_Blueprint" is a theme I've defined, with its own skin and images, using the following files:
WideWorlds_BlueprintTheme.xml:
WideWorlds_BlueprintSkins.xml:
WideWorlds_BlueprintTemplates.xml:
The thing is, I can't get a grip on any button instance (or anything else defined in the template) when using MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("Name") (I get an exception telling me the widget/button does not exist) and if I try to access anything using mainpanel's children, well somehow mainpanel has no children (mainpanel.getChildCount() == 0), which seems to be the root of the problem.
Note that if I skip/comment the whole callback setting part by only instantiating my mainpanel widget (and not accessing any sub-element within the code), everything is displayed fine at runtime just as expected, I even have the buttons changing their skin when I go over or click on them, like the theme is meant to behave, still from a source-code perspective all of this seems to be non-existent.
Thank you in advance.
Here's the issue, I'm setting up my GUI the following way:
void MainGUI::setupGUI(void){
const MyGUI::IntSize& view = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::Widget* mainpanel = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>("WideWorlds_Blueprint",
MyGUI::IntCoord(0, view.height - 384, 593, 384),
MyGUI::Align::Default, "Main");
MyGUI::Button* tButton = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("Terrain");
MyGUI::Button* sButton = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("Structure");
MyGUI::Button* oButton = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("Object");
tButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MainGUI::setTerrainMode);
sButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MainGUI::setStructureMode);
oButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MainGUI::setObjectMode);
}
"WideWorlds_Blueprint" is a theme I've defined, with its own skin and images, using the following files:
WideWorlds_BlueprintTheme.xml:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="List">
<List file="WideWorlds_BlueprintSkins.xml"/>
<List file="WideWorlds_BlueprintTemplates.xml"/>
</MyGUI>
WideWorlds_BlueprintSkins.xml:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Resource" version="1.1">
<Resource type="ResourceSkin" name="LeftPanel" size="114 384" texture="WideWorlds_BlueprintSkins.png">
<BasisSkin type="MainSkin" offset="0 0 114 384" align="Left Top">
<State name="normal" offset="0 384 114 384"/>
</BasisSkin>
</Resource>
<Resource type="ResourceSkin" name="BottomPanel" size="479 144" texture="WideWorlds_BlueprintSkins.png">
<BasisSkin type="MainSkin" offset="0 0 479 146" align="Left Top">
<State name="normal" offset="114 624 479 146"/>
</BasisSkin>
</Resource>
<Resource type="ResourceSkin" name="TerrainButton" size="73 73" texture="WideWorlds_BlueprintSkins.png">
<BasisSkin type="SubSkin" offset="0 0 73 73" align="Stretch">
<State name="disabled" offset="5 5 73 73"/>
<State name="normal" offset="5 5 73 73"/>
<State name="highlighted" offset="95 5 73 73"/>
<State name="pushed" offset="185 5 73 73"/>
</BasisSkin>
</Resource>
<Resource type="ResourceSkin" name="StructureButton" size="73 73" texture="WideWorlds_BlueprintSkins.png">
<BasisSkin type="SubSkin" offset="0 0 73 73" align="Stretch">
<State name="disabled" offset="5 95 73 73"/>
<State name="normal" offset="5 95 73 73"/>
<State name="highlighted" offset="95 95 73 73"/>
<State name="pushed" offset="185 95 73 73"/>
</BasisSkin>
</Resource>
<Resource type="ResourceSkin" name="ObjectButton" size="73 73" texture="WideWorlds_BlueprintSkins.png">
<BasisSkin type="SubSkin" offset="0 0 73 73" align="Stretch">
<State name="disabled" offset="5 185 73 73"/>
<State name="normal" offset="5 185 73 73"/>
<State name="highlighted" offset="95 185 73 73"/>
<State name="pushed" offset="185 185 73 73"/>
</BasisSkin>
</Resource>
</MyGUI>
WideWorlds_BlueprintTemplates.xml:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Resource">
<Resource type="ResourceLayout" name="WideWorlds_Blueprint" version="3.2.0">
<Widget type="Widget" position="0 0 593 384" name="Root">
<Widget type="Canvas" skin="LeftPanel" position="0 0 114 384" name="LeftPanel" align="Left Top">
<Widget type="Button" skin="TerrainButton" position="20 30 73 73" align="Stretch" name="Terrain"/>
<Widget type="Button" skin="StructureButton" position="20 120 73 73" align="Stretch" name="Structure"/>
<Widget type="Button" skin="ObjectButton" position="20 210 73 73" align="Stretch" name="Object"/>
</Widget>
<Widget type="Canvas" skin="BottomPanel" position="114 241 478 144" name="BottomPanel" align="Left Top">
<Widget type="Widget" skin="PanelSkin" position="11 52 452 84" name="Root">
<Widget type="Widget" skin="PanelEmpty" position="3 3 32 32" align="Stretch" name="Client"/>
<Widget type="ScrollBar" skin="ScrollBarH" position="3 65 444 15" align="HStretch Bottom" name="HScroll"/>
</Widget>
</Widget>
</Widget>
</Resource>
</MyGUI>
The thing is, I can't get a grip on any button instance (or anything else defined in the template) when using MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("Name") (I get an exception telling me the widget/button does not exist) and if I try to access anything using mainpanel's children, well somehow mainpanel has no children (mainpanel.getChildCount() == 0), which seems to be the root of the problem.
Note that if I skip/comment the whole callback setting part by only instantiating my mainpanel widget (and not accessing any sub-element within the code), everything is displayed fine at runtime just as expected, I even have the buttons changing their skin when I go over or click on them, like the theme is meant to behave, still from a source-code perspective all of this seems to be non-existent.
Thank you in advance.