GUI/Menuing System Design

Started by
3 comments, last by CadetUmfer 14 years, 12 months ago
I'm toying around with different ways of designing (coding) a GUI system. I'm trying to make it very versatile, so I'm thinking of using a decorator pattern for rendering. But I do not have a way of actually passing messages around (such as OnButtonClick, etc). I was thinking of using something similar to a message queue in which message are processed at the next time I update. This has a down side because I'm forced to use a huge switch statement in order to sift through all the messages (much is the problem with Win32 coding). What is the best way of processing messages like this? I'm open to any ideas. Thanks in advance.
------------Anything prior to 9am should be illegal.
Advertisement
Your event/messaging system could make use of the observer pattern.

You would get around needing the giant switch by making use of OO constructs. Virtual functions, polymorphism, functors, etc. can all be used in place of a discrete enum to define event types and a giant switch to handle them.
Personally, I prefer the setup where a button is setup with a delegate/event/functor that is triggered (or at least enqueued) when it's clicked.
Quote:Original post by y2kiah
Your event/messaging system could make use of the observer pattern.

You would get around needing the giant switch by making use of OO constructs. Virtual functions, polymorphism, functors, etc. can all be used in place of a discrete enum to define event types and a giant switch to handle them.


Good call, The problem is that this now takes the switch statement and splits it into many functions or classes. Which is easier to read but it makes a ton of files and classes. Hmm....I guess there is no way around this.

Quote:Personally, I prefer the setup where a button is setup with a delegate/event/functor that is triggered (or at least enqueued) when it's clicked.

This is what I'm aiming for, or something close to it.
------------Anything prior to 9am should be illegal.
Since games are generally periodic/polling at their core, I go with an immediate-mode solution ala IMGUI. It completely avoids the need for a callback system, since you can just immediately notify the calling code of any events.
Anthony Umfer

This topic is closed to new replies.

Advertisement