Переглянути джерело

More Prototype scrollbuttons in Padding for CharMap

Tig 1 рік тому
батько
коміт
f65c49a858

+ 9 - 2
Terminal.Gui/View/ViewDrawing.cs

@@ -524,12 +524,12 @@ public partial class View
             _needsDisplayRect = new (x, y, w, h);
         }
 
-        SuperView?.SetSubViewNeedsDisplay ();
-
         Margin?.SetNeedsDisplay ();
         Border?.SetNeedsDisplay ();
         Padding?.SetNeedsDisplay ();
 
+        SuperView?.SetSubViewNeedsDisplay ();
+
         foreach (View subview in Subviews)
         {
             if (subview.Frame.IntersectsWith (region))
@@ -550,6 +550,13 @@ public partial class View
         if (SuperView is { SubViewNeedsDisplay: false })
         {
             SuperView.SetSubViewNeedsDisplay ();
+
+            return;
+        }
+
+        if (this is Adornment adornment)
+        {
+            adornment.Parent?.SetSubViewNeedsDisplay ();
         }
     }
 

+ 13 - 14
Terminal.Gui/Views/Button.cs

@@ -62,7 +62,8 @@ public class Button : View
         //MouseClick += Button_MouseClick;
     }
 
-    private Attribute _originalNormal;
+    [CanBeNull]
+    private ColorScheme _savedColorScheme;
 
     private void Button_MouseEvent (object sender, MouseEventEventArgs e)
     {
@@ -71,31 +72,29 @@ public class Button : View
             if (Application.MouseGrabView == this)
             {
                 e.Handled = InvokeCommand (Command.HotKey) == true;
-
                 return;
             }
+
+            SetFocus();
             Application.GrabMouse(this);
 
-            _originalNormal = ColorScheme.Normal;
-            var cs = new ColorScheme (ColorScheme)
-            {
-                Normal = ColorScheme.HotFocus
-            };
+            _savedColorScheme = ColorScheme;
+            var cs = new ColorScheme (new Attribute (ColorScheme.Normal.Background, ColorScheme.Normal.Foreground));
             ColorScheme = cs;
         }
 
-        if (e.MouseEvent.Flags == MouseFlags.Button1Released)
+        if (e.MouseEvent.Flags.HasFlag(MouseFlags.Button1Released))
         {
             Application.UngrabMouse ();
-            var cs = new ColorScheme (ColorScheme)
-            {
-                Normal = _originalNormal
-            };
-            ColorScheme = cs;
 
             e.Handled = InvokeCommand (Command.HotKey) == true;
 
-            return;
+            if (_savedColorScheme is { })
+            {
+                ColorScheme = _savedColorScheme;
+            }
+
+            _savedColorScheme = null;
         }
     }
 

+ 1 - 1
UICatalog/Scenarios/Buttons.cs

@@ -301,7 +301,7 @@ public class Buttons : Scenario
             Width = 1,
             NoPadding = true,
             NoDecorations = true,
-            Title = CM.Glyphs.UpArrow.ToString(),
+            Title = $"{CM.Glyphs.UpArrow}",
         };
         Win.Add (label, oneByOne);