From c19ff9b2ef992f50b616ba94365e947959321430 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 19:25:50 -0500 Subject: [PATCH 1/6] Added a change in cursor type to assist in UX for resizing editor panels and changing the values in value boxes --- Source/Editor/GUI/Input/ValueBox.cs | 12 ++++++++++++ Source/Engine/UI/GUI/Panels/SplitPanel.cs | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index ff824d76c..4b9ef8a51 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -172,6 +172,7 @@ namespace FlaxEditor.GUI.Input { _isSliding = false; EndMouseCapture(); + Cursor = CursorType.Default; SlidingEnd?.Invoke(); } @@ -236,6 +237,7 @@ namespace FlaxEditor.GUI.Input _startSlideLocation = location; _startSlideValue = _value; StartMouseCapture(true); + Cursor = CursorType.SizeWE; SlidingStart?.Invoke(); return true; } @@ -256,6 +258,16 @@ 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; + } + else if (!_isSliding) + { + Cursor = CursorType.Default; + } base.OnMouseMove(location); } diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 8772c78e6..563f1974b 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -161,6 +161,15 @@ namespace FlaxEngine.GUI if (_splitterClicked) { SplitterValue = _orientation == Orientation.Horizontal ? location.X / Width : location.Y / Height; + Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + } + else if (_mouseOverSplitter) + { + Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + } + else + { + Cursor = CursorType.Default; } base.OnMouseMove(location); From e18002dd03544e686432a666f46fe27d8eda31ab Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 20:01:35 -0500 Subject: [PATCH 2/6] Fixed regression of cursor being stuck in default when trying to change it in viewport --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 563f1974b..bf79cb86c 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -23,6 +23,8 @@ namespace FlaxEngine.GUI private float _splitterValue; private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; + private bool _leftMouseButtonDown; + private bool _rightMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -167,7 +169,7 @@ namespace FlaxEngine.GUI { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; } - else + else if (!_leftMouseButtonDown && !_rightMouseButtonDown) { Cursor = CursorType.Default; } @@ -178,6 +180,16 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { + if (button == MouseButton.Left) + { + _leftMouseButtonDown = true; + } + + if (button == MouseButton.Right) + { + _rightMouseButtonDown = true; + } + if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -192,6 +204,16 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { + if (button == MouseButton.Left) + { + _leftMouseButtonDown = false; + } + + if (button == MouseButton.Right) + { + _rightMouseButtonDown = false; + } + if (_splitterClicked) { EndTracking(); From 3867cb5e9758d53b873e3b06776fa163a9da2af1 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 20:52:04 -0500 Subject: [PATCH 3/6] Changed how cursor is set back to default, so it doesnt keep setting itself --- Source/Editor/GUI/Input/ValueBox.cs | 4 +++- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 27 ++++------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 4b9ef8a51..4836b41c5 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -56,6 +56,7 @@ namespace FlaxEditor.GUI.Input private Float2 _startSlideLocation; private double _clickStartTime = -1; + private bool _cursorChanged; /// /// Occurs when value gets changed. @@ -263,8 +264,9 @@ namespace FlaxEditor.GUI.Input if (CanUseSliding && SlideRect.Contains(location)) { Cursor = CursorType.SizeWE; + _cursorChanged = true; } - else if (!_isSliding) + else if (_cursorChanged && !_isSliding) { Cursor = CursorType.Default; } diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index bf79cb86c..4b15c38db 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -23,8 +23,7 @@ namespace FlaxEngine.GUI private float _splitterValue; private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; - private bool _leftMouseButtonDown; - private bool _rightMouseButtonDown; + private bool _cursorChanged; /// /// The first panel (left or upper based on Orientation). @@ -168,10 +167,12 @@ namespace FlaxEngine.GUI else if (_mouseOverSplitter) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + _cursorChanged = true; } - else if (!_leftMouseButtonDown && !_rightMouseButtonDown) + else if (_cursorChanged) { Cursor = CursorType.Default; + _cursorChanged = false; } base.OnMouseMove(location); @@ -180,16 +181,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { - if (button == MouseButton.Left) - { - _leftMouseButtonDown = true; - } - - if (button == MouseButton.Right) - { - _rightMouseButtonDown = true; - } - if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -204,16 +195,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { - if (button == MouseButton.Left) - { - _leftMouseButtonDown = false; - } - - if (button == MouseButton.Right) - { - _rightMouseButtonDown = false; - } - if (_splitterClicked) { EndTracking(); From aca552224580009b3ce129cdcb496c2c55e0eb70 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 5 Oct 2022 21:16:54 -0500 Subject: [PATCH 4/6] Fixed small bug when moving a tab when close to the split panel splitter --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 4b15c38db..65ef60a19 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -24,6 +24,7 @@ namespace FlaxEngine.GUI private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; private bool _cursorChanged; + private bool _anyMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -163,8 +164,9 @@ namespace FlaxEngine.GUI { SplitterValue = _orientation == Orientation.Horizontal ? location.X / Width : location.Y / Height; Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + _cursorChanged = true; } - else if (_mouseOverSplitter) + else if (_mouseOverSplitter && !_anyMouseButtonDown) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; @@ -181,6 +183,7 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { + _anyMouseButtonDown = true; if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -195,6 +198,7 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { + _anyMouseButtonDown = false; if (_splitterClicked) { EndTracking(); From 6d6961d9611fdfb4ea88c2ed2f6c57a0ac2e94ce Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 19:59:51 -0500 Subject: [PATCH 5/6] removed mouse button down as it caused issues with focus --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 65ef60a19..5fb8c410a 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -24,7 +24,6 @@ namespace FlaxEngine.GUI private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; private bool _cursorChanged; - private bool _anyMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -166,7 +165,7 @@ namespace FlaxEngine.GUI Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; } - else if (_mouseOverSplitter && !_anyMouseButtonDown) + else if (_mouseOverSplitter) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; @@ -183,7 +182,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { - _anyMouseButtonDown = true; if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -198,7 +196,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { - _anyMouseButtonDown = false; if (_splitterClicked) { EndTracking(); From 133d13ff3ca452701ee2e9d66fc369104f6e6c77 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 10 Oct 2022 11:06:10 -0500 Subject: [PATCH 6/6] Fixed continually setting cursour back to default in value box --- Source/Editor/GUI/Input/ValueBox.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 4836b41c5..2b13742ee 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -174,6 +174,7 @@ namespace FlaxEditor.GUI.Input _isSliding = false; EndMouseCapture(); Cursor = CursorType.Default; + _cursorChanged = false; SlidingEnd?.Invoke(); } @@ -224,6 +225,8 @@ namespace FlaxEditor.GUI.Input // Update UpdateText(); } + + Cursor = CursorType.Default; ResetViewOffset(); } @@ -239,6 +242,7 @@ namespace FlaxEditor.GUI.Input _startSlideValue = _value; StartMouseCapture(true); Cursor = CursorType.SizeWE; + _cursorChanged = true; SlidingStart?.Invoke(); return true; } @@ -269,6 +273,7 @@ namespace FlaxEditor.GUI.Input else if (_cursorChanged && !_isSliding) { Cursor = CursorType.Default; + _cursorChanged = false; } base.OnMouseMove(location);