Merge branch 'develop' into wsl-clipboard-unit-tests-fix

This commit is contained in:
BDisp
2022-10-20 18:47:04 +01:00
committed by GitHub
3 changed files with 326 additions and 299 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,6 @@
using System;
using System.Linq;
using System.Reflection;
namespace Terminal.Gui {
/// <summary>
@@ -217,7 +216,7 @@ namespace Terminal.Gui {
/// <param name="view">The view to add to the scrollview.</param>
public override void Add (View view)
{
if (!IsOverridden (view)) {
if (!IsOverridden (view, "MouseEvent")) {
view.MouseEnter += View_MouseEnter;
view.MouseLeave += View_MouseLeave;
}
@@ -237,14 +236,6 @@ namespace Terminal.Gui {
Application.GrabMouse (this);
}
bool IsOverridden (View view)
{
Type t = view.GetType ();
MethodInfo m = t.GetMethod ("MouseEvent");
return (m.DeclaringType == t || m.ReflectedType == t) && m.GetBaseDefinition ().DeclaringType == typeof (Responder);
}
/// <summary>
/// Gets or sets the visibility for the horizontal scroll indicator.
/// </summary>
@@ -515,7 +506,7 @@ namespace Terminal.Gui {
vertical.MouseEvent (me);
} else if (me.Y == horizontal.Frame.Y && ShowHorizontalScrollIndicator) {
horizontal.MouseEvent (me);
} else if (IsOverridden (me.View)) {
} else if (IsOverridden (me.View, "MouseEvent")) {
Application.UngrabMouse ();
}
return true;

View File

@@ -2123,6 +2123,28 @@ Y
Assert.Equal (new Rect (0, 0, 8, 4), pos);
}
[Fact, AutoInitShutdown]
public void DrawFrame_With_Minimum_Size ()
{
var view = new View (new Rect (0, 0, 2, 2));
view.DrawContent += (_) => view.DrawFrame (view.Bounds, 0, true);
Assert.Equal (Point.Empty, new Point (view.Frame.X, view.Frame.Y));
Assert.Equal (new Size (2, 2), new Size (view.Frame.Width, view.Frame.Height));
Application.Top.Add (view);
Application.Begin (Application.Top);
var expected = @"
┌┐
└┘
";
var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 2, 2), pos);
}
[Fact, AutoInitShutdown]
public void DrawFrame_With_Negative_Positions ()
{
@@ -2452,7 +2474,7 @@ Y
Width = Dim.Fill (),
Height = Dim.Fill ()
};
view.LayoutComplete += e => {
view.DrawContent += e => {
view.DrawFrame (view.Bounds);
var savedClip = Application.Driver.Clip;
Application.Driver.Clip = new Rect (1, 1, view.Bounds.Width - 2, view.Bounds.Height - 2);
@@ -2500,7 +2522,7 @@ Y
Width = Dim.Fill (),
Height = Dim.Fill ()
};
view.LayoutComplete += e => {
view.DrawContent += e => {
view.DrawFrame (view.Bounds);
var savedClip = Application.Driver.Clip;
Application.Driver.Clip = new Rect (1, 1, view.Bounds.Width - 2, view.Bounds.Height - 2);