WIP (broken) - support adornmnts

This commit is contained in:
Tig Kindel
2024-02-27 08:21:01 -07:00
parent cecfb71ee1
commit 3bc2909d73
2 changed files with 53 additions and 4 deletions

View File

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

View File

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