MMB Panning

Added MMB panning to VisjectSurfaces (materials/etc).
This commit is contained in:
Luke Schneider
2023-09-21 08:37:13 -05:00
parent 97ed46bc4f
commit ad29dd0c92
2 changed files with 44 additions and 1 deletions

View File

@@ -213,6 +213,21 @@ namespace FlaxEditor.Surface
return; 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) // Check if user is selecting or moving node(s)
if (_leftMouseDown) if (_leftMouseDown)
{ {
@@ -269,6 +284,10 @@ namespace FlaxEditor.Surface
_rightMouseDown = false; _rightMouseDown = false;
Cursor = CursorType.Default; Cursor = CursorType.Default;
} }
if (_middleMouseDown) {
_middleMouseDown = false;
Cursor = CursorType.Default;
}
_isMovingSelection = false; _isMovingSelection = false;
ConnectingEnd(null); ConnectingEnd(null);
@@ -380,6 +399,7 @@ namespace FlaxEditor.Surface
_isMovingSelection = false; _isMovingSelection = false;
_rightMouseDown = false; _rightMouseDown = false;
_leftMouseDown = false; _leftMouseDown = false;
_middleMouseDown = false;
return true; return true;
} }
@@ -398,6 +418,12 @@ namespace FlaxEditor.Surface
{ {
_rightMouseDown = true; _rightMouseDown = true;
_rightMouseDownPos = location; _rightMouseDownPos = location;
Debug.Log("The right mouse button is down in a window");
}
if (button == MouseButton.Middle) {
_middleMouseDown = true;
_middleMouseDownPos = location;
Debug.Log("The middle mouse button is down in a window");
} }
// Check if any node is under the mouse // Check if any node is under the mouse
@@ -444,7 +470,7 @@ namespace FlaxEditor.Surface
Focus(); Focus();
return true; return true;
} }
if (_rightMouseDown) if (_rightMouseDown || _middleMouseDown)
{ {
// Start navigating // Start navigating
StartMouseCapture(); StartMouseCapture();
@@ -513,6 +539,12 @@ namespace FlaxEditor.Surface
} }
_mouseMoveAmount = 0; _mouseMoveAmount = 0;
} }
if (_middleMouseDown && button == MouseButton.Middle) {
_middleMouseDown = false;
EndMouseCapture();
Cursor = CursorType.Default;
_mouseMoveAmount = 0;
}
// Base // Base
bool handled = base.OnMouseUp(location, button); bool handled = base.OnMouseUp(location, button);
@@ -523,6 +555,7 @@ namespace FlaxEditor.Surface
// Clear flags // Clear flags
_rightMouseDown = false; _rightMouseDown = false;
_leftMouseDown = false; _leftMouseDown = false;
_middleMouseDown = false;
return true; return true;
} }

View File

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