Merge branch 'MMB_Pan' of https://github.com/Radiangames/FlaxEngine into Radiangames-MMB_Pan

This commit is contained in:
Wojtek Figat
2023-09-25 15:40:19 +02:00
2 changed files with 42 additions and 1 deletions

View File

@@ -213,6 +213,21 @@ namespace FlaxEditor.Surface
return;
}
if (_middleMouseDown) {
// Calculate delta
var delta = location - _middleMouseDownPos;
if (delta.LengthSquared > 0.01f) {
// Move view
_mouseMoveAmount += delta.Length;
_rootControl.Location += delta;
_middleMouseDownPos = location;
Cursor = CursorType.SizeAll;
}
// Handled
return;
}
// Check if user is selecting or moving node(s)
if (_leftMouseDown)
{
@@ -269,6 +284,10 @@ namespace FlaxEditor.Surface
_rightMouseDown = false;
Cursor = CursorType.Default;
}
if (_middleMouseDown) {
_middleMouseDown = false;
Cursor = CursorType.Default;
}
_isMovingSelection = false;
ConnectingEnd(null);
@@ -380,6 +399,7 @@ namespace FlaxEditor.Surface
_isMovingSelection = false;
_rightMouseDown = false;
_leftMouseDown = false;
_middleMouseDown = false;
return true;
}
@@ -399,6 +419,10 @@ namespace FlaxEditor.Surface
_rightMouseDown = true;
_rightMouseDownPos = location;
}
if (button == MouseButton.Middle) {
_middleMouseDown = true;
_middleMouseDownPos = location;
}
// Check if any node is under the mouse
SurfaceControl controlUnderMouse = GetControlUnderMouse();
@@ -444,7 +468,7 @@ namespace FlaxEditor.Surface
Focus();
return true;
}
if (_rightMouseDown)
if (_rightMouseDown || _middleMouseDown)
{
// Start navigating
StartMouseCapture();
@@ -513,6 +537,12 @@ namespace FlaxEditor.Surface
}
_mouseMoveAmount = 0;
}
if (_middleMouseDown && button == MouseButton.Middle) {
_middleMouseDown = false;
EndMouseCapture();
Cursor = CursorType.Default;
_mouseMoveAmount = 0;
}
// Base
bool handled = base.OnMouseUp(location, button);
@@ -523,6 +553,7 @@ namespace FlaxEditor.Surface
// Clear flags
_rightMouseDown = false;
_leftMouseDown = false;
_middleMouseDown = false;
return true;
}

View File

@@ -59,6 +59,11 @@ namespace FlaxEditor.Surface
/// </summary>
protected bool _rightMouseDown;
/// <summary>
/// The middle mouse down flag.
/// </summary>
protected bool _middleMouseDown;
/// <summary>
/// The left mouse down position.
/// </summary>
@@ -69,6 +74,11 @@ namespace FlaxEditor.Surface
/// </summary>
protected Float2 _rightMouseDownPos = Float2.Minimum;
/// <summary>
/// The middle mouse down position.
/// </summary>
protected Float2 _middleMouseDownPos = Float2.Minimum;
/// <summary>
/// The mouse position.
/// </summary>