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

Demo proving Title rendering is easy

Tig Kindel 2 жил өмнө
parent
commit
f26c556544

+ 20 - 54
Terminal.Gui/Views/FrameView.cs

@@ -241,8 +241,6 @@ namespace Terminal.Gui {
 					Driver.DrawWindowTitle (scrRect, Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
 				Driver.SetAttribute (GetNormalColor ());
 			} else {
-				Driver.SetAttribute (ColorScheme.Normal);
-
 				var lc = new LineCanvas ();
 
 				if (Border?.BorderStyle != BorderStyle.None) {
@@ -255,66 +253,34 @@ namespace Terminal.Gui {
 				}
 
 				foreach (var subview in contentView.Subviews) {
-					lc.AddLine (new Point (subview.Frame.X+1, subview.Frame.Y+1), subview.Frame.Width - 1, Orientation.Horizontal, subview.Border.BorderStyle);
-					lc.AddLine (new Point (subview.Frame.X+1, subview.Frame.Y+1), subview.Frame.Height - 1, Orientation.Vertical, subview.Border.BorderStyle);
-
-					lc.AddLine (new Point (subview.Frame.Width - 1, subview.Frame.Y + subview.Frame.Height), -subview.Frame.Width + 1, Orientation.Horizontal, subview.Border.BorderStyle);
-					lc.AddLine (new Point (subview.Frame.X + subview.Frame.Width, subview.Frame.Height - 1), -subview.Frame.Height + 1, Orientation.Vertical, subview.Border.BorderStyle);
-				}
-
-				//TODO: Figure out how to draw Titles
-				
-				// TODO: Figure out how to add splitters
+					lc.AddLine (new Point (subview.Frame.X + 1, subview.Frame.Y + 1), subview.Frame.Width - 1, Orientation.Horizontal, subview.Border.BorderStyle);
+					lc.AddLine (new Point (subview.Frame.X + 1, subview.Frame.Y + 1), subview.Frame.Height - 1, Orientation.Vertical, subview.Border.BorderStyle);
 
-				//foreach (var line in allLines) {
-				//	bool isRoot = splitterLines.Contains (line);
-
-				//	line.ViewToScreen (0, 0, out var x1, out var y1);
-				//	var origin = ScreenToView (x1, y1);
-				//	var length = line.Orientation == Orientation.Horizontal ?
-				//			line.Frame.Width - 1 :
-				//			line.Frame.Height - 1;
-
-				//	if (!isRoot) {
-				//		if (line.Orientation == Orientation.Horizontal) {
-				//			origin.X -= 1;
-				//		} else {
-				//			origin.Y -= 1;
-				//		}
-				//		length += 2;
-				//	}
-
-				//	lc.AddLine (origin, length, line.Orientation, Border.BorderStyle);
-				//}
+					lc.AddLine (new Point (subview.Frame.X + subview.Frame.Width, subview.Frame.Y + subview.Frame.Height), -subview.Frame.Width + 1, Orientation.Horizontal, subview.Border.BorderStyle);
+					lc.AddLine (new Point (subview.Frame.X + subview.Frame.Width, subview.Frame.Y + subview.Frame.Height), -subview.Frame.Height + 1, Orientation.Vertical, subview.Border.BorderStyle);
 
+				}
 
 				Driver.SetAttribute (ColorScheme.Normal);
 				lc.Draw (this, bounds);
 
-				//// Redraw the lines so that focus/drag symbol renders
-				//foreach (var line in allLines) {
-				//	line.DrawSplitterSymbol ();
-				//}
 
-				// Draw Titles over Border
-
-				//foreach (var titleToRender in allTitlesToRender) {
-				//	var renderAt = titleToRender.GetLocalCoordinateForTitle (this);
-
-				//	if (renderAt.Y < 0) {
-				//		// If we have no border then root level tiles
-				//		// have nowhere to render their titles.
-				//		continue;
-				//	}
-
-				//	// TODO: Render with focus color if focused
-
-				//	var title = titleToRender.GetTrimmedTitle ();
+				// Redraw the lines so that focus/drag symbol renders
+				foreach (var subview in contentView.Subviews) {
+					//	line.DrawSplitterSymbol ();
+				}
 
-				//	for (int i = 0; i < title.Length; i++) {
-				//		AddRune (renderAt.X + i, renderAt.Y, title [i]);
-				//	}
-				//}
+				// Draw Titles over Border
+				foreach (var subview in contentView.Subviews) {
+					// TODO: Use reflection to see if subview has a Title property
+					if (subview is FrameView viewWithTite) {
+						var rect = viewWithTite.Frame;
+						rect.X = rect.X + 1;
+						rect.Y = rect.Y + 2;
+						// TODO: Do focus color correctly
+						Driver.DrawWindowTitle (rect, viewWithTite.Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
+					}
+				}
 			}
 		}
 

+ 9 - 7
UICatalog/Scenarios/TileViewExperiment.cs

@@ -51,13 +51,15 @@ namespace UICatalog.Scenarios {
 
 			frame.Add (view1);
 
+			//var view12splitter = new SplitterEventArgs
+
 			var view2 = new FrameView () {
 				Title = "View 2",
-				Text = "View2 right of view1, 30%/Fill Single.",
+				Text = "View2 right of view1, 30%/70% Single.",
 				X = Pos.Right (view1) - 1,
 				Y = -1,
 				Width = Dim.Percent (30),
-				Height = Dim.Fill (-1),
+				Height = Dim.Percent (70),
 				ColorScheme = Colors.ColorSchemes ["Error"],
 				Border = new Border () { BorderStyle = BorderStyle.Single }
 			};
@@ -79,10 +81,10 @@ namespace UICatalog.Scenarios {
 
 			var view4 = new FrameView () {
 				Title = "View 4",
-				Text = "View4 below View1 30%/5 Single",
-				X = -1,
-				Y = Pos.Bottom (view1)-1,
-				Width = Dim.Percent (30),
+				Text = "View4 below View2 view2.Width/5 Single",
+				X = Pos.Left (view2),
+				Y = Pos.Bottom (view2) - 1,
+				Width = view2.Width,
 				Height = 5,
 				ColorScheme = Colors.ColorSchemes ["TopLevel"],
 				Border = new Border () { BorderStyle = BorderStyle.Single }
@@ -93,7 +95,7 @@ namespace UICatalog.Scenarios {
 			var view5 = new FrameView () {
 				Title = "View 5",
 				Text = "View5 below View4 view4.Width/5 Double",
-				X = -1,
+				X = Pos.Left (view2),
 				Y = Pos.Bottom (view4) - 1,
 				Width = view4.Width,
 				Height = 5,