Merge branch 'cristhofermarques-mouse_fix'
This commit is contained in:
@@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.Input
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
if (_isSliding)
|
||||
if (_isSliding && !RootWindow.Window.IsMouseFlippingHorizontally)
|
||||
{
|
||||
// Update sliding
|
||||
var slideLocation = location + Root.TrackingMouseOffset;
|
||||
|
||||
@@ -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,32 +69,13 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
if (_isMoving)
|
||||
if (_isMoving && !_timeline.RootWindow.Window.IsMouseFlippingHorizontally)
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
|
||||
if (_isStart)
|
||||
{
|
||||
// TODO: editing timeline start frame?
|
||||
@@ -111,9 +90,6 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
{
|
||||
_timeline.MarkAsEdited();
|
||||
}
|
||||
|
||||
_lastMouseLocation = moveLocation;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,7 +141,6 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
_timeline.DurationFrames = duration;
|
||||
}
|
||||
_isMoving = false;
|
||||
_flipScreenMoveDelta = 0;
|
||||
_timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum;
|
||||
|
||||
EndMouseCapture();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value indicating if the mouse flipped to the other screen edge horizontally
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsMouseFlippingHorizontally() const
|
||||
{
|
||||
return _isHorizontalFlippingMouse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value indicating if the mouse flipped to the other screen edge vertically
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsMouseFlippingVertically() const
|
||||
{
|
||||
return _isVerticalFlippingMouse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the mouse tracking.
|
||||
/// </summary>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -824,14 +828,14 @@ LRESULT WindowsWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
const Float2 mousePos(static_cast<float>(WINDOWS_GET_X_LPARAM(lParam)), static_cast<float>(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;
|
||||
|
||||
Reference in New Issue
Block a user