enable icon indicating copy to clipboard operation
enable copied to clipboard

Use ConstraintsContainer in more places

Open corranwebster opened this issue 5 years ago • 3 comments

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.

corranwebster avatar Sep 28 '20 07:09 corranwebster

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.

rkern avatar Feb 22 '21 18:02 rkern

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.

corranwebster avatar Feb 23 '21 08:02 corranwebster

My comments were with that in mind.

rkern avatar Feb 23 '21 16:02 rkern