Merge branch 'VNNCC-dev'
This commit is contained in:
@@ -20,6 +20,7 @@ namespace FlaxEditor.GUI.Docking
|
|||||||
private Vector2 _mouse;
|
private Vector2 _mouse;
|
||||||
private DockState _toSet;
|
private DockState _toSet;
|
||||||
private DockPanel _toDock;
|
private DockPanel _toDock;
|
||||||
|
private bool _lateDragOffsetUpdate;
|
||||||
|
|
||||||
private Rectangle _rLeft, _rRight, _rBottom, _rUpper, _rCenter;
|
private Rectangle _rLeft, _rRight, _rBottom, _rUpper, _rCenter;
|
||||||
|
|
||||||
@@ -37,9 +38,14 @@ namespace FlaxEditor.GUI.Docking
|
|||||||
window.Focus();
|
window.Focus();
|
||||||
|
|
||||||
// Calculate dragging offset and move window to the destination position
|
// Calculate dragging offset and move window to the destination position
|
||||||
Vector2 mouse = FlaxEngine.Input.MouseScreenPosition;
|
var mouseScreenPosition = FlaxEngine.Input.MouseScreenPosition;
|
||||||
Vector2 baseWinPos = window.Position;
|
|
||||||
_dragOffset = mouse - baseWinPos;
|
// If the _toMove window was not focused when initializing this window, the result vector only contains zeros
|
||||||
|
// and to prevent a failure, we need to perform an update for the drag offset at later time which will be done in the OnMouseMove event handler.
|
||||||
|
if (mouseScreenPosition != Vector2.Zero)
|
||||||
|
CalculateDragOffset(mouseScreenPosition);
|
||||||
|
else
|
||||||
|
_lateDragOffsetUpdate = true;
|
||||||
|
|
||||||
// Get initial size
|
// Get initial size
|
||||||
_defaultWindowSize = window.Size;
|
_defaultWindowSize = window.Size;
|
||||||
@@ -217,6 +223,12 @@ namespace FlaxEditor.GUI.Docking
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CalculateDragOffset(Vector2 mouseScreenPosition)
|
||||||
|
{
|
||||||
|
Vector2 baseWinPos = this._toMove.Window.Window.Position;
|
||||||
|
_dragOffset = mouseScreenPosition - baseWinPos;
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateRects()
|
private void UpdateRects()
|
||||||
{
|
{
|
||||||
// Cache mouse position
|
// Cache mouse position
|
||||||
@@ -326,6 +338,16 @@ namespace FlaxEditor.GUI.Docking
|
|||||||
|
|
||||||
private void OnMouseMove(ref Vector2 mousePos)
|
private void OnMouseMove(ref Vector2 mousePos)
|
||||||
{
|
{
|
||||||
|
// Recalculate the drag offset because the current mouse screen position was invalid when we initialized the window
|
||||||
|
if (_lateDragOffsetUpdate)
|
||||||
|
{
|
||||||
|
// Calculate dragging offset and move window to the destination position
|
||||||
|
CalculateDragOffset(mousePos);
|
||||||
|
|
||||||
|
// Reset state
|
||||||
|
_lateDragOffsetUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateRects();
|
UpdateRects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user