Designing a decent GUI

Started by
4 comments, last by Architekt 22 years, 3 months ago
Note: I posted this in the directx group too because I''m implementing the GUI library in both opengl and directx and assumed that the methods described in one wouldn''t really cary over due to the vastly different APIs. I''m in the process of designing some GUI widgets that I need specifically for my game. Some of the features I''m implementing are texture mapped widgets, and alpha blending among the non mundane. My main question though is in regards to event handling. One way I thought of how to do things was to have the user (most likely only me) register callback functions for each event they were interested in processing. A pointer to their function would then be stored and called when the proper event is triggered. But in terms of triggering the event...the first way to implement it that came to mind to me was something like this: In the OpenGL mouse handling code, check for, e.g., a left mouse button down event. For each widget on screen, call their left mouse button down event, passing in the mouse coordinates. If the mouse coordinates lie within the bounds of the widget, then that event has been triggered, and the user''s callback code gets executed and returns the value of that callback. The process is much the same for every other callback. Now, it works, but I was wondering if there was a way to make this way simpler. Ideally, it would be cool if when a widget or dialog box was on the screen, if the dialog box (which contains all the widgets) could take over proecssing the mouse input, and keyboard input in the case of the edit box. By taking over the input, I could in the class have it check for the proper events and call teh right methods, instead of having the user get so involved in the process. Then, after the events have been processed, it could relay the event message or propogate it in some say so that just in case the user didn''t want to lose total control of their input abilities when dialog boxes are on the screen, they could still receive the input notifications. Just conceptually speaking (I''m not asking for source code), is there a way to at least get close to what I''m trying to achieve, or is the way I''m currently approaching it "as good as it gets"? Perhaps there''s a better method altogether. Thanks for your help, I greatly appreciate it.
Advertisement
My advice is to do things in both OpenGL and DirectX _only_ when it is absolutely needed. Build the rest of the engine on those components. For example, graphics would be different, but you create wrappers that function the same no matter what.

Will this be cross-platform?
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)
I agree with ironfroggy. If you want to design your own API for the GUI stuff is perhaps better not making it depend on OpenGL or DirectX.

Does not all "real" GUI APIs take control over user input for dialogs? After the user has left the dialog box can the program read the edited values. Supporting generic dialogs is pretty ambitious. If you do not stop will you implement a whole API with tools like resource editors/compilers and that easy to use class library on top!

well, then my question is this: So let''s say for the windows bit (oh ya, I''m trying to make it work in linux/windows), I use MFC to gain control of the input. Let''s say the user also has their input class pointers (LPDIRECTINPUT) all initialized as well, cause they need to handle mouse/keyboard input themselves for the rest of the game. What happens if my GUI system is called first and it polls the mouse...is that event lost? Or what if the user polls the mouse before my GUI system...same thing? BTW, this GUI thing isn''t meant to be some super crazy GUI that I''m intending to release to everyone. I''m writing it first and foremost for some very specific purposes of mine. If other people find use from it, great, but it''s not meant to be an all encompassing GUI solution. Thanks for your help.
Linux/windows, and OpenGL/DirectX.... Hehehe... Thats just funny.

Trent
http://www.geocities.com/SiliconValley/Vista/7184/guitool.html
perhaps an acceptable gui already exists

This topic is closed to new replies.

Advertisement