diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 6354cba9c..68f1ce6bc 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -120,15 +120,15 @@ public partial class View public virtual Point ScreenToFrame (int x, int y) { Point superViewBoundsOffset = SuperView?.GetBoundsOffset () ?? Point.Empty; - var ret = new Point (x - Frame.X - superViewBoundsOffset.X, y - Frame.Y - superViewBoundsOffset.Y); - - if (SuperView is { }) + if (SuperView is null) { - Point superFrame = SuperView.ScreenToFrame (x - superViewBoundsOffset.X, y - superViewBoundsOffset.Y); - ret = new (superFrame.X - Frame.X, superFrame.Y - Frame.Y); + superViewBoundsOffset.Offset (x - Frame.X, y - Frame.Y); + return superViewBoundsOffset; } - return ret; + var frame = SuperView.ScreenToFrame (x - superViewBoundsOffset.X, y - superViewBoundsOffset.Y); + frame.Offset (-Frame.X, -Frame.Y); + return frame; } private Pos _x = Pos.At (0); diff --git a/Terminal.Gui/View/ViewAdornments.cs b/Terminal.Gui/View/ViewAdornments.cs index d31f08175..5cf036439 100644 --- a/Terminal.Gui/View/ViewAdornments.cs +++ b/Terminal.Gui/View/ViewAdornments.cs @@ -1,4 +1,5 @@ namespace Terminal.Gui; + public partial class View { private void CreateAdornments () @@ -25,6 +26,7 @@ public partial class View Border?.EndInit (); Padding?.EndInit (); } + private void DisposeAdornments () { Margin?.Dispose (); @@ -133,7 +135,10 @@ public partial class View /// A thickness that describes the sum of the Adornments' thicknesses. public Thickness GetAdornmentsThickness () { return Margin.Thickness + Border.Thickness + Padding.Thickness; } - /// Overriden by to do nothing, as the does not have adornments. + /// Lays out the Adornments of the View. + /// + /// Overriden by to do nothing, as does not have adornments. + /// internal virtual void LayoutAdornments () { if (Margin is null)