This post might be a bit winded, but I'd really appreciate if I could get some guidance on this one.
I've been working on an app/game for a while now, but I keep finding myself having a distaste for how I'm running my GUI framework. The way I have it set up right now is similar to Java Swing, in that I have Components and Containers being the basic classes of the layout, where Containers can have Components within, etc.
The main challenges I'm facing are:
- How to be able to position child components in a layout respective to the parent's position. The way I had it done before was that my Container had an UpdatePosition virtual function that Container classes would overwrite. I don't like this method much because some containers, such as ones that lay 50+ children out in a grid, can be pretty heavy operations to run each frame.
- Being able to get the absolute position of the components to do things like checking mouse collision. After doing what I mentioned in #1, I tried using D3DXMATRIX to transform the world before each container was drawn. That way, if a component was at position (0, 0) relative to its parent, and its parent was at (30, 30), the component would be drawn at (30, 30). However, when it comes to collision detection, I can't simply use these relative positions.
I was thinking of maybe giving Container a LayoutManager class, which could store the relative position of each child, and then when the container is moved, have it simply add the relative position to the parent's position, but decided to post here and see if maybe I could get some opinions. Anyone done anything similar?
Thanks for getting this far,
Jengerer