2
0
Эх сурвалжийг харах

Improve the UI of the ListView demo, and the demo; And add a crashing scenario that I will fix

miguel 5 жил өмнө
parent
commit
f8548666ee

+ 9 - 11
Example/demo.cs

@@ -365,7 +365,7 @@ static class Demo {
 
 	#region Selection Demo
 
-	static void ListSelectionDemo ()
+	static void ListSelectionDemo (bool multiple)
 	{
 		var d = new Dialog ("Selection Demo", 60, 20,
 			new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
@@ -385,7 +385,7 @@ static class Demo {
 			Width = Dim.Fill () - 4,
 			Height = Dim.Fill () - 4,
 			AllowsMarking = true,
-			AllowsMultipleSelection = false
+			AllowsMultipleSelection = multiple
 		};
 		d.Add (msg, list);
 		Application.Run (d);
@@ -460,7 +460,8 @@ static class Demo {
 				menuItems[3]
 			}),
 			new MenuBarItem ("_List Demos", new MenuItem [] {
-				new MenuItem ("Select Items", "", ListSelectionDemo),
+				new MenuItem ("Select Multiple Items", "", () => ListSelectionDemo (true)),
+				new MenuItem ("Select Single Item", "", () => ListSelectionDemo (false)),
 			}),
 			new MenuBarItem ("Test Menu and SubMenus", new MenuItem [] {
 				new MenuItem ("SubMenu1Item1",
@@ -513,18 +514,15 @@ static class Demo {
 
 		win.Add (drag, dragText);
 #if false
-		var label = new Label ("Fitler") {
-			X = 2
-		};
-		var spacing = 20;
+		// This currently causes a stack overflow, because it is referencing a window that has not had its size allocated yet
 
-		var button = new Button ("apply") {
-			X = Pos.Right (label) + spacing + 2,
-			Y = 0
+		var bottom = new Label ("This should go on the bottom!") {
+			X = Pos.Left (win),
+			Y = Pos.Bottom (win)
 		};
+		win.Add (bottom);
 #endif
 
-
 		top.Add (win);
 		//top.Add (menu);
 		top.Add (menu, statusBar, ml);

+ 2 - 0
Terminal.Gui/Core.cs

@@ -1268,8 +1268,10 @@ namespace Terminal.Gui {
 				if (v.LayoutStyle == LayoutStyle.Computed)
 					v.RelativeLayout (Frame);
 
+				
 				v.LayoutSubviews ();
 				v.layoutNeeded = false;
+
 			}
 			layoutNeeded = false;
 		}

+ 1 - 1
Terminal.Gui/Views/ListView.cs

@@ -277,7 +277,7 @@ namespace Terminal.Gui {
 						Driver.AddRune(' ');
 				} else {
 					if (allowsMarking) {
-						Driver.AddStr (source.IsMarked (item) ? "[x] " : "[ ] ");
+						Driver.AddStr (source.IsMarked (item) ? (AllowsMultipleSelection ? "[x] " : "(o)") : (AllowsMultipleSelection ? "[ ] " : "( )"));
 					}
 					Source.Render(this, Driver, isSelected, item, col, row, f.Width-col);
 				}