pioneerspacesim/pioneer — pull request #1746 by robn (2012-11-21 02:54:17+00:00)
Title: New UI: Size control

Currently a widget can't easily tell the container if it has special requirements for sizing if it can't get its preferred size, or if it has unusual layout requirements. Return 0 or `SIZE_EXPAND` in its preferred size has been used to try to allow a widget to influence things, but its a bit of a hack.

This allows a widget to specify some specific flags in addition to its preferred size that help the container figure out exactly how to size and layout the widget. Some, like `NO_HEIGHT` and `NO_WIDTH` influence the way the container does its layout. Others, like `PRESERVE_ASPECT` influence the way the widget is sized when the container can't give its preferred size.

There's some helper functions in `Container` that do most of the work so a container shouldn't have to try very hard - it should mostly just work.

The initial benefit of this is that `Image`s can now be controlled better, and `Icon`s don't contribute height and do scale nicely, so they can be packed into a `HBox` with a label and take its height.