Renamed new methods

This commit is contained in:
Thomas
2022-05-13 21:42:50 +01:00
parent e60d7f4363
commit 7f0671e10a
3 changed files with 30 additions and 30 deletions

View File

@@ -622,7 +622,7 @@ namespace Terminal.Gui {
/// </summary>
/// <param name="toFind"></param>
/// <returns></returns>
public int? IndexOf(T toFind)
public int? GetObjectYPosition(T toFind)
{
var idx = BuildLineMap ().IndexOf (o => o.Model.Equals (toFind));
@@ -696,15 +696,15 @@ namespace Terminal.Gui {
/// <summary>
/// Returns the object in the tree list that is currently visible
/// at the provided point. Returns null if no object is at that location.
/// at the provided col/row. Returns null if no object is at that location.
/// <remarks>
/// </remarks>
/// If you have screen cordinates then use <see cref="View.ScreenToView(int, int)"/>
/// If you have screen coordinates then use <see cref="View.ScreenToView(int, int)"/>
/// to translate these into the client area of the <see cref="TreeView{T}"/>.
/// </summary>
/// <param name="point">Point with the <see cref="View.Bounds"/> of the <see cref="TreeView{T}"/></param>
/// <returns></returns>
public T HitTest (Point point)
public T GetObjectAtPoint (Point point)
{
return HitTest (point.Y)?.Model;
}

View File

@@ -100,7 +100,7 @@ namespace UICatalog.Scenarios {
if (selected == null)
return;
var location = treeViewFiles.IndexOf (selected);
var location = treeViewFiles.GetObjectYPosition (selected);
//selected object is offscreen or somehow not found
if (location == null || location < 0 || location > treeViewFiles.Frame.Height)
@@ -118,7 +118,7 @@ namespace UICatalog.Scenarios {
// if user right clicks
if (obj.MouseEvent.Flags.HasFlag(MouseFlags.Button3Clicked)) {
var rightClicked = treeViewFiles.HitTest (new Point (obj.MouseEvent.X, obj.MouseEvent.Y));
var rightClicked = treeViewFiles.GetObjectAtPoint (new Point (obj.MouseEvent.X, obj.MouseEvent.Y));
// nothing was clicked
if (rightClicked == null)

View File

@@ -721,7 +721,7 @@ namespace Terminal.Gui.Views {
}
[Fact, AutoInitShutdown]
public void TestTreeHitTest ()
public void TestGetObjectAtPoint ()
{
var tv = new TreeView { Width = 20, Height = 10 };
@@ -746,11 +746,11 @@ namespace Terminal.Gui.Views {
└─pink
", output);
Assert.Same (n1, tv.HitTest (new Point (0, 0)));
Assert.Same (n1_1, tv.HitTest (new Point (0, 1)));
Assert.Same (n1_2, tv.HitTest (new Point (0, 2)));
Assert.Same (n2, tv.HitTest (new Point (0, 3)));
Assert.Null (tv.HitTest (new Point (0, 4)));
Assert.Same (n1, tv.GetObjectAtPoint (new Point (0, 0)));
Assert.Same (n1_1, tv.GetObjectAtPoint (new Point (0, 1)));
Assert.Same (n1_2, tv.GetObjectAtPoint (new Point (0, 2)));
Assert.Same (n2, tv.GetObjectAtPoint (new Point (0, 3)));
Assert.Null (tv.GetObjectAtPoint (new Point (0, 4)));
tv.Collapse (n1);
@@ -762,15 +762,15 @@ namespace Terminal.Gui.Views {
└─pink
", output);
Assert.Same (n1, tv.HitTest (new Point (0, 0)));
Assert.Same (n2, tv.HitTest (new Point (0, 1)));
Assert.Null (tv.HitTest (new Point (0, 2)));
Assert.Null (tv.HitTest (new Point (0, 3)));
Assert.Null (tv.HitTest (new Point (0, 4)));
Assert.Same (n1, tv.GetObjectAtPoint (new Point (0, 0)));
Assert.Same (n2, tv.GetObjectAtPoint (new Point (0, 1)));
Assert.Null (tv.GetObjectAtPoint (new Point (0, 2)));
Assert.Null (tv.GetObjectAtPoint (new Point (0, 3)));
Assert.Null (tv.GetObjectAtPoint (new Point (0, 4)));
}
[Fact, AutoInitShutdown]
public void TestTreeIndexOf ()
public void TestGetObjectYPosition ()
{
var tv = new TreeView { Width = 20, Height = 10 };
@@ -795,10 +795,10 @@ namespace Terminal.Gui.Views {
└─pink
", output);
Assert.Equal (0, tv.IndexOf (n1));
Assert.Equal (1, tv.IndexOf (n1_1));
Assert.Equal (2, tv.IndexOf (n1_2));
Assert.Equal (3, tv.IndexOf (n2));
Assert.Equal (0, tv.GetObjectYPosition (n1));
Assert.Equal (1, tv.GetObjectYPosition (n1_1));
Assert.Equal (2, tv.GetObjectYPosition (n1_2));
Assert.Equal (3, tv.GetObjectYPosition (n2));
tv.Collapse (n1);
@@ -809,10 +809,10 @@ namespace Terminal.Gui.Views {
@"├+normal
└─pink
", output);
Assert.Equal (0, tv.IndexOf (n1));
Assert.Null (tv.IndexOf (n1_1));
Assert.Null (tv.IndexOf (n1_2));
Assert.Equal (1, tv.IndexOf (n2));
Assert.Equal (0, tv.GetObjectYPosition (n1));
Assert.Null (tv.GetObjectYPosition (n1_1));
Assert.Null (tv.GetObjectYPosition (n1_2));
Assert.Equal (1, tv.GetObjectYPosition (n2));
// scroll down 1
@@ -824,10 +824,10 @@ namespace Terminal.Gui.Views {
GraphViewTests.AssertDriverContentsAre (
@"└─pink
", output);
Assert.Equal (-1, tv.IndexOf (n1));
Assert.Null (tv.IndexOf (n1_1));
Assert.Null (tv.IndexOf (n1_2));
Assert.Equal (0, tv.IndexOf (n2));
Assert.Equal (-1, tv.GetObjectYPosition (n1));
Assert.Null (tv.GetObjectYPosition (n1_1));
Assert.Null (tv.GetObjectYPosition (n1_2));
Assert.Equal (0, tv.GetObjectYPosition (n2));
}
[Fact, AutoInitShutdown]
public void TestTreeViewColor()