Tig Kindel 2 gadi atpakaļ
vecāks
revīzija
8bd9ac7bce

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

@@ -1216,7 +1216,7 @@ namespace Terminal.Gui {
 					MdiTop?.OnDeactivate (state.Toplevel);
 					MdiTop?.OnDeactivate (state.Toplevel);
 					state.Toplevel = Current;
 					state.Toplevel = Current;
 					MdiTop?.OnActivate (state.Toplevel);
 					MdiTop?.OnActivate (state.Toplevel);
-					Top.SetChildNeedsDisplay ();
+					Top.SetSubViewNeedsDisplay ();
 					Refresh ();
 					Refresh ();
 				}
 				}
 				if (Driver.EnsureCursorVisibility ()) {
 				if (Driver.EnsureCursorVisibility ()) {
@@ -1280,7 +1280,7 @@ namespace Terminal.Gui {
 
 
 			foreach (var top in toplevels) {
 			foreach (var top in toplevels) {
 				if (top != Current && top.Visible && (!top.NeedDisplay.IsEmpty || top.ChildNeedsDisplay || top.LayoutNeeded)) {
 				if (top != Current && top.Visible && (!top.NeedDisplay.IsEmpty || top.ChildNeedsDisplay || top.LayoutNeeded)) {
-					MdiTop.SetChildNeedsDisplay ();
+					MdiTop.SetSubViewNeedsDisplay ();
 					return true;
 					return true;
 				}
 				}
 			}
 			}

+ 11 - 5
Terminal.Gui/Core/Toplevel.cs

@@ -134,7 +134,7 @@ namespace Terminal.Gui {
 		internal virtual void OnChildClosed (Toplevel top)
 		internal virtual void OnChildClosed (Toplevel top)
 		{
 		{
 			if (IsMdiContainer) {
 			if (IsMdiContainer) {
-				SetChildNeedsDisplay ();
+				SetSubViewNeedsDisplay ();
 			}
 			}
 			ChildClosed?.Invoke (top);
 			ChildClosed?.Invoke (top);
 		}
 		}
@@ -208,6 +208,10 @@ namespace Terminal.Gui {
 		{
 		{
 			ColorScheme = Colors.TopLevel;
 			ColorScheme = Colors.TopLevel;
 
 
+			// TODO: v2 - ALL Views (Responders??!?!) should support the commands related to 
+			//    - Focus
+			//  Move the appropriate AddCommand calls to `Responder`
+
 			// Things this view knows how to do
 			// Things this view knows how to do
 			AddCommand (Command.QuitToplevel, () => { QuitToplevel (); return true; });
 			AddCommand (Command.QuitToplevel, () => { QuitToplevel (); return true; });
 			AddCommand (Command.Suspend, () => { Driver.Suspend (); ; return true; });
 			AddCommand (Command.Suspend, () => { Driver.Suspend (); ; return true; });
@@ -357,7 +361,7 @@ namespace Terminal.Gui {
 
 
 		/// <summary>
 		/// <summary>
 		/// <see langword="true"/> if was already loaded by the <see cref="Application.Begin(Toplevel)"/>
 		/// <see langword="true"/> if was already loaded by the <see cref="Application.Begin(Toplevel)"/>
-		/// <see langword="false"/>, otherwise. This is used to avoid the <see cref="View.NeedDisplay"/>
+		/// <see langword="false"/>, otherwise. This is used to avoid the <see cref="View._needsDisplay"/>
 		/// having wrong values while this was not yet loaded.
 		/// having wrong values while this was not yet loaded.
 		/// </summary>
 		/// </summary>
 		public bool IsLoaded { get; private set; }
 		public bool IsLoaded { get; private set; }
@@ -595,7 +599,7 @@ namespace Terminal.Gui {
 		}
 		}
 
 
 		internal View EnsureVisibleBounds (Toplevel top, int x, int y,
 		internal View EnsureVisibleBounds (Toplevel top, int x, int y,
-			out int nx, out int ny, out View mb, out View sb)
+			out int nx, out int ny, out MenuBar mb, out StatusBar sb)
 		{
 		{
 			int l;
 			int l;
 			View superView;
 			View superView;
@@ -668,13 +672,14 @@ namespace Terminal.Gui {
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
+		/// Adjusts the location and size of <paramref name="top"/> within this Toplevel.
 		/// Virtual method enabling implementation of specific positions for inherited <see cref="Toplevel"/> views.
 		/// Virtual method enabling implementation of specific positions for inherited <see cref="Toplevel"/> views.
 		/// </summary>
 		/// </summary>
-		/// <param name="top">The toplevel.</param>
+		/// <param name="top">The Toplevel to adjust.</param>
 		public virtual void PositionToplevel (Toplevel top)
 		public virtual void PositionToplevel (Toplevel top)
 		{
 		{
 			var superView = EnsureVisibleBounds (top, top.Frame.X, top.Frame.Y,
 			var superView = EnsureVisibleBounds (top, top.Frame.X, top.Frame.Y,
-				out int nx, out int ny, out _, out View sb);
+				out int nx, out int ny, out _, out StatusBar sb);
 			bool layoutSubviews = false;
 			bool layoutSubviews = false;
 			if ((top?.SuperView != null || (top != Application.Top && top.Modal)
 			if ((top?.SuperView != null || (top != Application.Top && top.Modal)
 				|| (top?.SuperView == null && top.IsMdiChild))
 				|| (top?.SuperView == null && top.IsMdiChild))
@@ -690,6 +695,7 @@ namespace Terminal.Gui {
 				}
 				}
 			}
 			}
 
 
+			// TODO: v2 - This is a hack to get the StatusBar to be positioned correctly.
 			if (sb != null && ny + top.Frame.Height != superView.Frame.Height - (sb.Visible ? 1 : 0)
 			if (sb != null && ny + top.Frame.Height != superView.Frame.Height - (sb.Visible ? 1 : 0)
 				&& top.Height is Dim.DimFill && -top.Height.Anchor (0) < 1) {
 				&& top.Height is Dim.DimFill && -top.Height.Anchor (0) < 1) {
 
 

+ 5 - 5
Terminal.Gui/Core/View.cs

@@ -918,7 +918,7 @@ namespace Terminal.Gui {
 				var h = Math.Max (NeedDisplay.Height, region.Height);
 				var h = Math.Max (NeedDisplay.Height, region.Height);
 				NeedDisplay = new Rect (x, y, w, h);
 				NeedDisplay = new Rect (x, y, w, h);
 			}
 			}
-			container?.SetChildNeedsDisplay ();
+			container?.SetSubViewNeedsDisplay ();
 
 
 			if (subviews == null)
 			if (subviews == null)
 				return;
 				return;
@@ -937,11 +937,11 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// <summary>
 		/// Indicates that any child views (in the <see cref="Subviews"/> list) need to be repainted.
 		/// Indicates that any child views (in the <see cref="Subviews"/> list) need to be repainted.
 		/// </summary>
 		/// </summary>
-		public void SetChildNeedsDisplay ()
+		public void SetSubViewNeedsDisplay ()
 		{
 		{
 			ChildNeedsDisplay = true;
 			ChildNeedsDisplay = true;
 			if (container != null)
 			if (container != null)
-				container.SetChildNeedsDisplay ();
+				container.SetSubViewNeedsDisplay ();
 		}
 		}
 
 
 		internal bool addingView;
 		internal bool addingView;
@@ -1547,14 +1547,14 @@ namespace Terminal.Gui {
 				(!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) {
 				(!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) {
 
 
 				Clear ();
 				Clear ();
-				SetChildNeedsDisplay ();
+				SetSubViewNeedsDisplay ();
 			}
 			}
 
 
 			if (!ustring.IsNullOrEmpty (TextFormatter.Text)) {
 			if (!ustring.IsNullOrEmpty (TextFormatter.Text)) {
 				Rect containerBounds = GetContainerBounds ();
 				Rect containerBounds = GetContainerBounds ();
 				if (!containerBounds.IsEmpty) {
 				if (!containerBounds.IsEmpty) {
 					Clear (GetNeedDisplay (containerBounds));
 					Clear (GetNeedDisplay (containerBounds));
-					SetChildNeedsDisplay ();
+					SetSubViewNeedsDisplay ();
 					// Draw any Text
 					// Draw any Text
 					if (TextFormatter != null) {
 					if (TextFormatter != null) {
 						TextFormatter.NeedsFormat = true;
 						TextFormatter.NeedsFormat = true;

+ 1 - 1
Terminal.Gui/Types/Rect.cs

@@ -130,7 +130,7 @@ namespace Terminal.Gui
 		///
 		///
 		/// <remarks>
 		/// <remarks>
 		///	Produces a new Rectangle by intersecting 2 existing 
 		///	Produces a new Rectangle by intersecting 2 existing 
-		///	Rectangles. Returns null if there is no	intersection.
+		///	Rectangles. Returns Empty if there is no intersection.
 		/// </remarks>
 		/// </remarks>
 
 
 		public static Rect Intersect (Rect a, Rect b)
 		public static Rect Intersect (Rect a, Rect b)

+ 1 - 15
Terminal.Gui/Views/FrameView.cs

@@ -1,16 +1,4 @@
-//
-// Authors:
-//   Miguel de Icaza ([email protected])
-//
-// NOTE: FrameView is functionally identical to Window with the following exceptions. 
-//  - Is not a Toplevel
-//  - Does not support mouse dragging
-//  - Does not support padding (but should)
-//  - Does not support IEnumerable
-// Any udpates done here should probably be done in Window as well; TODO: Merge these classes
-
-using System;
-using System.Linq;
+using System.Linq;
 using System.Text.Json.Serialization;
 using System.Text.Json.Serialization;
 using NStack;
 using NStack;
 using Terminal.Gui.Graphs;
 using Terminal.Gui.Graphs;
@@ -127,8 +115,6 @@ namespace Terminal.Gui {
 		/// <param name="border">The <see cref="Border"/>.</param>
 		/// <param name="border">The <see cref="Border"/>.</param>
 		public FrameView (Rect frame, ustring title = null, View [] views = null, Border border = null) : base (frame)
 		public FrameView (Rect frame, ustring title = null, View [] views = null, Border border = null) : base (frame)
 		{
 		{
-			//var cFrame = new Rect (1, 1, Math.Max (frame.Width - 2, 0), Math.Max (frame.Height - 2, 0));
-
 			Initialize (frame, title, views, border);
 			Initialize (frame, title, views, border);
 		}
 		}
 
 

+ 2 - 2
UICatalog/UICatalog.cs

@@ -304,7 +304,7 @@ namespace UICatalog {
 						StatusBar.Visible = !StatusBar.Visible;
 						StatusBar.Visible = !StatusBar.Visible;
 						ContentPane.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
 						ContentPane.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
 						LayoutSubviews();
 						LayoutSubviews();
-						SetChildNeedsDisplay();
+						SetSubViewNeedsDisplay();
 					}),
 					}),
 					DriverName,
 					DriverName,
 					OS
 					OS
@@ -393,7 +393,7 @@ namespace UICatalog {
 					var height = (StatusBar.Visible ? 1 : 0);// + (MenuBar.Visible ? 1 : 0);
 					var height = (StatusBar.Visible ? 1 : 0);// + (MenuBar.Visible ? 1 : 0);
 					ContentPane.Height = Dim.Fill (height);
 					ContentPane.Height = Dim.Fill (height);
 					LayoutSubviews ();
 					LayoutSubviews ();
-					SetChildNeedsDisplay ();
+					SetSubViewNeedsDisplay ();
 				};
 				};
 
 
 				Loaded -= LoadedHandler;
 				Loaded -= LoadedHandler;

+ 1 - 1
UnitTests/TopLevels/ToplevelTests.cs

@@ -201,7 +201,7 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.Equal (top, Application.Top);
 			Assert.Equal (top, Application.Top);
 
 
 			// top is Application.Top without menu and status bar.
 			// top is Application.Top without menu and status bar.
-			var supView = top.EnsureVisibleBounds (top, 2, 2, out int nx, out int ny, out View mb, out View sb);
+			var supView = top.EnsureVisibleBounds (top, 2, 2, out int nx, out int ny, out MenuBar mb, out StatusBar sb);
 			Assert.Equal (Application.Top, supView);
 			Assert.Equal (Application.Top, supView);
 			Assert.Equal (0, nx);
 			Assert.Equal (0, nx);
 			Assert.Equal (0, ny);
 			Assert.Equal (0, ny);