Skip to content

Add fixed-mouse-position wheel zoom action (Google Maps style) - #159

Merged
jkriege2 merged 3 commits into
jkriege2:masterfrom
waka4g:feature/zoom-fixed-mouse-wheel
Dec 22, 2025
Merged

Add fixed-mouse-position wheel zoom action (Google Maps style)#159
jkriege2 merged 3 commits into
jkriege2:masterfrom
waka4g:feature/zoom-fixed-mouse-wheel

Conversation

@waka4g

@waka4g waka4g commented Dec 12, 2025

Copy link
Copy Markdown

First of all, thank you for creating and maintaining this wonderful library! I'm using JKQtPlotter for an internal tool at my company, and it has been incredibly helpful.

I wanted to add a new zoom mode for mouse wheel operation, so I'm submitting this PR. I would appreciate it if you could consider this contribution.

This adds new mouse wheel zoom actions that keep the position under the mouse cursor fixed during zooming (Google Maps style zoom behavior).

Summary

Add new mouse wheel zoom actions that keep the position under the mouse cursor fixed during zooming (Google Maps
style zoom behavior).

New Features

  • jkqtpmwaZoomFixedMouseByWheel - Zoom with fixed mouse position
  • jkqtpmwaZoomFixedMouseByWheelAndTrackpadPan - Same as above with trackpad pan gesture support

Changes

  • Added new enum values to JKQTPMouseWheelActions
  • Added string conversion functions for the new actions
  • Implemented fixed-mouse-position zoom logic in wheelEvent()
  • Works for both plot area and axis-only zooming
  • Updated user_interaction example to demonstrate the new options

Usage

plotter->registerMouseWheelAction(Qt::NoModifier,
    JKQTPMouseWheelActions::jkqtpmwaZoomFixedMouseByWheel);

Behavior Comparison

Action Behavior
jkqtpmwaZoomByWheel Mouse position becomes the center of the new view
jkqtpmwaZoomFixedMouseByWheel Mouse position stays fixed on screen (Google Maps style)

twakatsu added 3 commits December 12, 2025 10:36
  Revert the comment to its original state, as the behavior was not changed.
  Revert comments for jkqtpmwaZoomByWheel and jkqtpmwaZoomByWheelAndTrackpadPan
  to their original state, as no behavior was changed for these actions.
@jkriege2
jkriege2 merged commit 17df5d3 into jkriege2:master Dec 22, 2025
11 checks passed
@jkriege2

Copy link
Copy Markdown
Owner

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants