Skip to content

Simplify interactive zoom handling. #16757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2020
Merged

Simplify interactive zoom handling. #16757

merged 2 commits into from
Mar 14, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 13, 2020

  • During interactive zoom, one can additionally press x or y to restrict
    zooming to the x or y direction. Instead of adding separate
    key_press_handlers to check that and maintaining that state in
    _zoom_mode, one can simply read event.key in the mouse handler
    (because the key needs to stay pressed for this to be active --
    there's no behavior change).
  • The ids_zoom list of callback ids can then be replaced by a single
    _id_zoom.
  • When stashing info in _xypress to perform the zoom, one only needs
    to know where the zoom started (x, y) and the underlying axes (a).
    The index (i) and view (a._get_view()) are unused, so just remove
    them.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone Mar 13, 2020
@timhoffm
Copy link
Member

_idZoom (not PEP8, but that's consistent with _idDrag, so heh)

These are private. Let‘s go the other way round, stay PEP8 conform, and maybe later rename _idDrag.

anntzer added 2 commits March 13, 2020 22:43
- During interactive zoom, one can additionally press x or y to restrict
  zooming to the x or y direction.  Instead of adding separate
  key_press_handlers to check that and maintaining that state in
  `_zoom_mode`, one can simply read `event.key` in the mouse handler
  (because the key needs to stay pressed for this to be active --
  there's no behavior change).
- The `ids_zoom` list of callback ids can then be replaced by a single
  `_id_zoom`.
- When stashing info in `_xypress` to perform the zoom, one only needs
  to know where the zoom started (x, y) and the underlying axes (a).
  The index (i) and view (a._get_view()) are unused, so just remove
  them.
@anntzer
Copy link
Contributor Author

anntzer commented Mar 13, 2020

ok, did that, and also replaced _idDrag by _id_drag in a separate commit.

@timhoffm timhoffm merged commit 2f6a7a4 into matplotlib:master Mar 14, 2020
@anntzer anntzer deleted the zoom branch March 14, 2020 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants