diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index 8521a548f..59b51c612 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -1574,7 +1574,7 @@ public static partial class Application { // If the mouse is grabbed, send the event to the view that grabbed it. // The coordinates are relative to the Bounds of the view that grabbed the mouse. - Point frameLoc = MouseGrabView.ScreenToViewport (mouseEvent.X, mouseEvent.Y); + Point frameLoc = MouseGrabView.ScreenToViewport (new (mouseEvent.X, mouseEvent.Y)); var viewRelativeMouseEvent = new MouseEvent { @@ -1650,7 +1650,7 @@ public static partial class Application } else if (view.ViewportToScreen (Rectangle.Empty with { Size = view.Viewport.Size }).Contains (mouseEvent.X, mouseEvent.Y)) { - Point viewportLocation = view.ScreenToViewport (mouseEvent.X, mouseEvent.Y); + Point viewportLocation = view.ScreenToViewport (new (mouseEvent.X, mouseEvent.Y)); me = new () { @@ -1709,7 +1709,7 @@ public static partial class Application break; } - Point boundsPoint = view.ScreenToViewport (mouseEvent.X, mouseEvent.Y); + Point boundsPoint = view.ScreenToViewport (new (mouseEvent.X, mouseEvent.Y)); me = new () { diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index c7bd4bde2..0e134c512 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -135,9 +135,9 @@ public class Adornment : View } /// - public override Point ScreenToFrame (Point screen) + public override Point ScreenToFrame (Point location) { - return Parent.ScreenToFrame (new (screen.X - Frame.X, screen.Y - Frame.Y)); + return Parent.ScreenToFrame (new (location.X - Frame.X, location.Y - Frame.Y)); } /// Does nothing for Adornment diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 922fa2a19..60d789c51 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -301,7 +301,7 @@ public class Border : Adornment _dragPosition = new Point (mouseEvent.X, mouseEvent.Y); - Point parentLoc = Parent.SuperView?.ScreenToViewport (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y) ?? mouseEvent.ScreenPosition; + Point parentLoc = Parent.SuperView?.ScreenToViewport (new (mouseEvent.ScreenPosition.X, mouseEvent.ScreenPosition.Y)) ?? mouseEvent.ScreenPosition; GetLocationEnsuringFullVisibility ( Parent, diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 235e8c388..53dfb000d 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -147,22 +147,22 @@ public partial class View /// View's 's . /// /// The coordinate relative to the 's . - /// Screen-relative coordinate. - public virtual Point ScreenToFrame (Point screen) + /// Screen-relative coordinate. + public virtual Point ScreenToFrame (Point location) { if (SuperView is null) { - return new (screen.X - Frame.X, screen.Y - Frame.Y); + return new (location.X - Frame.X, location.Y - Frame.Y); } Point superViewViewportOffset = SuperView.GetViewportOffsetFromFrame (); superViewViewportOffset.X -= SuperView.Viewport.X; superViewViewportOffset.Y -= SuperView.Viewport.Y; - screen.X -= superViewViewportOffset.X; - screen.Y -= superViewViewportOffset.Y; + location.X -= superViewViewportOffset.X; + location.Y -= superViewViewportOffset.Y; - Point frame = SuperView.ScreenToFrame (screen); + Point frame = SuperView.ScreenToFrame (location); frame.X -= Frame.X; frame.Y -= Frame.Y; diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs index 53b299a37..6fc85439a 100644 --- a/Terminal.Gui/View/ViewContent.cs +++ b/Terminal.Gui/View/ViewContent.cs @@ -446,15 +446,14 @@ public partial class View /// /// Viewport-relative means relative to the top-left corner of the inner rectangle of the . /// - /// Column relative to the left side of the Viewport. - /// Row relative to the top of the Viewport - public Point ScreenToViewport (int x, int y) + /// Screen-Relative Coordinate. + public Point ScreenToViewport (in Point location) { Point viewportOffset = GetViewportOffsetFromFrame (); - Point screen = ScreenToFrame (new (x, y)); - screen.Offset (-viewportOffset.X, -viewportOffset.Y); + Point frame = ScreenToFrame (location); + frame.Offset (-viewportOffset.X, -viewportOffset.Y); - return screen; + return frame; } /// diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 6d0353f9b..03d6a693e 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -726,7 +726,7 @@ internal sealed class Menu : View View view = a.View ?? this; - Point boundsPoint = view.ScreenToViewport (a.X, a.Y); + Point boundsPoint = view.ScreenToViewport (new (a.X, a.Y)); var me = new MouseEvent { X = boundsPoint.X, diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs index b23351e9f..c6d75e806 100644 --- a/UnitTests/View/Layout/ScreenToTests.cs +++ b/UnitTests/View/Layout/ScreenToTests.cs @@ -32,7 +32,7 @@ public class ScreenToTests BorderStyle = LineStyle.Single }; - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -54,7 +54,7 @@ public class ScreenToTests { var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 }; - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -82,7 +82,7 @@ public class ScreenToTests var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 }; super.Add (view); - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -113,7 +113,7 @@ public class ScreenToTests view.Viewport = new (1, 1, 5, 5); - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -134,7 +134,7 @@ public class ScreenToTests var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 }; super.Add (view); - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); } @@ -169,7 +169,7 @@ public class ScreenToTests view.Viewport = view.Viewport with { Location = new (1, 1) }; - Point actual = view.ScreenToViewport (x, y); + Point actual = view.ScreenToViewport (new (x, y)); Assert.Equal (expectedX, actual.X); Assert.Equal (expectedY, actual.Y); }