Merge branch 'cursor-changes' of https://github.com/Tryibion/FlaxEngine into Tryibion-cursor-changes

This commit is contained in:
Wojtek Figat
2022-10-10 18:33:29 +02:00
2 changed files with 32 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ namespace FlaxEditor.GUI.Input
private Float2 _startSlideLocation;
private double _clickStartTime = -1;
private bool _cursorChanged;
/// <summary>
/// Occurs when value gets changed.
@@ -172,6 +173,8 @@ namespace FlaxEditor.GUI.Input
{
_isSliding = false;
EndMouseCapture();
Cursor = CursorType.Default;
_cursorChanged = false;
SlidingEnd?.Invoke();
}
@@ -222,6 +225,8 @@ namespace FlaxEditor.GUI.Input
// Update
UpdateText();
}
Cursor = CursorType.Default;
ResetViewOffset();
}
@@ -236,6 +241,8 @@ namespace FlaxEditor.GUI.Input
_startSlideLocation = location;
_startSlideValue = _value;
StartMouseCapture(true);
Cursor = CursorType.SizeWE;
_cursorChanged = true;
SlidingStart?.Invoke();
return true;
}
@@ -256,6 +263,18 @@ namespace FlaxEditor.GUI.Input
ApplySliding(Mathf.RoundToInt(slideLocation.X - _startSlideLocation.X) * _slideSpeed);
return;
}
// Update cursor type so user knows they can slide value
if (CanUseSliding && SlideRect.Contains(location))
{
Cursor = CursorType.SizeWE;
_cursorChanged = true;
}
else if (_cursorChanged && !_isSliding)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseMove(location);
}

View File

@@ -23,6 +23,7 @@ namespace FlaxEngine.GUI
private float _splitterValue;
private Rectangle _splitterRect;
private bool _splitterClicked, _mouseOverSplitter;
private bool _cursorChanged;
/// <summary>
/// The first panel (left or upper based on Orientation).
@@ -161,6 +162,18 @@ namespace FlaxEngine.GUI
if (_splitterClicked)
{
SplitterValue = _orientation == Orientation.Horizontal ? location.X / Width : location.Y / Height;
Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS;
_cursorChanged = true;
}
else if (_mouseOverSplitter)
{
Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS;
_cursorChanged = true;
}
else if (_cursorChanged)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseMove(location);