2
0
Эх сурвалжийг харах

Reverting the breaking Toplevel Redraw.

BDisp 4 жил өмнө
parent
commit
88c33bb924

+ 31 - 2
Terminal.Gui/Core/Toplevel.cs

@@ -401,10 +401,10 @@ namespace Terminal.Gui {
 		{
 			EnsureVisibleBounds (top, top.Frame.X, top.Frame.Y, out int nx, out int ny);
 			if ((nx != top.Frame.X || ny != top.Frame.Y) && top.LayoutStyle == LayoutStyle.Computed) {
-				if (top.X is Pos.PosAbsolute && top.Bounds.X != nx) {
+				if ((top.X == null || top.X is Pos.PosAbsolute) && top.Bounds.X != nx) {
 					top.X = nx;
 				}
-				if (top.Y is Pos.PosAbsolute && top.Bounds.Y != ny) {
+				if ((top.Y == null || top.Y is Pos.PosAbsolute) && top.Bounds.Y != ny) {
 					top.Y = ny;
 				}
 			}
@@ -421,6 +421,35 @@ namespace Terminal.Gui {
 			}
 		}
 
+		///<inheritdoc/>
+		public override void Redraw (Rect bounds)
+		{
+			Application.CurrentView = this;
+
+			if (IsCurrentTop || this == Application.Top) {
+				if (!NeedDisplay.IsEmpty || LayoutNeeded) {
+					Driver.SetAttribute (Colors.TopLevel.Normal);
+
+					// This is the Application.Top. Clear just the region we're being asked to redraw 
+					// (the bounds passed to us).
+					Clear (bounds);
+					Driver.SetAttribute (Colors.Base.Normal);
+					PositionToplevels ();
+
+					foreach (var view in Subviews) {
+						if (view.Frame.IntersectsWith (bounds)) {
+							view.SetNeedsLayout ();
+							view.SetNeedsDisplay (view.Bounds);
+						}
+					}
+
+					ClearLayoutNeeded ();
+					ClearNeedsDisplay ();
+				}
+			}
+
+			base.Redraw (base.Bounds);
+		}
 
 		/// <summary>
 		/// Invoked by <see cref="Application.Begin"/> as part of the <see cref="Application.Run(Toplevel)"/> after

+ 3 - 22
Terminal.Gui/Core/View.cs

@@ -1310,12 +1310,12 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public virtual void Redraw (Rect bounds)
 		{
-			Application.CurrentView = this;
-
 			if (!CanBeVisible (this)) {
 				return;
 			}
 
+			Application.CurrentView = this;
+
 			var clipRect = new Rect (Point.Empty, frame.Size);
 
 			if (ColorScheme != null) {
@@ -1331,25 +1331,6 @@ namespace Terminal.Gui {
 				textFormatter?.Draw (ViewToScreen (Bounds), HasFocus ? ColorScheme.Focus : ColorScheme.Normal, HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal);
 			}
 
-			if (IsCurrentTop || this == Application.Top) {
-				if (!NeedDisplay.IsEmpty || LayoutNeeded) {
-					Driver.SetAttribute (Colors.TopLevel.Normal);
-
-					// This is the Application.Top. Clear just the region we're being asked to redraw 
-					// (the bounds passed to us).
-					Clear (bounds);
-					Driver.SetAttribute (Colors.Base.Normal);
-					((Toplevel)this).PositionToplevels ();
-
-					foreach (var view in Subviews) {
-						if (view.Frame.IntersectsWith (bounds)) {
-							view.SetNeedsLayout ();
-							view.SetNeedsDisplay (view.Bounds);
-						}
-					}
-				}
-			}
-
 			// Invoke DrawContentEvent
 			OnDrawContent (bounds);
 
@@ -1362,7 +1343,7 @@ namespace Terminal.Gui {
 							Application.CurrentView = view;
 
 							// Draw the subview
-							// Use the view's bounds (view-relative; Location will always be (0,0) because
+							// Use the view's bounds (view-relative; Location will always be (0,0)
 							if (view.Visible) {
 								view.Redraw (view.Bounds);
 							}