Questions about managers, widgets size and mouse cursor

sebarnolds

26-10-2009 08:08:37

Hi.

I started ported by (basic) UI code to QuickGUI and it seems to be working well but I have a few questions:
- I hide the mouse cursor by retrieving the mouse cursor from the manager and call setVisible on it. Is it the right way to do it ? If it is, that would mean that all the sheets of a manager share the same mouse cursor, correct ? I asked this because I will have GUI parts which will need a cursor (e.g. menu) while others won't (e.g. in-game HUD, which won't respond to inputs) : am I guessing correctly that I will need a different manager for them ?
- Again, about managers, if I want some sheets to be rendered in the background queue and others in the overlay queue, I will need different managers ?
- When I use a label, it has a background but I only want to display the text ? Do I have to set the opacity of the label to 0 or is there another way to avoid displaying the background ?
- All the coordinates and sizes are specified in absolute. If I want to display the same UI regardless of the resolution, I have to manage that myself, correct ? This could be easy but then the text can cause problems as I would need to calculate the font size based on the original sheet dimensions (e.g. a text whose size is 12 on a 800x600 sheet would have a size of (768 / 600)*12=15.36 =~16 if I want to resize my UI to the actual screen resolution). Any idea about that ?

Thank you very much for your answers,
Sebastien

Calder

26-10-2009 12:47:32

Well, I think I might be able to answer the last question. QuickGUI uses an anchoring system to define positions and sizes relative to other objects. There's a tutorial on the wiki here: http://www.ogre3d.org/wiki/index.php/Qu ... Tutorial_3 .

kungfoomasta

27-10-2009 18:33:43

In the latest version 9.10, I made the Mouse Cursor accessible through the Sheet widget, and the Sheet widget has the ability to modify the cursor's visibility. (This is the only way to do it, since MouseCursor is not publicly accessible anymore)

To achieve what you want just set the Sheet's property of cursor visibility, and when you load each sheet, the cursor will be shown/hidden as you've specified.

Again, about managers, if I want some sheets to be rendered in the background queue and others in the overlay queue, I will need different managers ?


You can tell the GUIManager what render queue to draw in. I believe the API is GUIManager::setRenderQueueID.

When I use a label, it has a background but I only want to display the text ? Do I have to set the opacity of the label to 0 or is there another way to avoid displaying the background ?

Create a transparent Label skin and use that. Create a file mySkins.skinTypes and add your skin definition for the label. Here is an example you can use:


Label transparent
{
SkinElement background
{
}
}


Now in your code you can set the Label's skin to "transparent", or you can set it in the desc prior to creation. You should see only the text of the Label, no texture for the background will be drawn.

All the coordinates and sizes are specified in absolute. If I want to display the same UI regardless of the resolution, I have to manage that myself, correct ?

Yes, I can't think of any straightforward way. But if you scaled the small text and made it bigger, wouldn't it look bad anyway? Are you allowing users to resize the window to any size, or you have pre-determined sizes? I would make several Sheets for each pre-determined size, so the text looks good on each resolution. Make a function that takes a width and height, and from that information, generates the widgets dimensions and positions. You can also make use of QuickGUI::Text::getFontHeight (I think thats the API), which will tell you how many pixels tall the font is when rendered.

sebarnolds

29-10-2009 21:40:01

Thank you for your answers.

The question about manager and sheets is in fact related to multiple sheets. Image I have a menu with a background picture, a 3D scene and the actual menu GUI. The background would obviously need to be rendered in the background queue while the menu would be rendered in the overlay queue. My question was to be sure that I needed to create two managers for that, each one having a different queue i.e. two sheets in a manager will always be rendered in the same queue ?

About the mouse cursor, I guess that if I show multiple sheets at the same time, it's my job to hide the cursor on all sheets except the one I consider as the "active" one ?

About the size, the problem is that I try to think about it a lot in order to do the right thing. I don't have a defined set of resolution as I will use the list of available resolutions on the player computer. Now, there is a problem because a) the screen can have different aspect ratio (4:3, 16:9...) b) text is not resized automatically. Does anybody have any idea how it could be handled ? If I remember well, Deus Ex used the same menu size regardless of the resolution (i.e. in 640x480 the menu took a bigger part of the screen than in 1280x1024). However lots of other commercial titles shows the same UI regardless of the resolution. How could this be achieved ? Would I need to define several font sizes and determine the fittest at runtime to have the best quality for font rendering ?

Thank you for your time,
Sebastien

kungfoomasta

01-11-2009 19:40:34

If you want to draw 2 sheets at the same time, you'll have to have 2 GUIManagers. GUIManagers render during a specific render queue, so if you want a sheet drawn on the background, then a sheet on top, each GUIManager would need to have a different render queue id.

About the mouse cursor, I guess that if I show multiple sheets at the same time, it's my job to hide the cursor on all sheets except the one I consider as the "active" one ?

Yep.

For the size issue, I'm going to try to implement a feature that would allow the Sheet texture to be scaled. Will post back when I've tried it out to see if it works.

sebarnolds

06-11-2009 12:34:19

Hey !

Thank you for your answers and sorry for returning so late. I guess my only question remaining is related to the size.

Thank you for thinking about the size issue. Maybe it would be a good idea to ask this also in the general forum as the size issues is not directly related to QuickGUI but to any GUI system ?

Sebastien