From da55844277bcb7f209f536443f162351b3b2fba7 Mon Sep 17 00:00:00 2001 From: Tig Date: Tue, 9 Apr 2024 23:34:15 -0400 Subject: [PATCH] Rewrote ScreenToFrame to be clearer and more performant --- Terminal.Gui/View/Layout/ViewLayout.cs | 28 +++++--------------------- Terminal.sln.DotSettings | 5 +++++ 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index d288247c2..0090b353d 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -120,39 +120,21 @@ public partial class View /// The coordinate relative to the 's . /// Screen-relative column. /// Screen-relative row. - //public virtual Point ScreenToFrame (int x, int y) - //{ - // Point superViewViewportOffset = SuperView?.GetViewportOffsetFromFrame () ?? Point.Empty; - - // if (SuperView is null) - // { - // superViewViewportOffset.Offset (x - Frame.X, y - Frame.Y); - - // return superViewViewportOffset; - // } - // superViewViewportOffset.Offset (-SuperView.Viewport.X, -SuperView.Viewport.Y); - // Point frame = SuperView.ScreenToFrame (x - superViewViewportOffset.X, y - superViewViewportOffset.Y); - // frame.Offset (-Frame.X, -Frame.Y); - - // return frame; - //} - - public virtual Point ScreenToFrame (/*Point point*/int x, int y) + public virtual Point ScreenToFrame (int x, int y) { - Point point = new (x, y); if (SuperView is null) { - return new Point (point.X - Frame.X, point.Y - Frame.Y); + return new Point (x - Frame.X, y - Frame.Y); } Point superViewViewportOffset = SuperView.GetViewportOffsetFromFrame (); superViewViewportOffset.X -= SuperView.Viewport.X; superViewViewportOffset.Y -= SuperView.Viewport.Y; - point.X -= superViewViewportOffset.X; - point.Y -= superViewViewportOffset.Y; + x -= superViewViewportOffset.X; + y -= superViewViewportOffset.Y; - Point frame = SuperView.ScreenToFrame (point); + Point frame = SuperView.ScreenToFrame (x, y); frame.X -= Frame.X; frame.Y -= Frame.Y; diff --git a/Terminal.sln.DotSettings b/Terminal.sln.DotSettings index d04aeb7c3..3bc1fab5d 100644 --- a/Terminal.sln.DotSettings +++ b/Terminal.sln.DotSettings @@ -386,10 +386,15 @@ <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> True True True True + True True #FFCF9D32 True