enable
enable copied to clipboard
Use ConstraintsContainer in more places
Enable has some basic layout classes and methods: OverlayContainer, StackedContainer and subclasses, and the code in enable.simple_layout.
The code in these classes would become significantly simpler if it were converted to use the constraints system.
Just to throw out some alternatives for consideration:
My experience with constraint-based layout for GUIs has been that it is very easy to create unsolvable systems of constraints that are then very opaque to debug. If we used constraint solvers to implement these core containers, we should try to ensure that they are correct by construction regardless of their contents. It's possible this is easy enough for these layouts, but if it's not, then I'd avoid using constraints here.
Some other alternatives to constraints or our homegrown algorithm would be to use a flexbox layout implementation like Yoga (a C++ library) or Stretch (Rust). They probably expose the right level of semantics (raw constraints are very low level), have better-defined behavior when the user requests odd things (you'll always get a layout where probably only the problematic components are laid out badly), and refer to transferable concepts from HTML. Both would need to be wrapped, however; Python wrappers of each do exist, but seem to be preliminary and unmaintained.
My thought was not to remove those classes, but to replace the internal layout logic with the constraints system. The user-facing API would be unchanged.
My comments were with that in mind.