Refactoring

I’ve been without the internet for a little while so I spent a good part of that time refactoring some of the UI code.

I quickly identified a distinction between widgets that hold a single other widget, and widgets that contain many other widgets. These are Containers vs Layouts. Obviously a widget that holds one other widget is a container, something that holds many widgets only does so for the sole purpose of positioning them, therefore it’s a layout.

This brings me a Container class that the Window now inherits from. Containers don’t seem to have a clear way of doing a hierarchy as each positions them differently. The two I have now, a Tetris like stack that I call Box (I might rename it to TetrisLayout) and TableLayout don’t even store their widgets in the same manner.

The UI code is really starting to look slick. It’s actually got more code than the current state of the graphics engine and more than 4x the code of any of the celestial mechanics and AI stuff I’ve already done.

Leave a Reply

Your email address will not be published. Required fields are marked *