pioneerspacesim/pioneer — pull request #2575 by robn (2013-12-13 09:23:10+00:00)
Title: Rewrite Box layout to constrain the widgets to the allocation

Or maybe "de-write" is a better term, since this more-or-less restores it to where it was originally before I rewrote it in @9ff2a617.

Currently Box will effectively give unlimited size to its children, positioning them outside the box if necessary (which just gets them clipped during drawing). This makes it impossible to usefully embed a Box in a container that could give it more space if necessary, like a Scroller. The Box never reports that it would like more space, assuming it can take care of it all, and so the Scroller effectively becomes a no-op.

This PR forces all widgets to be limited to the area allocated to the box. If there's not enough room, they will receive less space. Leftover space will be allocated to to expandable widgets or just dropped.

I've deliberately spelt out the algorithm even though there's probably some generalisation possible because its a bit fiddly and I don't want to complicate it early.

(Incidentally, this came about because I got stuck on a couple of things in `new-ui-stationview` and I started to think that I needed something like [CSS Flexboxes](http://css-tricks.com/snippets/css/a-guide-to-flexbox/). After studying it for a while I realised that what Box used to do was actually pretty close to what I wanted. It might be nice to implement some of the other spacing concepts from Flexboxes one day).