浏览代码

Move the text alignment demo elsewhere, so I can debug other things

miguel 5 年之前
父节点
当前提交
6d08364ad9
共有 2 个文件被更改,包括 17 次插入8 次删除
  1. 16 8
      Example/demo.cs
  2. 1 0
      Terminal.Gui/Core.cs

+ 16 - 8
Example/demo.cs

@@ -82,17 +82,24 @@ static class Demo {
 	}
 
 
-	static void ShowTextAlignments (View container)
+	static void ShowTextAlignments ()
 	{
+		var container = new Dialog (
+			"Text Alignments", 50, 20,
+			new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
+			new Button ("Cancel") { Clicked = () => { Application.RequestStop (); } });
+		
+
 		int i = 0;
 		string txt = "Hello world, how are you doing today";
 		container.Add (
-			new FrameView (new Rect (75, 3, txt.Length + 6, 20), "Text Alignments") {
 				new Label(new Rect(0, 1, 40, 3), $"{i+1}-{txt}") { TextAlignment = TextAlignment.Left },
-				new Label(new Rect(0, 5, 40, 3), $"{i+2}-{txt}") { TextAlignment = TextAlignment.Right },
-				new Label(new Rect(0, 9, 40, 3), $"{i+3}-{txt}") { TextAlignment = TextAlignment.Centered },
-				new Label(new Rect(0, 13, 40, 3), $"{i+4}-{txt}") { TextAlignment = TextAlignment.Justified }
-			});
+				new Label(new Rect(0, 3, 40, 3), $"{i+2}-{txt}") { TextAlignment = TextAlignment.Right },
+				new Label(new Rect(0, 5, 40, 3), $"{i+3}-{txt}") { TextAlignment = TextAlignment.Centered },
+				new Label(new Rect(0, 7, 40, 3), $"{i+4}-{txt}") { TextAlignment = TextAlignment.Justified }
+			);
+
+		Application.Run (container);
 	}
 
 	static void ShowEntries (View container)
@@ -463,6 +470,9 @@ static class Demo {
 				new MenuItem ("Select Multiple Items", "", () => ListSelectionDemo (true)),
 				new MenuItem ("Select Single Item", "", () => ListSelectionDemo (false)),
 			}),
+			new MenuBarItem ("Assorted", new MenuItem [] {
+				new MenuItem ("Show text alignments", "", () => ShowTextAlignments ())
+			}),
 			new MenuBarItem ("Test Menu and SubMenus", new MenuItem [] {
 				new MenuItem ("SubMenu1Item1",
 					new MenuBarItem (new MenuItem[] {
@@ -496,8 +506,6 @@ static class Demo {
 		win.Add (test);
 		win.Add (ml);
 
-		ShowTextAlignments (win);
-
 		var drag = new Label ("Drag: ") { X = 70, Y = 24 };
 		var dragText = new TextField ("") {
 			X = Pos.Right (drag),

+ 1 - 0
Terminal.Gui/Core.cs

@@ -1188,6 +1188,7 @@ namespace Terminal.Gui {
 					h = height.Anchor (hostFrame.Height - _y);
 			}
 			Frame = new Rect (_x, _y, w, h);
+			// layoutNeeded = false;
 		}
 
 		// https://en.wikipedia.org/wiki/Topological_sorting