An extension of your code to support modifying constraints.

Added a block based interface to be able to intercept the constraints
produced by the rules. This is useful when constraints are vaired
depending on the orientation.