Skip to content

Commit

Permalink
#5792: When zooming in on the cursor position, keep the world point b…
Browse files Browse the repository at this point in the history
…elow the mouse cursor constant.

Fix the ultra-fast zooming on sensitive mouse wheels, only zoom in or out by one step, like the old-style zoom methods.
  • Loading branch information
codereader committed Oct 30, 2021
1 parent d36f1fb commit 1df6f1c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions radiant/xyview/XYWnd.cpp
Expand Up @@ -1581,7 +1581,7 @@ void XYWnd::zoomInOn(wxPoint cursor, int zoom)
const float newScale = getZoomedScale(zoom);
scrollByPixels(_width / 2 - cursor.x, _height / 2 - cursor.y);
setScale(newScale);
scrollByPixels((cursor.x - _width / 2) * oldScale / newScale, (cursor.y - _height / 2) * oldScale / newScale);
scrollByPixels(cursor.x - _width / 2, cursor.y - _height / 2);
}

// ================ CALLBACKS ======================================
Expand Down Expand Up @@ -1631,9 +1631,12 @@ bool XYWnd::onRender()

void XYWnd::onGLWindowScroll(wxMouseEvent& ev)
{
if ( !ev.ShiftDown() ) {
zoomInOn( ev.GetPosition(), ev.GetWheelRotation() / ev.GetWheelDelta() );
if (!ev.ShiftDown())
{
zoomInOn(ev.GetPosition(), ev.GetWheelRotation() > 0 ? 1 : -1);
return;
}

if (ev.GetWheelRotation() > 0)
{
zoomIn();
Expand Down

0 comments on commit 1df6f1c

Please sign in to comment.