Unify constraints generation into something similar.

These updates allow subclasses to define a 'layout_constraints' method
which will be called at the proper time to generate the layout.