mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
WIP (broken) - support adornmnts
This commit is contained in:
@@ -570,6 +570,23 @@ public partial class View
|
||||
return null;
|
||||
}
|
||||
|
||||
if (findAdornments)
|
||||
{
|
||||
if (start.Margin.Thickness.Contains (start.Frame, x, y))
|
||||
{
|
||||
return start.Margin;
|
||||
}
|
||||
if (start.Border.Thickness.Contains (start.Frame, x, y))
|
||||
{
|
||||
return start.Border;
|
||||
}
|
||||
if (start.Padding.Thickness.Contains (start.Frame, x, y))
|
||||
{
|
||||
return start.Padding;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (start.InternalSubviews is { Count: > 0 })
|
||||
{
|
||||
Point boundsOffset = start.GetBoundsOffset ();
|
||||
@@ -582,7 +599,7 @@ public partial class View
|
||||
|
||||
if (v.Visible && v.Frame.Contains (rx, ry))
|
||||
{
|
||||
View? deep = FindDeepestView (v, rx, ry);
|
||||
View? deep = FindDeepestView (v, rx, ry, findAdornments);
|
||||
return deep ?? v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +143,7 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
||||
|
||||
Assert.Equal (expectedSubViewFound, found == subview);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Test that FindDeepestView works if the start view has positive Adornments
|
||||
[Theory]
|
||||
[InlineData (0, 0, false)]
|
||||
@@ -173,11 +172,44 @@ public class FindDeepestViewTests (ITestOutputHelper output)
|
||||
};
|
||||
start.Add (subview);
|
||||
|
||||
var found = View.FindDeepestView (start, testX, testY);
|
||||
var found = View.FindDeepestView (start, testX, testY, true);
|
||||
|
||||
Assert.Equal (expectedSubViewFound, found == subview);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0, 0, typeof(Margin))]
|
||||
[InlineData (9, 9, typeof (Margin))]
|
||||
|
||||
[InlineData (1, 1, typeof (Border))]
|
||||
[InlineData (8, 8, typeof (Border))]
|
||||
|
||||
[InlineData (1, 1, typeof (Padding))]
|
||||
[InlineData (7, 7, typeof (Padding))]
|
||||
|
||||
[InlineData (5, 5, typeof (View))]
|
||||
public void Returns_Adornment_If_Start_Has_Adornments (int testX, int testY, Type expectedAdornmentType)
|
||||
{
|
||||
var start = new View ()
|
||||
{
|
||||
Width = 10, Height = 10,
|
||||
};
|
||||
start.Margin.Thickness = new Thickness (1);
|
||||
start.Border.Thickness = new Thickness (1);
|
||||
start.Padding.Thickness = new Thickness (1);
|
||||
|
||||
var subview = new View ()
|
||||
{
|
||||
X = 1, Y = 1,
|
||||
Width = 1, Height = 1,
|
||||
};
|
||||
start.Add (subview);
|
||||
|
||||
var found = View.FindDeepestView (start, testX, testY, true);
|
||||
Assert.Equal(expectedAdornmentType, found.GetType());
|
||||
|
||||
}
|
||||
|
||||
// Test that FindDeepestView works if the subview has positive Adornments
|
||||
[Theory]
|
||||
[InlineData (0, 0, false)]
|
||||
|
||||
Reference in New Issue
Block a user