I am preparing a GUI (Graphical User Interface) system for game engine (C ++).
The idea is to create a legacy of GUI controllers such as Focusable, Hooverable, Draggable, etc. Each GUI component can add many controllers, they modify the behavior of the component.
I think it gives a flexible system and prevents the code from repetition. Different examples of the same GUI class can have different complicated behaviors (maybe, it can also change dynamically) , So this approach looks practical.
The second option is to add centered, hovered, drag etc. The base GUI component class. It looks like overhead and it is not flexible.
Another solution is to use the object with Decorator Pattern and Focus Decorator, Hover Decorator etc. Maintaining such a system seems a little difficult.
Question: What are the harm in my solution? Maybe you have seen a better approach in the GUI system? What are the best ways to implement such a flexible complex system?
Your solution is very good to be honest, I think decorator design pattern is exactly the same, though In C ++, you have a better implementation technique, you can easily use policy based design to create a GUI component template class and add component behaviour specialty classes as its arguments and then participate in logic .
Comments
Post a Comment