diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs
index 28322e916..8521a548f 100644
--- a/Terminal.Gui/Application.cs
+++ b/Terminal.Gui/Application.cs
@@ -1637,7 +1637,7 @@ public static partial class Application
if (view is Adornment adornment)
{
- Point frameLoc = adornment.ScreenToFrame (mouseEvent.X, mouseEvent.Y);
+ Point frameLoc = adornment.ScreenToFrame (new (mouseEvent.X, mouseEvent.Y));
me = new ()
{
diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs
index 0829e961d..c7bd4bde2 100644
--- a/Terminal.Gui/View/Adornment/Adornment.cs
+++ b/Terminal.Gui/View/Adornment/Adornment.cs
@@ -135,7 +135,10 @@ public class Adornment : View
}
///
- public override Point ScreenToFrame (int x, int y) { return Parent.ScreenToFrame (x - Frame.X, y - Frame.Y); }
+ public override Point ScreenToFrame (Point screen)
+ {
+ return Parent.ScreenToFrame (new (screen.X - Frame.X, screen.Y - Frame.Y));
+ }
/// Does nothing for Adornment
///
diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs
index 5a0366452..235e8c388 100644
--- a/Terminal.Gui/View/Layout/ViewLayout.cs
+++ b/Terminal.Gui/View/Layout/ViewLayout.cs
@@ -147,23 +147,22 @@ public partial class View
/// View's 's .
///
/// The coordinate relative to the 's .
- /// Screen-relative column.
- /// Screen-relative row.
- public virtual Point ScreenToFrame (int x, int y)
+ /// Screen-relative coordinate.
+ public virtual Point ScreenToFrame (Point screen)
{
if (SuperView is null)
{
- return new (x - Frame.X, y - Frame.Y);
+ return new (screen.X - Frame.X, screen.Y - Frame.Y);
}
Point superViewViewportOffset = SuperView.GetViewportOffsetFromFrame ();
superViewViewportOffset.X -= SuperView.Viewport.X;
superViewViewportOffset.Y -= SuperView.Viewport.Y;
- x -= superViewViewportOffset.X;
- y -= superViewViewportOffset.Y;
+ screen.X -= superViewViewportOffset.X;
+ screen.Y -= superViewViewportOffset.Y;
- Point frame = SuperView.ScreenToFrame (x, y);
+ Point frame = SuperView.ScreenToFrame (screen);
frame.X -= Frame.X;
frame.Y -= Frame.Y;
diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs
index ba17287b6..53b299a37 100644
--- a/Terminal.Gui/View/ViewContent.cs
+++ b/Terminal.Gui/View/ViewContent.cs
@@ -211,7 +211,7 @@ public partial class View
public Point ScreenToContent (in Point location)
{
Point viewportOffset = GetViewportOffsetFromFrame ();
- Point screen = ScreenToFrame (location.X, location.Y);
+ Point screen = ScreenToFrame (location);
screen.Offset (Viewport.X - viewportOffset.X, Viewport.Y - viewportOffset.Y);
return screen;
@@ -451,7 +451,7 @@ public partial class View
public Point ScreenToViewport (int x, int y)
{
Point viewportOffset = GetViewportOffsetFromFrame ();
- Point screen = ScreenToFrame (x, y);
+ Point screen = ScreenToFrame (new (x, y));
screen.Offset (-viewportOffset.X, -viewportOffset.Y);
return screen;
diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs
index 8ca8e3ba6..25038453a 100644
--- a/Terminal.Gui/Views/Menu/MenuBar.cs
+++ b/Terminal.Gui/Views/Menu/MenuBar.cs
@@ -1805,7 +1805,7 @@ public class MenuBar : View
if (me.Y > -1)
{
- Point frameLoc = v.ScreenToFrame (me.X, me.Y);
+ Point frameLoc = v.ScreenToFrame (new (me.X, me.Y));
nme = new ()
{
diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs
index c184969e9..4a5df465a 100644
--- a/Terminal.Gui/Views/TileView.cs
+++ b/Terminal.Gui/Views/TileView.cs
@@ -219,7 +219,7 @@ public class TileView : View
bool isRoot = _splitterLines.Contains (line);
Rectangle screen = line.ViewportToScreen (Rectangle.Empty);
- Point origin = ScreenToFrame (screen.X, screen.Y);
+ Point origin = ScreenToFrame (screen.Location);
int length = line.Orientation == Orientation.Horizontal ? line.Frame.Width : line.Frame.Height;
if (!isRoot)
@@ -841,7 +841,7 @@ public class TileView : View
public Point GetLocalCoordinateForTitle (TileView intoCoordinateSpace)
{
Rectangle screen = Tile.ContentView.ViewportToScreen (Rectangle.Empty);
- return intoCoordinateSpace.ScreenToFrame (screen.X, screen.Y - 1);
+ return intoCoordinateSpace.ScreenToFrame (new (screen.X, screen.Y - 1));
}
internal string GetTrimmedTitle ()
diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs
index f5805753a..b23351e9f 100644
--- a/UnitTests/View/Layout/ScreenToTests.cs
+++ b/UnitTests/View/Layout/ScreenToTests.cs
@@ -198,7 +198,7 @@ public class ScreenToTests
BorderStyle = LineStyle.Single
};
- Point actual = view.ScreenToFrame (x, y);
+ Point actual = view.ScreenToFrame (new (x, y));
Assert.Equal (expectedX, actual.X);
Assert.Equal (expectedY, actual.Y);
}
@@ -220,7 +220,7 @@ public class ScreenToTests
{
var view = new View { X = viewX, Y = viewY, Width = 10, Height = 10 };
- Point actual = view.ScreenToFrame (x, y);
+ Point actual = view.ScreenToFrame (new (x, y));
Assert.Equal (expectedX, actual.X);
Assert.Equal (expectedY, actual.Y);
}
@@ -248,7 +248,7 @@ public class ScreenToTests
var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
super.Add (view);
- Point actual = view.ScreenToFrame (x, y);
+ Point actual = view.ScreenToFrame (new (x, y));
Assert.Equal (expectedX, actual.X);
Assert.Equal (expectedY, actual.Y);
}
@@ -269,7 +269,7 @@ public class ScreenToTests
var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
super.Add (view);
- Point actual = view.ScreenToFrame (x, y);
+ Point actual = view.ScreenToFrame (new (x, y));
Assert.Equal (expectedX, actual.X);
Assert.Equal (expectedY, actual.Y);
}
diff --git a/UnitTests/View/NavigationTests.cs b/UnitTests/View/NavigationTests.cs
index d4611eab2..533bc41bd 100644
--- a/UnitTests/View/NavigationTests.cs
+++ b/UnitTests/View/NavigationTests.cs
@@ -851,7 +851,7 @@ public class NavigationTests
);
// top
- Assert.Equal (Point.Empty, top.ScreenToFrame (0, 0));
+ Assert.Equal (Point.Empty, top.ScreenToFrame (new (0, 0)));
Rectangle screen = top.Margin.ViewportToScreen (new (0, 0, 0, 0));
Assert.Equal (0, screen.X);
Assert.Equal (0, screen.Y);
@@ -872,7 +872,7 @@ public class NavigationTests
Assert.Equal (0, found.Frame.X);
Assert.Equal (0, found.Frame.Y);
- Assert.Equal (new Point (3, 2), top.ScreenToFrame (3, 2));
+ Assert.Equal (new Point (3, 2), top.ScreenToFrame (new (3, 2)));
screen = top.ViewportToScreen (new (3, 2, 0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
@@ -884,7 +884,7 @@ public class NavigationTests
Assert.Equal (top, found);
//Assert.Equal (3, found.FrameToScreen ().X);
//Assert.Equal (2, found.FrameToScreen ().Y);
- Assert.Equal (new Point (13, 2), top.ScreenToFrame (13, 2));
+ Assert.Equal (new Point (13, 2), top.ScreenToFrame (new (13, 2)));
screen = top.ViewportToScreen (new (12, 2, 0, 0));
Assert.Equal (13, screen.X);
Assert.Equal (3, screen.Y);
@@ -899,7 +899,7 @@ public class NavigationTests
Assert.Equal (top, found);
//Assert.Equal (13, found.FrameToScreen ().X);
//Assert.Equal (2, found.FrameToScreen ().Y);
- Assert.Equal (new Point (14, 3), top.ScreenToFrame (14, 3));
+ Assert.Equal (new Point (14, 3), top.ScreenToFrame (new (14, 3)));
screen = top.ViewportToScreen (new (14, 3, 0, 0));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
@@ -909,7 +909,7 @@ public class NavigationTests
//Assert.Equal (3, found.FrameToScreen ().Y);
// view
- Assert.Equal (new Point (-4, -3), view.ScreenToFrame (0, 0));
+ Assert.Equal (new Point (-4, -3), view.ScreenToFrame (new (0, 0)));
screen = view.Margin.ViewportToScreen (new (-3, -2, 0, 0));
Assert.Equal (1, screen.X);
Assert.Equal (1, screen.Y);
@@ -928,21 +928,21 @@ public class NavigationTests
found = View.FindDeepestView (top, 0, 0);
Assert.Equal (top.Border, found);
- Assert.Equal (new Point (-1, -1), view.ScreenToFrame (3, 2));
+ Assert.Equal (new Point (-1, -1), view.ScreenToFrame (new (3, 2)));
screen = view.ViewportToScreen (new (0, 0, 0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (top, 4, 3);
Assert.Equal (view, found);
- Assert.Equal (new Point (9, -1), view.ScreenToFrame (13, 2));
+ Assert.Equal (new Point (9, -1), view.ScreenToFrame (new (13, 2)));
screen = view.ViewportToScreen (new (10, 0, 0, 0));
Assert.Equal (14, screen.X);
Assert.Equal (3, screen.Y);
found = View.FindDeepestView (top, 14, 3);
Assert.Equal (top, found);
- Assert.Equal (new Point (10, 0), view.ScreenToFrame (14, 3));
+ Assert.Equal (new Point (10, 0), view.ScreenToFrame (new (14, 3)));
screen = view.ViewportToScreen (new (11, 1, 0, 0));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
@@ -1005,7 +1005,7 @@ public class NavigationTests
Assert.Equal (new Rectangle (3, 2, 23, 10), frame);
// top
- Assert.Equal (new Point (-3, -2), top.ScreenToFrame (0, 0));
+ Assert.Equal (new Point (-3, -2), top.ScreenToFrame (new (0, 0)));
Rectangle screen = top.Margin.ViewportToScreen (new (-3, -2, 0, 0));
Assert.Equal (0, screen.X);
Assert.Equal (0, screen.Y);
@@ -1023,28 +1023,28 @@ public class NavigationTests
Assert.Equal (0, screen.Y);
var found = View.FindDeepestView (top, -4, -3);
Assert.Null (found);
- Assert.Equal (Point.Empty, top.ScreenToFrame (3, 2));
+ Assert.Equal (Point.Empty, top.ScreenToFrame (new (3, 2)));
screen = top.ViewportToScreen (new (0, 0, 0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (top.Border, View.FindDeepestView (top, 3, 2));
//Assert.Equal (0, found.FrameToScreen ().X);
//Assert.Equal (0, found.FrameToScreen ().Y);
- Assert.Equal (new Point (10, 0), top.ScreenToFrame (13, 2));
+ Assert.Equal (new Point (10, 0), top.ScreenToFrame (new (13, 2)));
screen = top.ViewportToScreen (new (10, 0, 0, 0));
Assert.Equal (14, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (top.Border, View.FindDeepestView (top, 13, 2));
//Assert.Equal (10, found.FrameToScreen ().X);
//Assert.Equal (0, found.FrameToScreen ().Y);
- Assert.Equal (new Point (11, 1), top.ScreenToFrame (14, 3));
+ Assert.Equal (new Point (11, 1), top.ScreenToFrame (new (14, 3)));
screen = top.ViewportToScreen (new (11, 1, 0, 0));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
Assert.Equal (top, View.FindDeepestView (top, 14, 3));
// view
- Assert.Equal (new Point (-7, -5), view.ScreenToFrame (0, 0));
+ Assert.Equal (new Point (-7, -5), view.ScreenToFrame (new (0, 0)));
screen = view.Margin.ViewportToScreen (new (-6, -4, 0, 0));
Assert.Equal (1, screen.X);
Assert.Equal (1, screen.Y);
@@ -1058,27 +1058,27 @@ public class NavigationTests
Assert.Equal (1, screen.X);
Assert.Equal (1, screen.Y);
Assert.Null (View.FindDeepestView (top, 1, 1));
- Assert.Equal (new Point (-4, -3), view.ScreenToFrame (3, 2));
+ Assert.Equal (new Point (-4, -3), view.ScreenToFrame (new (3, 2)));
screen = view.ViewportToScreen (new (-3, -2, 0, 0));
Assert.Equal (4, screen.X);
Assert.Equal (3, screen.Y);
Assert.Equal (top, View.FindDeepestView (top, 4, 3));
- Assert.Equal (new Point (-1, -1), view.ScreenToFrame (6, 4));
+ Assert.Equal (new Point (-1, -1), view.ScreenToFrame (new (6, 4)));
screen = view.ViewportToScreen (new (0, 0, 0, 0));
Assert.Equal (7, screen.X);
Assert.Equal (5, screen.Y);
Assert.Equal (view, View.FindDeepestView (top, 7, 5));
- Assert.Equal (new Point (6, -1), view.ScreenToFrame (13, 4));
+ Assert.Equal (new Point (6, -1), view.ScreenToFrame (new (13, 4)));
screen = view.ViewportToScreen (new (7, 0, 0, 0));
Assert.Equal (14, screen.X);
Assert.Equal (5, screen.Y);
Assert.Equal (view, View.FindDeepestView (top, 14, 5));
- Assert.Equal (new Point (7, -2), view.ScreenToFrame (14, 3));
+ Assert.Equal (new Point (7, -2), view.ScreenToFrame (new (14, 3)));
screen = view.ViewportToScreen (new (8, -1, 0, 0));
Assert.Equal (15, screen.X);
Assert.Equal (4, screen.Y);
Assert.Equal (top, View.FindDeepestView (top, 15, 4));
- Assert.Equal (new Point (16, -2), view.ScreenToFrame (23, 3));
+ Assert.Equal (new Point (16, -2), view.ScreenToFrame (new (23, 3)));
screen = view.ViewportToScreen (new (17, -1, 0, 0));
Assert.Equal (24, screen.X);
Assert.Equal (4, screen.Y);