[Y-devel] Widget size negotiation
Lincoln Quirk lincoln at cognitoy.com
Wed Feb 25 01:29:52 GMT 2004
Within each level of widget containment there should probably be an
automatic sizing method with propagation. This way, you can resize
windows, and everything inside the window will behave optimally in terms
of the sizes.
First, each widget should have no maximum size: it should be able to
look reasonably correct with any amount of extra space that it's given.
Each widget may have a minimum size: if the widget is given less than
its minimum, it makes no guarantees in terms of displaying properly.
Each widget may have a preferred size: the 'default' negotiation size.
For many widgets, the preferred size can be equal to the minimum (for
small widgets that have a specific accepted size). Others might have no
specific preferred size.
A widget that contains other widgets calculates its minimum and
preferred size based on those of its constituents and itself (just
adding should work). This is how the size preferences propagate upwards,
and it seems reasonable.
Here's my vision of negotiation: When a 'top-level' widget (that is, one
that doesn't have a negotiated size) changes size, it asks its
subwidgets for their minimum and preferred sizes. It first tries to give
each subwidget its preferred size. There are a few things that can
happen at this point:
- There is exactly the right amount of space.
- There isn't enough space for all the widgets. In this case it reduces
the size of some of them. I think that for each widget in the dimension
in question, shrink it by an equal amount of pixels, until it reaches
its minimum.
- There's too much space. We have to decide which widgets to grow. I
would grow whichever widget has the greatest preferred size (widgets
with 'no preferred size' are considered greater than any other; also, if
there are multiple widgets with the same greatest preferred size, grow
them all equally).
The problem with this approach, as I see it, is that there's no
automatic way to change the sizes of widgets in a configuration that is
already negotiated. That is, if there's a text box, and it decides to
change its minimum size for whatever reason, it's hard to automatically
do that and have it propagate upwards.
For most purposes this is OK - when you add your widgets at the start of
the app, you just call a method at the end to get the toplevel to
renegotiate. But it is something of a limitation.
This sound reasonable? Comments?
--
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved