Toolbar tracks views if axes are added during use #3347
Closed
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.
This is an initial implementation of a fix for #2511. This pull request should not be merged. Once MEP22 is merged, I'll port this code to backend_tools.ViewsPositionsMixin. (The porting should be fairly trivial.) I finished the implemented of this recently for in-house use, so I figured I'd put up a PR against master in case anyone had any initial comments.
With this PR, the back, forward, and home buttons in the toolbar will continue to work even if the number of axes changes. I've added a _home_views dictionary that stores the initial views of all axes. If an axes object didn't exist when a view was created, the initial view will be used for that axes. Positions will only be restored if there is a position for all axes objects. This avoids having newer axes overlap with older ones when clicking on back or home.
I haven't disconnected toolbar.update() as an axobserver in this PR since that will be hooked up slightly differently once MEP22 is merged.