[Solved]Layout Manager bug repositions and resizes widgets

mprestia

12-05-2010 22:09:45

Hello,

I am using the Layout Manager to create layouts for my game and noticed an interesting bug. As an example, I will use the following layout:


<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="WindowCS" position="100 100 200 200" layer="Back" name="window">
<Widget type="Button" skin="Button" position="50 50 50 50"/>
</Widget>
</MyGUI>


When I save this layout and reload it, everything works fine. However, if I change the layout to relative coordinates within the Layout Manager, I get the following result:


<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="WindowCS" position_real="0.0976563 0.130208 0.195313 0.260417" layer="Back" name="window">
<Widget type="Button" skin="Button" position_real="0.263158 0.306748 0.263158 0.306748"/>
</Widget>
</MyGUI>


When I save this layout and reload it, the button in the window is moved and resized.

I did some digging and discovered that when the Layout Manager is converting the button coord (50 50 50 50) to relative coordinates, the view size used for conversion is the size of the client widget of the window instead of the size of the actual window. When I reload the layout, the relative coordinates are converted to pixel coordinates using the size of the window instead of the window's client widget, distorting the button position and size, giving the resulting button coord of (52 61 52 61).

Has anyone else found this problem? If so, have you found a fix?

I am going to continue digging and will post updates if I make any progress.

Altren

12-05-2010 23:58:04

Yeah, you found bug. Thank you.

mprestia

14-05-2010 16:38:55

I tracked this down to the MyGUI::Window::baseCreateWidget function. In this function, the widget being created is set as the child of the client widget inside the window. I assume there is a reason for this, so I am attempting a workaround when the conversion is made to relative coordinates.

Altren

14-05-2010 17:04:01

Ok, I fixed that. Code was using widget size instead of client are size.

mprestia

14-05-2010 17:53:15

Awesome. Thanks Altren!