Scaling with Resolution

HTAPAWASO

29-12-2013 10:30:44

So I know there are a lot of topics on this, but I can't figure out this particular issue.

Here's my layout file (based on a suggestion in another thread):


<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">

<Widget type="ImageBox" skin="ImageBox" position="0 0 1024 768" align="Centre" layer="Back" name="MainWin">
<Property key="Visible" value="true"/>
<Property key="Enabled" value="true"/>
<Property key="NeedMouse" value="true"/>
<Property key="NeedKey" value="true"/>
<Property key="InheritsAlpha" value="true"/>

<Widget type="Button" skin="ButtonImage" position="924 0 100 100" align="Stretch" name="MenuButton">
<Property key="Button_ImageResource" value="pic_ButtonBorder"/>
<Property key="Button_ModeImage" value="true"/>
<Property key="Widget_Caption" value="Menu"/>
</Widget>
</Widget>

</MyGUI>


The aim is to get MenuButton to display in the top-right-hand corner regardless of the resolution.

Now this actually does work, but there are some big issues. If the actual resolution is smaller than that used in the layout file (in this case 1024x768), for some reason the position of MenuButton becomes negative, and it's not displayed.
Well, the obvious solution to that is to just use the smallest resolution desired within the layout file. This has its own problem though. For whatever reason, at higher resolutions, the program decides to mess up the size value (3rd and 4th argument of "position") of the button. The button refuses to shrink below a certain (very large) size, while it behaves perfectly well at 1024x768.

Does anybody have any idea why this is? Or if there is a better way to accomplish what I'm trying to do.
I mean, essentially all I'm trying to do is specify co-ordinates relatively rather than absolutely. I know it can be done in code like so:
w->createWidgetReal<MyGUI::Button>("Button", 0.1, 0.1, 0.1, 0.1, MyGUI::Align::Default, "Button1");
But how can I do it in the layout file?

Thanks.

simed

08-01-2014 08:44:46

In the Layout Editor you can specify whether a widget's position & size are in pixels or % values, so yes you can do this in XML. Easiest way would be to save something from the editor and see what the XML looks like.

However, do you definitely want the menu button to resize or just to be locked to the top-right corner?

HTAPAWASO

24-01-2014 03:10:51

Thanks for the reply, sorry I didn't check this thread for a while.

I ended up just doing it in code this time, but it's good to know it's possible for the future.

I have another (simpler) question though.
How do I set a delegate for right mouse clicks?