From 1d44f2e046556fd8149bc6ea5e9e52534389ff06 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 20 Jan 2024 16:19:13 +0000 Subject: [PATCH] Fixes #2571. Wizards background shifts to gray when focusing, looks bad. (#3194) * Fixes #2571. Wizards background shifts to gray when focusing, looks bad. * Update nuget packages. * Trying to fix the CodeQL failing. --- Terminal.Gui/Core/View.cs | 7 +++++-- UnitTests/UnitTests.csproj | 4 ++-- UnitTests/Views/ViewTests.cs | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 0d4a39818..174abd94b 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -1500,8 +1500,11 @@ namespace Terminal.Gui { (GetType ().IsNestedPublic && !IsOverridden (this, "Redraw") || GetType ().Name == "View") && (!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) { - Clear (); - SetChildNeedsDisplay (); + if (ColorScheme != null) { + Driver.SetAttribute (GetNormalColor ()); + Clear (); + SetChildNeedsDisplay (); + } } if (!ustring.IsNullOrEmpty (TextFormatter.Text)) { diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 2816d89f2..76d83ea4b 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -21,8 +21,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitTests/Views/ViewTests.cs b/UnitTests/Views/ViewTests.cs index 2c4cc9840..2f161d906 100644 --- a/UnitTests/Views/ViewTests.cs +++ b/UnitTests/Views/ViewTests.cs @@ -4563,5 +4563,23 @@ Label", output); TestHelpers.AssertDriverContentsAre (@" Label", output); } + + [Fact, AutoInitShutdown] + public void View_Instance_Use_Attribute_Normal_On_Draw () + { + var view = new View { Id = "view", X = 1, Y = 1, Width = 4, Height = 1, Text = "Test", CanFocus = true }; + var root = new View { Id = "root", Width = Dim.Fill (), Height = Dim.Fill () }; + root.Add (view); + Application.Top.Add (root); + Application.Begin (Application.Top); + + TestHelpers.AssertDriverContentsAre (@" +Test", output); + + TestHelpers.AssertDriverColorsAre (@" +000000 +011110 +000000", new Attribute [] { Colors.TopLevel.Normal, Colors.TopLevel.Focus }); + } } }