Simplified ScreenToFrame

This commit is contained in:
Tig
2024-03-11 12:09:25 -08:00
parent 11c1be60b9
commit ebb33bf9fc
2 changed files with 12 additions and 7 deletions

View File

@@ -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);

View File

@@ -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
/// <returns>A thickness that describes the sum of the Adornments' thicknesses.</returns>
public Thickness GetAdornmentsThickness () { return Margin.Thickness + Border.Thickness + Padding.Thickness; }
/// <summary>Overriden by <see cref="Adornment"/> to do nothing, as the <see cref="Adornment"/> does not have adornments.</summary>
/// <summary>Lays out the Adornments of the View.</summary>
/// <remarks>
/// Overriden by <see cref="Adornment"/> to do nothing, as <see cref="Adornment"/> does not have adornments.
/// </remarks>
internal virtual void LayoutAdornments ()
{
if (Margin is null)