This is not necessarily the current version of this TIP.
|Title:||Add Overall Anchoring to the Grid Geometry Manager|
|Version:||$Revision: 1.10 $|
|Author:||Peter Spjuth <peter dot spjuth at space dot se>|
|Created:||Tuesday, 05 August 2003|
This TIP proposes to add an anchor option to grid managers to control the behaviour of a grid where all weights are zero.
Have you ever found yourself adding "-weight" to an unused row or column in a grid? That is usually the workaround to use when you have no "-weight" on any column but you don't want things to sit in the middle of the grid when the window is grown.
By adding an anchor option it lets the code directly reflect the intention of the programmer and it makes the code more maintainable since you can add and remove columns without having to update the dummy weight.
When growing a grid, the behaviour is rather simple. Follow the weights and when 0, follow the anchor.
When shrinking a grid without weight things get more interesting.
The previous behaviour of the grid is a bit inconsistent in that when grown it centers the slaves (as in anchor "center") and when shrunk it shows the upper left part (as in anchor "nw").
Thus, following the new anchor will not be backwardly compatible, even though I doubt it can be common for people to rely on that behaviour.
For shrinking a grid without weight there are three options.
Always clip the bottom/right. i.e. behave as now.
Clip according to anchor.
Try to shrink all columns/rows, and only clip when minsize stops further shrinking. (Clip according to anchor)
I think 2. makes more sense than 1., but it does mean a minor compatiblity breach. Also, with 2., behaviour 1. and 3. can be emulated but the other way around is harder.
With 2, there are also two choises how to break compatibility depending on the default anchor.
Anyone relying on the bottom/left clipping will find things clip all around. Potentially an important widget in the nw corner can end up outside.
Anyone relying on the centering will find things ending up in the nw corner. Probably just a visual difference.
I can't see that any of those two are significantly worse than the other.
Finally, the question "what would you do if backwards compatiblity was not an aspect?" clearly answers "2b", leading to the specification in this TIP.
A new subcommand grid anchor is added. It is similar to grid propagate in that it configures an aspect of a grid manager.
The syntax is grid anchor master ?value? where value is a standard anchor value with nw as default.
Whenever there is extra space in the grid manager and all weights are zero, the layout is placed within its master according to the master's anchor value.
Whenever there is too little space in the grid manager and all weights are zero or all columns have reached their minimumn size, the layout is clipped according to the master's anchor value.
To clarify the shrinking options here is an example.
a: Current behaviour or, "1" with anchor "center".
b: "2" with anchor "center"