Browse Source

Removed flickering by minimizing layout/display

Tig 1 year ago
parent
commit
7c8b1990e6
2 changed files with 12 additions and 9 deletions
  1. 8 7
      Terminal.Gui/View/Layout/ViewLayout.cs
  2. 4 2
      Terminal.Gui/Views/TileView.cs

+ 8 - 7
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -66,7 +66,7 @@ public partial class View
         {
             if (_frame == value)
             {
-                //return;
+                return;
             }
 
             _frame = value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) };
@@ -165,12 +165,13 @@ public partial class View
         get => VerifyIsInitialized (_x, nameof (X));
         set
         {
-            _x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null");
-
             if (Equals (_x, value))
             {
-                //return;
+                return;
             }
+
+            _x = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (X)} cannot be null");
+
             OnResizeNeeded ();
         }
     }
@@ -205,7 +206,7 @@ public partial class View
         {
             if (Equals (_y, value))
             {
-                //return;
+                return;
             }
 
             _y = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Y)} cannot be null");
@@ -243,7 +244,7 @@ public partial class View
         {
             if (Equals (_height, value))
             {
-                //return;
+                return;
             }
 
             _height = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Height)} cannot be null");
@@ -298,7 +299,7 @@ public partial class View
         {
             if (Equals (_width, value))
             {
-               // return;
+                return;
             }
 
             _width = value ?? throw new ArgumentNullException (nameof (value), @$"{nameof (Width)} cannot be null");

+ 4 - 2
Terminal.Gui/Views/TileView.cs

@@ -183,7 +183,7 @@ public class TileView : View
     {
         Driver.SetAttribute (ColorScheme.Normal);
 
-        ClearVisibleContent();
+        ClearVisibleContent ();
 
         base.OnDrawContent (viewport);
 
@@ -816,6 +816,8 @@ public class TileView : View
                 tile.ContentView.Width = viewport.Width;
                 tile.ContentView.Height = GetTileWidthOrHeight (i, Viewport.Height, visibleTiles, visibleSplitterLines);
             }
+            //  BUGBUG: This should not be needed. If any of the pos/dim setters above actually changed values, NeedsDisplay should have already been set. 
+            tile.ContentView.SetNeedsDisplay ();
         }
     }
 
@@ -900,7 +902,7 @@ public class TileView : View
             }
         }
 
-        protected internal override bool OnMouseEvent  (MouseEvent mouseEvent)
+        protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
         {
             if (!dragPosition.HasValue && mouseEvent.Flags == MouseFlags.Button1Pressed)
             {