Skip to main content
gamedev.net
🔒 Locked

GUI control behaviour and testing

Started by Bezben 3 replies 750+ views
Original Post
Bezben
Bezben
I'd appriciate a little feedback on a GUI system I've been working on recently. Specifically, if it works, and whether or not the controls do what you expect them to do. What you should see if it works is are three top level windows, one a button, one custom drawn and one default drawn. One has a custom drawn button that does nothing, the other is sizable with a grid layout control containing six futher children that change things on the display. I currently have textboxes, buttons, checkboxes, radio button groups, sliders and comboboxes. Are there any other controls a typical game GUI would need? Thank you for your time.
Trienco
Trienco
Well, you passed the "highlight text in edit box"-test. Home/End doesn't seem to be supported, which is a minor thing.
How about the possibilities of changing the look and/or behaviour from outside? Not having to hardcode dialogues is a pretty handy thing and you can be lazy, use xml+tinyxml and could even create a gui editor.

Files could look like here and would easily allow to use things like default properties (collected in a "skin" file) and widget specific properties (in the actual dialogue file). Might save you a lot of typing and you could adjust dialogues without having to recompile the whole thing. (in the example, ignore that it has nothing but windows, buttons and just a single "exported" callback function to set). More a concept than anything.
f@dzhttp://festini.device-zero.de
Bezben
Bezben
I had thought about using xml to specify layout before. One of my aims when writing this library was to leave all the graphic api specific stuff outside the library. It doesn't load textures or images or anything like that, that is left to the host app. I really didn't want to force myself to have two instances of a texture loader, or rely on having other library X installed. The core of it only uses the standard c++ library. I suppose my point is that I'd write an xml layout class as application side option, since I'd use tinyxml myself.

The other thing about an xml layout is that I can't think of a nice neat way of linking the layout specification to what the gui is supposed to actually do without using some kind of scripting language...

I uploaded an updated version that now passes the home/end test :P
ostamo1
ostamo1
Question....how do you go about putting controls in a window and have that window move around......i am trying to build my own GUI but i am still fairly a newb at it

also if i try to use the mouse to hilight text in the text box it crashes for me
but it works if i use shift and the arrow keys to hilight text.
Bezben
Bezben
Fixed the crashing ;)

You draw windows relative to an origin, that origin being the parent. You just have to translate that point by all the parents. The way I do it is that all windows render into a canvas class that has a stack of positions the top of which is used to offset all rendering. Each window that renders pushes the offset from its parent to its top left corner and then draws as if it was at 0, 0.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.