Przeglądaj źródła

Better looking invert color logic

Tig 1 rok temu
rodzic
commit
45309c7564
2 zmienionych plików z 22 dodań i 6 usunięć
  1. 18 2
      Terminal.Gui/View/ViewMouse.cs
  2. 4 4
      UICatalog/Scenarios/Buttons.cs

+ 18 - 2
Terminal.Gui/View/ViewMouse.cs

@@ -149,8 +149,24 @@ public partial class View
             {
                 Application.GrabMouse (this);
                 _savedColorScheme = ColorScheme;
-                var cs = new ColorScheme (new Attribute (ColorScheme.Normal.Background, ColorScheme.Normal.Foreground));
-                ColorScheme = cs;
+
+                if (CanFocus)
+                {
+                    // TODO: Make the inverted color configurable
+                    var cs = new ColorScheme (ColorScheme)
+                    {
+                        Focus = new Attribute (ColorScheme.Normal.Foreground, ColorScheme.Focus.Background)
+                    };
+                    ColorScheme = cs;
+                }
+                else
+                {
+                    var cs = new ColorScheme (ColorScheme)
+                    {
+                        Normal = new Attribute (ColorScheme.Focus.Background, ColorScheme.Normal.Foreground)
+                    };
+                    ColorScheme = cs;
+                }
 
                 // Set the focus, but don't invoke Accept
                 SetFocus ();

+ 4 - 4
UICatalog/Scenarios/Buttons.cs

@@ -396,12 +396,12 @@ public class Buttons : Scenario
         {
             X = Pos.Right (label) + 1,
             Y = Pos.Top (label),
-            Title = $"Accept Count: {noRepeatAcceptCount}",
+            Title = $"Accept Cou_nt: {noRepeatAcceptCount}",
             WantContinuousButtonPressed = false,
         };
         noRepeatButton.Accept += (s, e) =>
                                  {
-                                     noRepeatButton.Title = $"Accept Count: {++noRepeatAcceptCount}";
+                                     noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
                                  };
         main.Add(label, noRepeatButton);
 
@@ -416,12 +416,12 @@ public class Buttons : Scenario
         {
             X = Pos.Right (label) + 1,
             Y = Pos.Top (label),
-            Title = $"Accept Count: {acceptCount}",
+            Title = $"Accept Co_unt: {acceptCount}",
             WantContinuousButtonPressed = true,
         };
         repeatButton.Accept += (s, e) =>
                                {
-                                   repeatButton.Title = $"Accept Count: {++acceptCount}";
+                                   repeatButton.Title = $"Accept Co_unt: {++acceptCount}";
                                };
 
         var enableCB = new CheckBox ()