From 7656c6981e74c524bedf304f761190b22befd088 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:09:31 -0300 Subject: [PATCH 1/7] added is flipping variables --- Source/Engine/Platform/Base/WindowBase.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h index 9782f40bb..2b10fd27b 100644 --- a/Source/Engine/Platform/Base/WindowBase.h +++ b/Source/Engine/Platform/Base/WindowBase.h @@ -287,6 +287,8 @@ protected: bool _isUsingMouseOffset; Rectangle _mouseOffsetScreenSize; bool _isTrackingMouse; + bool _isHorizontalFlippingMouse; + bool _isVerticalFlippingMouse; bool _isClippingCursor; explicit WindowBase(const CreateWindowSettings& settings); @@ -680,6 +682,22 @@ public: return _isTrackingMouse; } + /// + /// todo : add doc + /// + API_PROPERTY() bool IsHorizontalFlippingMouse() const + { + return _isHorizontalFlippingMouse; + } + + /// + /// todo : add doc + /// + API_PROPERTY() bool IsVerticalFlippingMouse() const + { + return _isVerticalFlippingMouse; + } + /// /// Ends the mouse tracking. /// From ae04253ba46a5cd2db761172925e5fdbed3caa04 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:11:33 -0300 Subject: [PATCH 2/7] added is flipping mouse on windows platform --- Source/Engine/Platform/Windows/WindowsWindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp index 0cd6aab95..62bce0014 100644 --- a/Source/Engine/Platform/Windows/WindowsWindow.cpp +++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp @@ -824,14 +824,14 @@ LRESULT WindowsWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) const Float2 mousePos(static_cast(WINDOWS_GET_X_LPARAM(lParam)), static_cast(WINDOWS_GET_Y_LPARAM(lParam))); Float2 mousePosition = ClientToScreen(mousePos); Float2 newMousePosition = mousePosition; - if (mousePosition.X <= desktopLocation.X + 2) - newMousePosition.X = desktopSize.X - 2; - else if (mousePosition.X >= desktopSize.X - 1) - newMousePosition.X = desktopLocation.X + 2; - if (mousePosition.Y <= desktopLocation.Y + 2) - newMousePosition.Y = desktopSize.Y - 2; - else if (mousePosition.Y >= desktopSize.Y - 1) - newMousePosition.Y = desktopLocation.Y + 2; + if (_isHorizontalFlippingMouse = mousePosition.X <= desktopLocation.X + 2) + newMousePosition.X = desktopSize.X - 3; + else if (_isHorizontalFlippingMouse = mousePosition.X >= desktopSize.X - 1) + newMousePosition.X = desktopLocation.X + 3; + if (_isVerticalFlippingMouse = mousePosition.Y <= desktopLocation.Y + 2) + newMousePosition.Y = desktopSize.Y - 3; + else if (_isVerticalFlippingMouse = mousePosition.Y >= desktopSize.Y - 1) + newMousePosition.Y = desktopLocation.Y + 3; if (!Float2::NearEqual(mousePosition, newMousePosition)) { _trackingMouseOffset -= newMousePosition - mousePosition; From f22a71509b8f8fc433bd98759ce312795bfc209d Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:12:38 -0300 Subject: [PATCH 3/7] fix value box sliding --- Source/Editor/GUI/Input/ValueBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index b818c56d5..0d1cbd356 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.Input /// public override void OnMouseMove(Float2 location) { - if (_isSliding) + if (_isSliding && !RootWindow.Window.IsHorizontalFlippingMouse) { // Update sliding var slideLocation = location + Root.TrackingMouseOffset; From 0e45f16b1998965e58a8b6f795a7b24fe0fbbf03 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:14:47 -0300 Subject: [PATCH 4/7] update timeline edge to use the mouse flipping info --- .../Editor/GUI/Timeline/GUI/TimelineEdge.cs | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs index 2d93fb79b..0a620b86b 100644 --- a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs +++ b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs @@ -71,27 +71,10 @@ namespace FlaxEditor.GUI.Timeline.GUI /// public override void OnMouseMove(Float2 location) { - if (_isMoving) + if (_isMoving && !_timeline.RootWindow.Window.IsHorizontalFlippingMouse) { - Float2 currWndCenter = _timeline.RootWindow.Window.ClientBounds.Center; - Float2 currMonitorSize = Platform.GetMonitorBounds(currWndCenter).Size; var moveLocation = Root.MousePosition; - var diffFromLastMoveLocation = Mathf.Max(_lastMouseLocation.X, moveLocation.X) - Mathf.Min(_lastMouseLocation.X, moveLocation.X); - var movePorcentOfXMonitorSize = diffFromLastMoveLocation * 100f / currMonitorSize.X; - - if (movePorcentOfXMonitorSize >= 90f) - { - if (_lastMouseLocation.X > moveLocation.X) - { - _flipScreenMoveDelta += currMonitorSize.X; - } - else - { - _flipScreenMoveDelta -= currMonitorSize.X; - } - } - - var moveLocationDelta = moveLocation - _startMoveLocation + _flipScreenMoveDelta; + var moveLocationDelta = moveLocation - _startMoveLocation + _timeline.Root.TrackingMouseOffset.X; var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond); var durationFrames = _timeline.DurationFrames; From 84009baeb00432a4e70a770adf5f2002cf9c22bf Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:10:35 -0300 Subject: [PATCH 5/7] change vars name and add code doc --- Source/Engine/Platform/Base/WindowBase.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h index 2b10fd27b..ebeeb6b45 100644 --- a/Source/Engine/Platform/Base/WindowBase.h +++ b/Source/Engine/Platform/Base/WindowBase.h @@ -683,17 +683,17 @@ public: } /// - /// todo : add doc + /// Gets the value indicating if the mouse flipped to the other screen edge horizontally /// - API_PROPERTY() bool IsHorizontalFlippingMouse() const + API_PROPERTY() bool IsMouseFlippingHorizontally() const { return _isHorizontalFlippingMouse; } /// - /// todo : add doc + /// Gets the value indicating if the mouse flipped to the other screen edge vertically /// - API_PROPERTY() bool IsVerticalFlippingMouse() const + API_PROPERTY() bool IsMouseFlippingVertically() const { return _isVerticalFlippingMouse; } From 2c12fffdf6f42d28a9e7ce0d61df70f4a9606833 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:14:05 -0300 Subject: [PATCH 6/7] reset value when start/stop mouse tracking --- Source/Engine/Platform/Windows/WindowsWindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp index 62bce0014..da7692eeb 100644 --- a/Source/Engine/Platform/Windows/WindowsWindow.cpp +++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp @@ -544,6 +544,8 @@ void WindowsWindow::StartTrackingMouse(bool useMouseScreenOffset) _isTrackingMouse = true; _trackingMouseOffset = Float2::Zero; _isUsingMouseOffset = useMouseScreenOffset; + _isHorizontalFlippingMouse = false; + _isVerticalFlippingMouse = false; int32 x = 0, y = 0, width = 0, height = 0; GetScreenInfo(x, y, width, height); @@ -558,6 +560,8 @@ void WindowsWindow::EndTrackingMouse() if (_isTrackingMouse) { _isTrackingMouse = false; + _isHorizontalFlippingMouse = false; + _isVerticalFlippingMouse = false; ReleaseCapture(); } From 527ba719f44ad9d829a6e9ab24f5eef1fce03bf6 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:15:04 -0300 Subject: [PATCH 7/7] update to the new variable names --- Source/Editor/GUI/Input/ValueBox.cs | 2 +- Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 0d1cbd356..50cdd529c 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.Input /// public override void OnMouseMove(Float2 location) { - if (_isSliding && !RootWindow.Window.IsHorizontalFlippingMouse) + if (_isSliding && !RootWindow.Window.IsMouseFlippingHorizontally) { // Update sliding var slideLocation = location + Root.TrackingMouseOffset; diff --git a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs index 0a620b86b..b74b47c46 100644 --- a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs +++ b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs @@ -15,8 +15,6 @@ namespace FlaxEditor.GUI.Timeline.GUI private Timeline _timeline; private bool _isMoving; private Float2 _startMoveLocation; - private Float2 _lastMouseLocation; - private float _flipScreenMoveDelta; private int _startMoveDuration; private bool _isStart; private bool _canEdit; @@ -71,15 +69,13 @@ namespace FlaxEditor.GUI.Timeline.GUI /// public override void OnMouseMove(Float2 location) { - if (_isMoving && !_timeline.RootWindow.Window.IsHorizontalFlippingMouse) + if (_isMoving && !_timeline.RootWindow.Window.IsMouseFlippingHorizontally) { var moveLocation = Root.MousePosition; var moveLocationDelta = moveLocation - _startMoveLocation + _timeline.Root.TrackingMouseOffset.X; var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond); var durationFrames = _timeline.DurationFrames; - - if (_isStart) { // TODO: editing timeline start frame? @@ -94,9 +90,6 @@ namespace FlaxEditor.GUI.Timeline.GUI { _timeline.MarkAsEdited(); } - - _lastMouseLocation = moveLocation; - } else { @@ -148,7 +141,6 @@ namespace FlaxEditor.GUI.Timeline.GUI _timeline.DurationFrames = duration; } _isMoving = false; - _flipScreenMoveDelta = 0; _timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum; EndMouseCapture();