GUI system architecture?
Posted
by topright
on Stack Overflow
See other posts from Stack Overflow
or by topright
Published on 2010-05-17T09:24:27Z
Indexed on
2010/05/17
10:30 UTC
Read the original article
Hit count: 286
I'm designing GUI (graphical user interface) system for a game engine (C++).
Idea is to create a heirarchy of GUI controllers like Focusable, Hoverable, Dragable etc. Every GUI component can attach multiple controllers, they modify component's behaviour.
I think it gives flexible system and protects from code duplication. Different instances of the same GUI class can have different complex behaviours (may be, even change it dynamically), so this approach looks practical.
The other choice is to add focused, hovered, dragged etc. flags in the base GUI component class. It looks like overhead and not that flexible.
Another solution is to use Decorator pattern and wrap objects with FocusDecorator, HoverDecorator etc. Maintaining such system looks a bit harder.
Question: What are pitfalls in my solution? May be you have seen a better approaches in GUI systems? What are the best ways of implementing such flexible complex system?
© Stack Overflow or respective owner