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

@@ -1002,7 +1002,7 @@ public class TreeView<T> : View, ITreeView where T : class
public bool IsSelected (T model) { return Equals (SelectedObject, model) || (MultiSelect && multiSelectedRegions.Any (s => s.Contains (model))); }
///<inheritdoc/>
protected internal override bool OnMouseEvent (MouseEvent me)
protected internal override bool OnMouseEvent (MouseEvent me)
{
// If it is not an event we care about
if (!me.Flags.HasFlag (MouseFlags.Button1Clicked)
@@ -1239,7 +1239,7 @@ public class TreeView<T> : View, ITreeView where T : class
}
/// <summary>Positions the cursor at the start of the selected objects line (if visible).</summary>
public override void PositionCursor ()
public override Point? PositionCursor ()
{
if (CanFocus && HasFocus && Visible && SelectedObject is { })
{
@@ -1250,16 +1250,10 @@ public class TreeView<T> : View, ITreeView where T : class
if (idx - ScrollOffsetVertical >= 0 && idx - ScrollOffsetVertical < Viewport.Height)
{
Move (0, idx - ScrollOffsetVertical);
}
else
{
base.PositionCursor ();
return new Point (0, idx - ScrollOffsetVertical);
}
}
else
{
base.PositionCursor ();
}
return base.PositionCursor ();
}
/// <summary>