Using constraints for user interface construction

Interactive, direct-manipulation, graphical user interfaces are easy to use but difficult to construct. This dissertation shows that automatic constraint satisfaction is useful in many facets of user interface construction and demonstrates that it is feasible. A constraint represents a desired relationship between variables. While some constraints are required to be satisfied, others may be merely preferred to varying degrees. Such preferential constraints allow the programmer to control the behavior of the constraint solver declaratively. In user interface construction, constraints can represent relationships at three levels: between application data structures and user interface components, between the components of a user interface, and between the parts of a compound component. A system that automatically maintains these relationships frees the programmer from many tedious and error prone tasks. This dissertation focuses on a constraint satisfaction technique known as local propagation. It shows how to frame local propagation as a graph problem, and proves that, in general, this problem is NP-complete. It then identifies a restricted form of the problem that can be solved efficiently by the DeltaBlue algorithm, an incremental local propagation solver that handles preferential constraints. The major contributions of this dissertation are to prove that the DeltaBlue algorithm is correct, to demonstrate that it is fast enough to provide low latency, high bandwidth interactive feedback in systems with as many as 20,000 constraints, and to show that it is powerful enough to solve many of the constraint problems that arise in user interface construction. It also addresses a number of related issues, such as how to integrate constraints with imperative programs cleanly, how to model user inputs as constraints, how to compile constraints, and how to maintain constraints on collections incrementally. Finally, it describes ThingLab II, a programming environment for constructing constraint-based user interfaces, and its use to build a number of user interfaces.