Browse Source

ListView support both LayoutStyle to calculate th height.

BDisp 5 years ago
parent
commit
e3f02a9d79
1 changed files with 10 additions and 2 deletions
  1. 10 2
      Terminal.Gui/Views/ListView.cs

+ 10 - 2
Terminal.Gui/Views/ListView.cs

@@ -199,6 +199,8 @@ namespace Terminal.Gui {
 			}
 		}
 
+		bool topPending;
+
 		/// <summary>
 		/// Gets or sets the index of the currently selected item.
 		/// </summary>
@@ -214,8 +216,8 @@ namespace Terminal.Gui {
 				OnSelectedChanged ();
 				if (selected < top)
 					top = selected;
-				else if (selected >= top + (LayoutStyle == LayoutStyle.Absolute ? Frame.Height : Height.Anchor (0)))
-					top = selected;
+				else
+					topPending = true;
 			}
 		}
 
@@ -280,6 +282,12 @@ namespace Terminal.Gui {
 			Driver.SetAttribute (current);
 			Move (0, 0);
 			var f = Frame;
+			if (topPending) {
+				topPending = false;
+				if (selected >= top + f.Height) {
+					top = selected;
+				}
+			}
 			var item = top;
 			bool focused = HasFocus;
 			int col = allowsMarking ? 4 : 0;