Prototype/WIP for revamping how cursor handling works.

Views should not have to do complex cursor logic just to position / show a cursor.
Application should take care of more of the heavy liftig.
Advanced cursor handling should be possible.
ProcessCursor is poorly designed and fragile.
This commit is contained in:
Tig
2024-04-26 13:19:11 -06:00
parent eecb7dc7ef
commit e6da3db22d
21 changed files with 440 additions and 506 deletions

View File

@@ -359,97 +359,97 @@ public class ViewportTests (ITestOutputHelper output)
Assert.Equal (view.Viewport.Size, view.ContentSize);
}
[Theory]
[InlineData (0, 0, true)]
[InlineData (-1, 0, true)]
[InlineData (0, -1, true)]
[InlineData (-1, -1, true)]
[InlineData (-2, -2, true)]
[InlineData (-3, -3, true)]
[InlineData (-4, -4, true)]
[InlineData (-5, -4, false)]
[InlineData (-4, -5, false)]
[InlineData (-5, -5, false)]
//[Theory]
//[InlineData (0, 0, true)]
//[InlineData (-1, 0, true)]
//[InlineData (0, -1, true)]
//[InlineData (-1, -1, true)]
//[InlineData (-2, -2, true)]
//[InlineData (-3, -3, true)]
//[InlineData (-4, -4, true)]
//[InlineData (-5, -4, false)]
//[InlineData (-4, -5, false)]
//[InlineData (-5, -5, false)]
[InlineData (1, 1, true)]
[InlineData (2, 2, true)]
[InlineData (3, 3, true)]
[InlineData (4, 4, true)]
[InlineData (5, 4, false)]
[InlineData (4, 5, false)]
[InlineData (5, 5, false)]
public void IsViewVisibleInViewport_No_Driver_No_SuperView (int x, int y, bool expected)
{
var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
Assert.True (view.IsViewLocationVisibleInViewport (x, y) == expected);
}
//[InlineData (1, 1, true)]
//[InlineData (2, 2, true)]
//[InlineData (3, 3, true)]
//[InlineData (4, 4, true)]
//[InlineData (5, 4, false)]
//[InlineData (4, 5, false)]
//[InlineData (5, 5, false)]
//public void IsVisibleInSuperView_No_Driver_No_SuperView (int x, int y, bool expected)
//{
// var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
// Assert.True (view.IsVisibleInSuperView (x, y) == expected);
//}
[Theory]
[InlineData (0, 0, true)]
[InlineData (-1, 0, true)]
[InlineData (0, -1, true)]
[InlineData (-1, -1, true)]
[InlineData (-2, -2, true)]
[InlineData (-3, -3, true)]
[InlineData (-4, -4, true)]
[InlineData (-5, -4, true)]
[InlineData (-4, -5, true)]
[InlineData (-5, -5, true)]
[InlineData (-6, -5, false)]
[InlineData (-5, -6, false)]
[InlineData (-6, -6, false)]
//[Theory]
//[InlineData (0, 0, true)]
//[InlineData (-1, 0, true)]
//[InlineData (0, -1, true)]
//[InlineData (-1, -1, true)]
//[InlineData (-2, -2, true)]
//[InlineData (-3, -3, true)]
//[InlineData (-4, -4, true)]
//[InlineData (-5, -4, true)]
//[InlineData (-4, -5, true)]
//[InlineData (-5, -5, true)]
//[InlineData (-6, -5, false)]
//[InlineData (-5, -6, false)]
//[InlineData (-6, -6, false)]
[InlineData (1, 1, true)]
[InlineData (2, 2, true)]
[InlineData (3, 3, true)]
[InlineData (4, 4, true)]
[InlineData (5, 4, true)]
[InlineData (4, 5, true)]
[InlineData (5, 5, true)]
[InlineData (6, 5, true)]
[InlineData (6, 6, true)]
[InlineData (7, 7, true)]
[InlineData (8, 8, true)]
[InlineData (9, 8, false)]
[InlineData (8, 9, false)]
[InlineData (9, 9, false)]
public void IsViewVisibleInViewport_No_Driver_With_SuperView (int x, int y, bool expected)
{
var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
var top = new Toplevel { Width = 10, Height = 10 };
top.Add (view);
//[InlineData (1, 1, true)]
//[InlineData (2, 2, true)]
//[InlineData (3, 3, true)]
//[InlineData (4, 4, true)]
//[InlineData (5, 4, true)]
//[InlineData (4, 5, true)]
//[InlineData (5, 5, true)]
//[InlineData (6, 5, true)]
//[InlineData (6, 6, true)]
//[InlineData (7, 7, true)]
//[InlineData (8, 8, true)]
//[InlineData (9, 8, false)]
//[InlineData (8, 9, false)]
//[InlineData (9, 9, false)]
//public void IsVisibleInSuperView_No_Driver_With_SuperView (int x, int y, bool expected)
//{
// var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
// var top = new Toplevel { Width = 10, Height = 10 };
// top.Add (view);
Assert.True (view.IsViewLocationVisibleInViewport (x, y) == expected);
}
// Assert.True (view.IsVisibleInSuperView (x, y) == expected);
//}
[SetupFakeDriver]
[Theory]
[InlineData (0, 0, true)]
[InlineData (-1, 0, false)]
[InlineData (0, -1, false)]
[InlineData (-1, -1, false)]
//[SetupFakeDriver]
//[Theory]
//[InlineData (0, 0, true)]
//[InlineData (-1, 0, false)]
//[InlineData (0, -1, false)]
//[InlineData (-1, -1, false)]
[InlineData (1, 0, true)]
[InlineData (0, 1, true)]
[InlineData (1, 1, true)]
[InlineData (2, 2, true)]
[InlineData (3, 3, true)]
[InlineData (4, 4, true)]
[InlineData (5, 4, false)]
[InlineData (4, 5, false)]
[InlineData (5, 5, false)]
public void IsViewVisibleInViewport_With_Driver (int x, int y, bool expected)
{
((FakeDriver)Application.Driver).SetBufferSize (10, 10);
//[InlineData (1, 0, true)]
//[InlineData (0, 1, true)]
//[InlineData (1, 1, true)]
//[InlineData (2, 2, true)]
//[InlineData (3, 3, true)]
//[InlineData (4, 4, true)]
//[InlineData (5, 4, false)]
//[InlineData (4, 5, false)]
//[InlineData (5, 5, false)]
//public void IsVisibleInSuperView_With_Driver (int x, int y, bool expected)
//{
// ((FakeDriver)Application.Driver).SetBufferSize (10, 10);
var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
var top = new Toplevel ();
top.Add (view);
Application.Begin (top);
// var view = new View { X = 1, Y = 1, Width = 5, Height = 5 };
// var top = new Toplevel ();
// top.Add (view);
// Application.Begin (top);
Assert.True (view.IsViewLocationVisibleInViewport (x, y) == expected);
// Assert.True (view.IsVisibleInSuperView (x, y) == expected);
top.Dispose ();
Application.Shutdown ();
}
// top.Dispose ();
// Application.Shutdown ();
//}
}