Merge branch 'UnifyZoomBehavior' of https://github.com/xxSeys1/FlaxEngine into xxSeys1-UnifyZoomBehavior

This commit is contained in:
Wojtek Figat
2025-06-02 12:25:18 +02:00

View File

@@ -369,24 +369,14 @@ namespace FlaxEditor.Surface
} }
// Change scale (disable scaling during selecting nodes) // Change scale (disable scaling during selecting nodes)
if (IsMouseOver && !_leftMouseDown && !IsPrimaryMenuOpened) if (IsMouseOver && !_leftMouseDown && !_rightMouseDown && !IsPrimaryMenuOpened)
{ {
var nextViewScale = ViewScale + delta * 0.1f; var nextViewScale = ViewScale + delta * 0.1f;
if (delta > 0 && !_rightMouseDown) // Scale towards/ away from mouse when zooming in/ out
{ var nextCenterPosition = ViewPosition + location / ViewScale;
// Scale towards mouse when zooming in ViewScale = nextViewScale;
var nextCenterPosition = ViewPosition + location / ViewScale; ViewPosition = nextCenterPosition - (location / ViewScale);
ViewScale = nextViewScale;
ViewPosition = nextCenterPosition - (location / ViewScale);
}
else
{
// Scale while keeping center position when zooming out or when dragging view
var viewCenter = ViewCenterPosition;
ViewScale = nextViewScale;
ViewCenterPosition = viewCenter;
}
return true; return true;
} }