Stop splitters from migrating between sessions #2598
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If you close and re-open GUI, the splitters between the mod list and the mod info and between the mod name/description and the mod info tabs are supposed to retain their positions. However, currently they tend to migrate rightwards and downwards rather than staying the same.
For example, across several open/close cycles where I did nothing but exit CKAN, the
ModInfoPosition
property in GUIConfig.xml took on this sequence of values:292, 569, 891, 891, 891
Closing this window:
... results in this window at the next launch:
Cause
Forms raise events in the following order at launch:
In a typical WinForms application, a form has a hard coded layout of a static size set at design time, which is then modified to fit other window sizes. To handle this, the various container controls have their layouts recalculated to fit the actual size of the window. This happens after Load and before Shown.
Currently CKAN restores the positions of its splitters in Load, before the container layouts are recalculated. This means that the saved positions are used as inputs into the recalculation process rather than absolute positions. When the layout is recalculated, different splitter positions are determined.
Changes
Now the splitter positions are set in
OnShown
instead ofOnLoad
. This ensures that the window size is the same as when the position was saved, and the layout will not be rearranged afterwards. The position is now always the same after closing and re-opening CKAN.