浏览代码

Fixed issue with border being drawn with focus color vs just title

Tigger Kindel 2 年之前
父节点
当前提交
f7604ed09a
共有 3 个文件被更改,包括 12 次插入31 次删除
  1. 2 1
      Terminal.Gui/Core/Frame.cs
  2. 9 29
      UICatalog/Scenarios/Generic.cs
  3. 1 1
      UnitTests/Text/TextFormatterTests.cs

+ 2 - 1
Terminal.Gui/Core/Frame.cs

@@ -106,9 +106,10 @@ namespace Terminal.Gui {
 			// TODO: v2 - this will eventually be two controls: "BorderView" and "Label" (for the title)
 			// TODO: v2 - this will eventually be two controls: "BorderView" and "Label" (for the title)
 
 
 			if (Id == "BorderFrame" && Thickness.Top > 0 && !ustring.IsNullOrEmpty (Parent?.Title)) {
 			if (Id == "BorderFrame" && Thickness.Top > 0 && !ustring.IsNullOrEmpty (Parent?.Title)) {
-
+				var prevAttr = Driver.GetAttribute ();
 				Driver.SetAttribute (Parent.HasFocus ? Parent.GetHotNormalColor () : Parent.GetNormalColor ());
 				Driver.SetAttribute (Parent.HasFocus ? Parent.GetHotNormalColor () : Parent.GetNormalColor ());
 				Driver.DrawWindowTitle (screenBounds, Parent?.Title, 0, 0, 0, 0);
 				Driver.DrawWindowTitle (screenBounds, Parent?.Title, 0, 0, 0, 0);
+				Driver.SetAttribute (prevAttr);
 			}
 			}
 
 
 			if (Id == "BorderFrame" && BorderStyle != BorderStyle.None) {
 			if (Id == "BorderFrame" && BorderStyle != BorderStyle.None) {

+ 9 - 29
UICatalog/Scenarios/Generic.cs

@@ -1,7 +1,9 @@
+using NStack;
 using System;
 using System;
 using System.Reflection.Emit;
 using System.Reflection.Emit;
 using Terminal.Gui;
 using Terminal.Gui;
 using Terminal.Gui.Configuration;
 using Terminal.Gui.Configuration;
+using Label = Terminal.Gui.Label;
 
 
 namespace UICatalog.Scenarios {
 namespace UICatalog.Scenarios {
 	[ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
 	[ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
@@ -16,7 +18,8 @@ namespace UICatalog.Scenarios {
 			//  - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
 			//  - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
 			// To override this, implement an override of `Init`.
 			// To override this, implement an override of `Init`.
 			//base.Init ();
 			//base.Init ();
-			// A common, alternate, implementation where `this.Win` is not used:
+			// A common, alternate, implementation where `this.Win` is not used is below. This code
+			// leverages ConfigurationManager to borrow the color scheme settings from UICatalog
 			Application.Init ();
 			Application.Init ();
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Apply ();
 			ConfigurationManager.Apply ();
@@ -30,35 +33,12 @@ namespace UICatalog.Scenarios {
 			// With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
 			// With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
 			// `Scenario.Run` which calls `Application.Run`.
 			// `Scenario.Run` which calls `Application.Run`.
 			// Example:
 			// Example:
-			//var button = new Button ("Press me!") {
-			//	AutoSize = false,
-			//	X = Pos.Center (),
-			//	Y = Pos.Center (),
-			//};
-			//Win.Add (button);
-
-
-			var root = new View () { Width = 20, Height = 10, ColorScheme = Colors.Base };
-
-			//var v = new Terminal.Gui.Label (new string ('c', 100)) {
-			//	Width = Dim.Fill (),
-			//	//Height =1
-			//};
-
-			var v = new TextView () {
-				Height = 1,
-				Text = new string ('c', 100),
-				Width = Dim.Fill ()
+			var button = new Button ("Press me!") {
+				AutoSize = false,
+				X = Pos.Center (),
+				Y = Pos.Center (),
 			};
 			};
-
-			root.Add (v);
-
-			Application.Top.Add (root);
-
-			//Application.Top.CanFocus = true;
-			//v.CanFocus = true;
-			//v.SetFocus ();
-
+			Win.Add (button);
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
UnitTests/Text/TextFormatterTests.cs

@@ -4242,7 +4242,7 @@ This TextFormatter (tf2) is rewritten.
 			};
 			};
 
 
 			TestHelpers.AssertDriverColorsAre (@"
 			TestHelpers.AssertDriverColorsAre (@"
-0222200000
+0022000000
 0000000000
 0000000000
 0111000000
 0111000000
 0000000000", expectedColors);
 0000000000", expectedColors);