Browse Source

Added Applicaton.ClearScreenNextIteration

Tig 8 tháng trước cách đây
mục cha
commit
d39a940955

+ 5 - 0
Terminal.Gui/Application/Application.Run.cs

@@ -505,6 +505,11 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     {
         bool neededLayout = View.Layout (TopLevels.Reverse (), Screen.Size);
 
+        if (ClearScreenNextIteration)
+        {
+            forceDraw = true;
+            ClearScreenNextIteration = false;
+        }
         if (forceDraw)
         {
             Driver?.ClearContents ();

+ 9 - 0
Terminal.Gui/Application/Application.Screen.cs

@@ -67,4 +67,13 @@ public static partial class Application // Screen related stuff
 
         return true;
     }
+
+    /// <summary>
+    ///     Gets or sets whether the screen will be cleared, and all Views redrawn, during the next Application iteration.
+    /// </summary>
+    /// <remarks>
+    ///     This is typicall set to true when a View's <see cref="View.Frame"/> changes and that view has no
+    ///     SuperView (e.g. when <see cref="Application.Top"/> is moved or resized.
+    /// </remarks>
+    public static bool ClearScreenNextIteratio { get; set; }
 }

+ 2 - 0
Terminal.Gui/Application/Application.cs

@@ -215,6 +215,8 @@ public static partial class Application
 
         Navigation = null;
 
+        ClearScreenNextIteration = false;
+
         AddApplicationKeyBindings ();
 
         // Reset synchronization context to allow the user to run async/await,

+ 8 - 1
Terminal.Gui/View/View.Layout.cs

@@ -557,7 +557,14 @@ public partial class View // Layout APIs
                 SetTitleTextFormatterSize ();
             }
 
-            SuperView?.SetNeedsDraw ();
+            if (SuperView is { })
+            {
+                SuperView?.SetNeedsDraw ();
+            }
+            else
+            {
+              //  Application.ClearScreenNextIteration = true;
+            }
         }
 
         if (TextFormatter.ConstrainToWidth is null)