Browse Source

Smarter focuscolor fix just for Border

Tig 1 year ago
parent
commit
c34b23762b
2 changed files with 10 additions and 8 deletions
  1. 9 2
      Terminal.Gui/View/Adornment/Border.cs
  2. 1 6
      Terminal.Gui/View/ViewDrawing.cs

+ 9 - 2
Terminal.Gui/View/Adornment/Border.cs

@@ -432,10 +432,17 @@ public class Border : Adornment
 
         if (canDrawBorder && Thickness.Top > 0 && maxTitleWidth > 0 && !string.IsNullOrEmpty (Parent?.Title))
         {
+            var focus = Parent.GetNormalColor();
+            if (Parent.SuperView is { } && Parent.SuperView?.Subviews!.Count (s => s.CanFocus) > 1)
+            {
+                // Only use focus color if there are multiple focusable views
+                focus = Parent.GetFocusColor() ;
+            }
+
             Parent.TitleTextFormatter.Draw (
                                             new (borderBounds.X + 2, titleY, maxTitleWidth, 1),
-                                            Parent.HasFocus ? Parent.GetFocusColor () : Parent.GetNormalColor (),
-                                            Parent.HasFocus ? Parent.GetFocusColor () : Parent.GetHotNormalColor ());
+                                            Parent.HasFocus ? focus : Parent.GetNormalColor (),
+                                            Parent.HasFocus ? focus : Parent.GetHotNormalColor ());
         }
 
         if (canDrawBorder && LineStyle != LineStyle.None)

+ 1 - 6
Terminal.Gui/View/ViewDrawing.cs

@@ -334,12 +334,7 @@ public partial class View
             cs = new ();
         }
 
-        if (SuperView is {} && SuperView?.Subviews!.Count(s => s.CanFocus) > 1)
-        {
-            return Enabled ? cs.Focus : cs.Disabled;
-        }
-
-        return Enabled ? cs.Normal : cs.Disabled;
+        return Enabled ? cs.Focus : cs.Disabled;
     }
 
     /// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>