mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
Simplified ScreenToFrame
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user