pioneerspacesim/pioneer — pull request #1665 by robn (2012-11-04 06:42:43+00:00)
Title: New UI: Reimplement Box and fix "give me lots" size requests

So `Box` was hard to use, with you having to flag widgets to indicate you wanted them to receive "leftover" space. For some widgets, like MultiLineText which has (had) no ideal size, this meant you could never get them on screen unless you always gave them flags. Also, you pretty much never want `EXPAND` without `FILL`, so that was more annoyance.

Now `Box` has no flags, and makes no effort to evenly distribute the available space (because it'll usually end up being a broken interface anyway). Now it just mashes the widgets up against each other. If any report that they want "as much space as possible" (via a preferred size of `SIZE_EXPAND`), they get an even share of the leftover space, or 100 pixels, whichever is larger.

This means that Box can now extend beyond its preferred size, and will be clipped during draw. If that's a problem, wrap it in a `Scroller`.

To support this, I had to go through the other widgets and ensure that they use `SIZE_EXPAND` appropriately - some were using 0 for this, which means something different. Since its a magic number (really `INT_MAX`), I wrote some skanky helper functions to safely add sizes together without screwing up this magic number. I'm not really keen on the structure of this, but its so little code that its barely worth doing anything else.

You can see it in action on `robn/new-ui-infoview`. All the infoview screens are now properly displayed above the panel. The Missions tab looks a bit odd because it doesn't have any `SIZE_EXPAND` widgets in its tree. This may require some kind of "force expand" container, but that will be a separate issue.