Bladeren bron

More progress

Tigger Kindel 2 jaren geleden
bovenliggende
commit
54fc9fce61

+ 37 - 12
Terminal.Gui/Core/Frame.cs

@@ -18,7 +18,7 @@ namespace Terminal.Gui {
 	public class Frame : View {
 		private Thickness _thickness;
 
-		internal override void CreateFrames (){ /* Do nothing - Frames do not have Frames */ }
+		internal override void CreateFrames () { /* Do nothing - Frames do not have Frames */ }
 
 		/// <summary>
 		/// The Parent of this Frame (the View this Frame surrounds).
@@ -91,6 +91,8 @@ namespace Terminal.Gui {
 
 			if (ColorScheme != null) {
 				Driver.SetAttribute (ColorScheme.Normal);
+			} else {
+				Driver.SetAttribute (Parent.GetNormalColor ());
 			}
 
 			var prevClip = SetClip (Frame);
@@ -100,22 +102,45 @@ namespace Terminal.Gui {
 
 			//OnDrawSubviews (bounds); 
 
-			if (BorderStyle != BorderStyle.None) {
+			// TODO: v2 - this will eventually be two controls: "BorderView" and "Label" (for the title)
+			if (Id == "BorderFrame" && BorderStyle != BorderStyle.None) {
 				var lc = new LineCanvas ();
-				lc.AddLine (screenBounds.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
-				lc.AddLine (screenBounds.Location, Frame.Height - 1, Orientation.Vertical, BorderStyle);
-
-				lc.AddLine (new Point (screenBounds.X, screenBounds.Y + screenBounds.Height - 1), screenBounds.Width - 1, Orientation.Horizontal, BorderStyle);
-				lc.AddLine (new Point (screenBounds.X + screenBounds.Width - 1, screenBounds.Y), screenBounds.Height - 1, Orientation.Vertical, BorderStyle);
+				if (Thickness.Top > 0) {
+					if (ustring.IsNullOrEmpty (Parent?.Title)) {
+						lc.AddLine (screenBounds.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+					} else {
+
+						lc.AddLine (screenBounds.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+
+						//// ╔╡ Title ╞═════╗
+						//// Add a short horiz line for ╔╡
+						//lc.AddLine (screenBounds.Location, 1, Orientation.Horizontal, BorderStyle);
+						//// Add a short vert line for ╔╡
+						//lc.AddLine (new Point (screenBounds.X + 1, screenBounds.Location.Y - 1), 1, Orientation.Vertical, BorderStyle.Single);
+						//// Add a short vert line for ╞
+						//lc.AddLine (new Point (screenBounds.X + (Parent.Title.Length + 3), screenBounds.Location.Y - 1), 1, Orientation.Vertical, BorderStyle.Single);
+						//// Add the right hand line for ╞═════╗
+						//lc.AddLine (new Point (screenBounds.X + (Parent.Title.Length + 3), screenBounds.Location.Y), Frame.Width - 1 - (Parent.Title.Length + 2), Orientation.Horizontal, BorderStyle);
+					}
+				}
+				if (Thickness.Left > 0) {
+					lc.AddLine (screenBounds.Location, Frame.Height - 1, Orientation.Vertical, BorderStyle);
+				}
+				if (Thickness.Bottom > 0) {
+					lc.AddLine (new Point (screenBounds.X, screenBounds.Y + screenBounds.Height - 1), screenBounds.Width - 1, Orientation.Horizontal, BorderStyle);
+				}
+				if (Thickness.Right > 0) {
+					lc.AddLine (new Point (screenBounds.X + screenBounds.Width - 1, screenBounds.Y), screenBounds.Height - 1, Orientation.Vertical, BorderStyle);
+				}
 				foreach (var p in lc.GenerateImage (screenBounds)) {
 					Driver.Move (p.Key.X, p.Key.Y);
 					Driver.AddRune (p.Value);
 				}
+			}
+			if (Id == "BorderFrame" && Thickness.Top > 0 && !ustring.IsNullOrEmpty (Parent?.Title)) {
 
-				if (!ustring.IsNullOrEmpty (Parent?.Title)) {
-					Driver.SetAttribute (Parent.HasFocus ? Parent.GetHotNormalColor () : Parent.GetNormalColor ());
-					Driver.DrawWindowTitle (screenBounds, Parent?.Title, 0, 0, 0, 0);
-				}
+				Driver.SetAttribute (Parent.HasFocus ? Parent.GetHotNormalColor () : Parent.GetNormalColor ());
+				Driver.DrawWindowTitle (screenBounds, Parent?.Title, 0, 0, 0, 0);
 			}
 
 			Driver.Clip = prevClip;
@@ -138,7 +163,7 @@ namespace Terminal.Gui {
 				if (prev != _thickness) {
 					OnThicknessChanged ();
 				}
-				
+
 			}
 		}
 

+ 5 - 4
Terminal.Gui/Core/View.cs

@@ -530,7 +530,6 @@ namespace Terminal.Gui {
 			Margin = new Frame () { Id = "Margin", Thickness = new Thickness (0) };
 			Margin.ThicknessChanged += ThicknessChangedHandler;
 			Margin.Parent = this;
-			//Margin.DiagnosticsLabel.Text = "Margin";
 
 			if (BorderFrame != null) {
 				BorderFrame.ThicknessChanged -= ThicknessChangedHandler;
@@ -540,6 +539,7 @@ namespace Terminal.Gui {
 			BorderFrame = new Frame () { Id = "BorderFrame", Thickness = new Thickness (0), BorderStyle = BorderStyle.Single };
 			BorderFrame.ThicknessChanged += ThicknessChangedHandler;
 			BorderFrame.Parent = this;
+
 			// TODO: Create View.AddAdornment
 
 			if (Padding != null) {
@@ -552,8 +552,8 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		/// Lays out the views <see cref="Frame"/>s objects (<see cref="Margin"/>, <see cref="BorderFrame"/>, and <see cref="Padding"/> 
-		/// as needed. Causes each Frame to Layout it's subviews.
+		/// Lays out the view's <see cref="Frame"/> objects (<see cref="Margin"/>, <see cref="BorderFrame"/>, and <see cref="Padding"/> 
+		/// as needed. Causes each Frame to Layout its SubViews.
 		/// </summary>
 		public void LayoutFrames ()
 		{
@@ -593,7 +593,8 @@ namespace Terminal.Gui {
 		ustring title;
 
 		/// <summary>
-		/// The title to be displayed for this <see cref="View"/>.
+		/// The title to be displayed for this <see cref="View"/>. The title will be displayed if <see cref="BorderFrame"/>.<see cref="Thickness.Top"/>
+		/// is greater than 0.
 		/// </summary>
 		/// <value>The title.</value>
 		public ustring Title {

+ 1 - 1
Terminal.Gui/Core/Window.cs

@@ -116,7 +116,7 @@ namespace Terminal.Gui {
 			}
 			BorderFrame.Thickness = new Thickness (1);
 			BorderFrame.BorderStyle = Border.BorderStyle;
-			BorderFrame.ColorScheme = ColorScheme;
+			//BorderFrame.ColorScheme = ColorScheme;
 			BorderFrame.Data = "BorderFrame";
 
 			// TODO: Hack until Border is refactored

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

@@ -75,7 +75,7 @@ namespace Terminal.Gui {
 		public FrameView () : this (title: string.Empty) {
 			BorderFrame.Thickness = new Thickness (1);
 			BorderFrame.BorderStyle = Border.BorderStyle;
-			BorderFrame.ColorScheme = ColorScheme;
+			//BorderFrame.ColorScheme = ColorScheme;
 			BorderFrame.Data = "BorderFrame";
 		}
 

+ 5 - 5
UICatalog/Scenarios/Frames.cs

@@ -74,7 +74,7 @@ namespace UICatalog.Scenarios {
 				Add (leftEdit);
 
 				var rightEdit = new TextField ("") {
-					X = Pos.Right (topEdit) + 1,
+					X = Pos.Right (topEdit),
 					Y = Pos.Bottom (topEdit),
 					Width = 5
 				};
@@ -183,10 +183,10 @@ namespace UICatalog.Scenarios {
 				};
 				Add (rbBorderStyle);
 
-				//rbBorderStyle.SelectedItemChanged += (e) => {
-				//	viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
-				//	viewToEdit.SetNeedsDisplay ();
-				//};
+				rbBorderStyle.SelectedItemChanged += (e) => {
+					viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
+					viewToEdit.SetNeedsDisplay ();
+				};
 
 				//Add (new Label ("Background:") {
 				//	Y = 5

+ 27 - 15
UICatalog/Scenarios/ViewExperiments.cs

@@ -23,7 +23,7 @@ namespace UICatalog.Scenarios {
 
 			public ThicknessEditor ()
 			{
-				Margin.Thickness = new Thickness (1);
+				Margin.Thickness = new Thickness (0);
 				BorderFrame.Thickness = new Thickness (1);
 			}
 
@@ -71,7 +71,7 @@ namespace UICatalog.Scenarios {
 				Add (leftEdit);
 
 				var rightEdit = new TextField ("") {
-					X = Pos.Right (topEdit) + 1,
+					X = Pos.Right (topEdit),
 					Y = Pos.Bottom (topEdit),
 					Width = 5
 				};
@@ -132,11 +132,12 @@ namespace UICatalog.Scenarios {
 			{
 				viewToEdit.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 				var marginEditor = new ThicknessEditor () {
-					X = 20,
+					X = 0,
 					Y = 0,
 					Title = "Margin",
 					Thickness = viewToEdit.Margin.Thickness,
 				};
+				marginEditor.Margin.Thickness = new Thickness (0, 0, 1, 0);
 				marginEditor.ThicknessChanged += (s, a) => {
 					viewToEdit.Margin.Thickness = a.Thickness;
 				};
@@ -149,14 +150,35 @@ namespace UICatalog.Scenarios {
 					Title = "Border",
 					Thickness = viewToEdit.BorderFrame.Thickness,
 				};
+				borderEditor.Margin.Thickness = new Thickness (0, 0, 1, 0);
 				borderEditor.ThicknessChanged += (s, a) => {
 					viewToEdit.BorderFrame.Thickness = a.Thickness;
 				};
 				Add (borderEditor);
 
+				var styleLabel = new Label ("BorderStyle: ") {
+					X = Pos.Right (borderEditor),
+					Y = 0
+				};
+				Add (styleLabel);
+
+				var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
+				var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
+					e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
+					X = Pos.Left (styleLabel),
+					Y = Pos.Bottom (styleLabel),
+					SelectedItem = (int)viewToEdit.BorderFrame.BorderStyle
+				};
+
+				rbBorderStyle.SelectedItemChanged += (e) => {
+					viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
+					viewToEdit.SetNeedsDisplay ();
+				};
+				Add (rbBorderStyle);
+
 				viewToEdit.Padding.ColorScheme = Colors.ColorSchemes ["Error"];
 				var paddingEditor = new ThicknessEditor () {
-					X = Pos.Right (borderEditor),
+					X = Pos.Right (styleLabel),
 					Y = 0,
 					Title = "Padding",
 					Thickness = viewToEdit.Padding.Thickness,
@@ -168,17 +190,7 @@ namespace UICatalog.Scenarios {
 
 				viewToEdit.Y = Pos.Center () + 4;
 
-				Add (new Label ("BorderStyle:"));
-
-				var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
-				var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
-					e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
 
-					X = 2,
-					Y = 1,
-					SelectedItem = (int)viewToEdit.BorderFrame.BorderStyle
-				};
-				Add (rbBorderStyle);
 
 				//rbBorderStyle.SelectedItemChanged += (e) => {
 				//	viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
@@ -223,7 +235,7 @@ namespace UICatalog.Scenarios {
 				//};
 				//Add (rbBorderBrush);
 
-				Height = 9; 
+				Height = 8; 
 				Title = title;
 			}
 		}