Procházet zdrojové kódy

Fixes #1011. LayoutNeeded must be a property with a private set, because it's used outside the View class.

BDisp před 4 roky
rodič
revize
71f1b6b002
2 změnil soubory, kde provedl 19 přidání a 11 odebrání
  1. 2 2
      Terminal.Gui/Core/Toplevel.cs
  2. 17 9
      Terminal.Gui/Core/View.cs

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

@@ -427,7 +427,7 @@ namespace Terminal.Gui {
 			Application.CurrentView = this;
 
 			if (IsCurrentTop || this == Application.Top) {
-				if (!NeedDisplay.IsEmpty || layoutNeeded) {
+				if (!NeedDisplay.IsEmpty || LayoutNeeded) {
 					Driver.SetAttribute (Colors.TopLevel.Normal);
 
 					// This is the Application.Top. Clear just the region we're being asked to redraw 
@@ -443,7 +443,7 @@ namespace Terminal.Gui {
 						}
 					}
 
-					layoutNeeded = false;
+					ClearLayoutNeeded ();
 					ClearNeedsDisplay ();
 				}
 			}

+ 17 - 9
Terminal.Gui/Core/View.cs

@@ -684,19 +684,27 @@ namespace Terminal.Gui {
 			SetNeedsDisplay (Bounds);
 		}
 
-		internal bool layoutNeeded = true;
+		internal bool LayoutNeeded { get; private set; } = true;
 
 		internal void SetNeedsLayout ()
 		{
-			if (layoutNeeded)
+			if (LayoutNeeded)
 				return;
-			layoutNeeded = true;
+			LayoutNeeded = true;
 			if (SuperView == null)
 				return;
 			SuperView.SetNeedsLayout ();
 			textFormatter.NeedsFormat = true;
 		}
 
+		/// <summary>
+		/// Removes the <see cref="SetNeedsLayout"/> setting on this view.
+		/// </summary>
+		protected void ClearLayoutNeeded ()
+		{
+			LayoutNeeded = false;
+		}
+
 		/// <summary>
 		/// Flags the view-relative region on this View as needing to be repainted.
 		/// </summary>
@@ -1323,7 +1331,7 @@ namespace Terminal.Gui {
 				foreach (var view in subviews) {
 					if (!view.NeedDisplay.IsEmpty || view.childNeedsDisplay) {
 						if (view.Frame.IntersectsWith (clipRect) && (view.Frame.IntersectsWith (bounds) || bounds.X < 0 || bounds.Y < 0)) {
-							if (view.layoutNeeded)
+							if (view.LayoutNeeded)
 								view.LayoutSubviews ();
 							Application.CurrentView = view;
 
@@ -1829,7 +1837,7 @@ namespace Terminal.Gui {
 		/// </remarks>
 		public virtual void LayoutSubviews ()
 		{
-			if (!layoutNeeded) {
+			if (!LayoutNeeded) {
 				return;
 			}
 
@@ -1865,15 +1873,15 @@ namespace Terminal.Gui {
 				}
 
 				v.LayoutSubviews ();
-				v.layoutNeeded = false;
+				v.LayoutNeeded = false;
 
 			}
 
-			if (SuperView == Application.Top && layoutNeeded && ordered.Count == 0 && LayoutStyle == LayoutStyle.Computed) {
+			if (SuperView == Application.Top && LayoutNeeded && ordered.Count == 0 && LayoutStyle == LayoutStyle.Computed) {
 				SetRelativeLayout (Frame);
 			}
 
-			layoutNeeded = false;
+			LayoutNeeded = false;
 
 			OnLayoutComplete (new LayoutEventArgs () { OldBounds = oldBounds });
 		}
@@ -1908,7 +1916,7 @@ namespace Terminal.Gui {
 
 		/// <summary>
 		/// Used by <see cref="Text"/> to resize the view's <see cref="Bounds"/> with the <see cref="TextFormatter.Size"/>.
-		/// Setting <see cref="Auto"/> to true only work if the <see cref="Width"/> and <see cref="Height"/> are null or
+		/// Setting <see cref="AutoSize"/> to true only work if the <see cref="Width"/> and <see cref="Height"/> are null or
 		///   <see cref="LayoutStyle.Absolute"/> values and doesn't work with <see cref="LayoutStyle.Computed"/> layout,
 		///   to avoid breaking the <see cref="Pos"/> and <see cref="Dim"/> settings.
 		/// </summary>