Procházet zdrojové kódy

Fixed Window tests; fixed XML doc errors

Tigger Kindel před 2 roky
rodič
revize
43d5efcd6c

+ 18 - 0
Terminal.Gui/Core/Border.cs

@@ -85,11 +85,29 @@ namespace Terminal.Gui {
 		}
 
 		// TODO: These are all temporary to keep code compiling
+		/// <summary>
+		/// 
+		/// </summary>
 		public bool DrawMarginFrame { get; set; }
+		/// <summary>
+		/// 
+		/// </summary>
 		public Point Effect3DOffset { get; set; } = new Point (1, 1);
+		/// <summary>
+		/// 
+		/// </summary>
 		public bool Effect3D { get; set; }
+		/// <summary>
+		/// 
+		/// </summary>
 		public Thickness BorderThickness { get; set; } = new Thickness (0);
+		/// <summary>
+		/// 
+		/// </summary>
 		public object Effect3DBrush { get; set; }
+		/// <summary>
+		/// 
+		/// </summary>
 		public Thickness PaddingThickness { get; set; } = new Thickness (0);
 
 		/// <summary>

+ 0 - 1
Terminal.Gui/Core/Thickness.cs

@@ -52,7 +52,6 @@ namespace Terminal.Gui {
 		/// </summary>
 		[JsonInclude]
 		public int Bottom;
-		private Rect inside;
 
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Thickness"/> class with all widths

+ 1 - 1
Terminal.Gui/Core/ThicknessEventArgs.cs

@@ -4,7 +4,7 @@
 
 namespace Terminal.Gui {
 	/// <summary>
-	/// Event arguments for the <see cref="ConfigurationManager"/> events.
+	/// Event arguments for the <see cref="Thickness"/> events.
 	/// </summary>
 	public class ThicknessEventArgs : EventArgs {
 

+ 3 - 14
Terminal.Gui/Core/TitleEventArgs.cs

@@ -1,15 +1,4 @@
-//
-// Authors:
-//   Miguel de Icaza ([email protected])
-//
-// NOTE: Window is functionally identical to FrameView with the following exceptions. 
-//  - Window is a Toplevel
-//  - FrameView Does not support padding (but should)
-//  - FrameView Does not support mouse dragging
-//  - FrameView Does not support IEnumerable
-// Any updates done here should probably be done in FrameView as well; TODO: Merge these classes
-
-using System;
+using System;
 using NStack;
 
 namespace Terminal.Gui {
@@ -35,8 +24,8 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Initializes a new instance of <see cref="TitleEventArgs"/>
 		/// </summary>
-		/// <param name="oldTitle">The <see cref="Window.Title"/> that is/has been replaced.</param>
-		/// <param name="newTitle">The new <see cref="Window.Title"/> to be replaced.</param>
+		/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
+		/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
 		public TitleEventArgs (ustring oldTitle, ustring newTitle)
 		{
 			OldTitle = oldTitle;

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

@@ -623,8 +623,8 @@ namespace Terminal.Gui {
 		/// <param name="y">The target y location.</param>
 		/// <param name="nx">The x location after ensuring <paramref name="top"/> will remain visible.</param>
 		/// <param name="ny">The y location after ensuring <paramref name="top"/> will remain visible.</param>
-		/// <param name="menuBar">The new top most menuBar</param>
-		/// <param name="statusBar">The new top most statusBar</param>
+		/// <param name="mb">The new top most menuBar</param>
+		/// <param name="sb">The new top most statusBar</param>
 		/// <returns>The <see cref="Toplevel"/> that is Application.Top</returns>
 		internal View EnsureVisibleBounds (Toplevel top, int x, int y,
 					out int nx, out int ny, out MenuBar mb, out StatusBar sb)

+ 39 - 6
Terminal.Gui/Core/View.cs

@@ -21,7 +21,7 @@ namespace Terminal.Gui {
 
 		/// <summary>
 		/// The position and size of the view will be computed based on 
-		/// <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/>. <see cref="View.Frame"/> will
+		/// <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/>. <see cref="View.Frame"/> will
 		/// provide the absolute computed values.
 		/// </summary>
 		Computed
@@ -564,6 +564,42 @@ namespace Terminal.Gui {
 			}
 		}
 
+		/// <summary>
+		/// Called before the <see cref="View.Title"/> changes. Invokes the <see cref="TitleChanging"/> event, which can be cancelled.
+		/// </summary>
+		/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
+		/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
+		/// <returns>`true` if an event handler canceled the Title change.</returns>
+		public virtual bool OnTitleChanging (ustring oldTitle, ustring newTitle)
+		{
+			var args = new TitleEventArgs (oldTitle, newTitle);
+			TitleChanging?.Invoke (this, args);
+			return args.Cancel;
+		}
+
+		/// <summary>
+		/// Event fired when the <see cref="View.Title"/> is changing. Set <see cref="TitleEventArgs.Cancel"/> to 
+		/// `true` to cancel the Title change.
+		/// </summary>
+		public event EventHandler<TitleEventArgs> TitleChanging;
+
+		/// <summary>
+		/// Called when the <see cref="View.Title"/> has been changed. Invokes the <see cref="TitleChanged"/> event.
+		/// </summary>
+		/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
+		/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
+		public virtual void OnTitleChanged (ustring oldTitle, ustring newTitle)
+		{
+			var args = new TitleEventArgs (oldTitle, newTitle);
+			TitleChanged?.Invoke (this, args);
+		}
+
+		/// <summary>
+		/// Event fired after the <see cref="View.Title"/> has been changed. 
+		/// </summary>
+		public event EventHandler<TitleEventArgs> TitleChanged;
+
+
 		LayoutStyle _layoutStyle;
 
 		/// <summary>
@@ -593,9 +629,6 @@ namespace Terminal.Gui {
 		/// The <see cref="Rect.Location"/> of Bounds is always (0, 0). To obtain the offset of the Bounds from the Frame use 
 		/// <see cref="GetBoundsOffset"/>.
 		/// </para>
-		/// <para>
-		/// To obtain the SuperView-relative location of the content area use <see cref="ContentArea"/>.
-		/// </para>
 		/// </remarks>
 		public virtual Rect Bounds {
 			get {
@@ -609,13 +642,13 @@ namespace Terminal.Gui {
 			}
 			set {
 				// BUGBUG: Margin etc.. can be null (if typeof(Frame))
-				Frame = new Rect (Frame.Location, 
+				Frame = new Rect (Frame.Location,
 					new Size (
 						value.Size.Width + Margin.Thickness.Horizontal + BorderFrame.Thickness.Horizontal + Padding.Thickness.Horizontal,
 						value.Size.Height + Margin.Thickness.Vertical + BorderFrame.Thickness.Vertical + Padding.Thickness.Vertical
 						)
 					);
-;
+				;
 			}
 		}
 

+ 2 - 67
Terminal.Gui/Core/Window.cs

@@ -6,7 +6,7 @@ using Terminal.Gui.Configuration;
 using static Terminal.Gui.Configuration.ConfigurationManager;
 
 namespace Terminal.Gui {
-	
+
 	/// <summary>
 	/// A <see cref="Toplevel"/> <see cref="View"/> that draws a border around its <see cref="View.Frame"/> with a Title at the top.
 	/// </summary>
@@ -93,7 +93,7 @@ namespace Terminal.Gui {
 			ColorScheme = Colors.Base;
 			if (title == null) title = ustring.Empty;
 			Title = title;
-			
+
 			if (border == null) {
 				// TODO: v2 this is a hack until Border gets refactored
 				Border = new Border () {
@@ -149,70 +149,5 @@ namespace Terminal.Gui {
 			RemoveMenuStatusBar (view);
 
 		}
-
-		/// <summary>
-		/// Event arguments for <see cref="View.Title"/> change events.
-		/// </summary>
-		public class TitleEventArgs : EventArgs {
-			/// <summary>
-			/// The new Window Title.
-			/// </summary>
-			public ustring NewTitle { get; set; }
-
-			/// <summary>
-			/// The old Window Title.
-			/// </summary>
-			public ustring OldTitle { get; set; }
-
-			/// <summary>
-			/// Flag which allows canceling the Title change.
-			/// </summary>
-			public bool Cancel { get; set; }
-
-			/// <summary>
-			/// Initializes a new instance of <see cref="TitleEventArgs"/>
-			/// </summary>
-			/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
-			/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
-			public TitleEventArgs (ustring oldTitle, ustring newTitle)
-			{
-				OldTitle = oldTitle;
-				NewTitle = newTitle;
-			}
-		}
-		/// <summary>
-		/// Called before the <see cref="View.Title"/> changes. Invokes the <see cref="TitleChanging"/> event, which can be cancelled.
-		/// </summary>
-		/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
-		/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
-		/// <returns>`true` if an event handler canceled the Title change.</returns>
-		public virtual bool OnTitleChanging (ustring oldTitle, ustring newTitle)
-		{
-			var args = new TitleEventArgs (oldTitle, newTitle);
-			TitleChanging?.Invoke (this, args);
-			return args.Cancel;
-		}
-
-		/// <summary>
-		/// Event fired when the <see cref="View.Title"/> is changing. Set <see cref="TitleEventArgs.Cancel"/> to 
-		/// `true` to cancel the Title change.
-		/// </summary>
-		public event EventHandler<TitleEventArgs> TitleChanging;
-
-		/// <summary>
-		/// Called when the <see cref="View.Title"/> has been changed. Invokes the <see cref="TitleChanged"/> event.
-		/// </summary>
-		/// <param name="oldTitle">The <see cref="View.Title"/> that is/has been replaced.</param>
-		/// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
-		public virtual void OnTitleChanged (ustring oldTitle, ustring newTitle)
-		{
-			var args = new TitleEventArgs (oldTitle, newTitle);
-			TitleChanged?.Invoke (this, args);
-		}
-
-		/// <summary>
-		/// Event fired after the <see cref="View.Title"/> has been changed. 
-		/// </summary>
-		public event EventHandler<TitleEventArgs> TitleChanged;
 	}
 }

+ 8 - 0
Terminal.Gui/Views/TileView.cs

@@ -373,8 +373,16 @@ namespace Terminal.Gui {
 			return true;
 		}
 
+		/// <summary>
+		/// BUGBUG: v2 Temporary for now
+		/// </summary>
 		public BorderStyle BorderStyle { get; set; } = BorderStyle.None;
 
+		/// <summary>
+		/// Overriden so no Frames get drawn (BUGBUG: v2 fix this hack)
+		/// </summary>
+		/// <param name="bounds"></param>
+		/// <returns></returns>
 		public override bool OnDrawFrames (Rect bounds)
 		{
 			return false;

+ 0 - 42
Terminal.Gui/Views/TitleEventArgs.cs

@@ -1,42 +0,0 @@
-using NStack;
-using System;
-
-namespace Terminal.Gui {
-
-	public partial class TileView {
-
-		public partial class Tile {
-			/// <summary>
-			/// An <see cref="EventArgs"/> which allows passing a cancelable new <see cref="Title"/> value event.
-			/// </summary>
-			public class TitleEventArgs : EventArgs {
-				/// <summary>
-				/// The new Window Title.
-				/// </summary>
-				public ustring NewTitle { get; set; }
-
-				/// <summary>
-				/// The old Window Title.
-				/// </summary>
-				public ustring OldTitle { get; set; }
-
-				/// <summary>
-				/// Flag which allows cancelling the Title change.
-				/// </summary>
-				public bool Cancel { get; set; }
-
-				/// <summary>
-				/// Initializes a new instance of <see cref="TitleEventArgs"/>
-				/// </summary>
-				/// <param name="oldTitle">The <see cref="Title"/> that is/has been replaced.</param>
-				/// <param name="newTitle">The new <see cref="Title"/> to be replaced.</param>
-				public TitleEventArgs (ustring oldTitle, ustring newTitle)
-				{
-					OldTitle = oldTitle;
-					NewTitle = newTitle;
-				}
-			}
-		}
-
-	}
-}

+ 0 - 66
Terminal.Gui/Windows/Wizard.cs

@@ -92,72 +92,6 @@ namespace Terminal.Gui {
 
 			private ustring title = ustring.Empty;
 
-			/// <summary>
-			/// An <see cref="EventArgs"/> which allows passing a cancelable new <see cref="Title"/> value event.
-			/// </summary>
-			public class TitleEventArgs : EventArgs {
-				/// <summary>
-				/// The new Window Title.
-				/// </summary>
-				public ustring NewTitle { get; set; }
-
-				/// <summary>
-				/// The old Window Title.
-				/// </summary>
-				public ustring OldTitle { get; set; }
-
-				/// <summary>
-				/// Flag which allows cancelling the Title change.
-				/// </summary>
-				public bool Cancel { get; set; }
-
-				/// <summary>
-				/// Initializes a new instance of <see cref="TitleEventArgs"/>
-				/// </summary>
-				/// <param name="oldTitle">The <see cref="Title"/> that is/has been replaced.</param>
-				/// <param name="newTitle">The new <see cref="Title"/> to be replaced.</param>
-				public TitleEventArgs (ustring oldTitle, ustring newTitle)
-				{
-					OldTitle = oldTitle;
-					NewTitle = newTitle;
-				}
-			}
-
-			/// <summary>
-			/// Called before the <see cref="Title"/> changes. Invokes the <see cref="TitleChanging"/> event, which can be cancelled.
-			/// </summary>
-			/// <param name="oldTitle">The <see cref="Title"/> that is/has been replaced.</param>
-			/// <param name="newTitle">The new <see cref="Title"/> to be replaced.</param>
-			/// <returns><c>true</c> if an event handler cancelled the Title change.</returns>
-			public virtual bool OnTitleChanging (ustring oldTitle, ustring newTitle)
-			{
-				var args = new TitleEventArgs (oldTitle, newTitle);
-				TitleChanging?.Invoke (this, args);
-				return args.Cancel;
-			}
-
-			/// <summary>
-			/// Event fired when the <see cref="Title"/> is changing. Set <see cref="TitleEventArgs.Cancel"/> to 
-			/// <c>true</c> to cancel the Title change.
-			/// </summary>
-			public event EventHandler<TitleEventArgs> TitleChanging;
-
-			/// <summary>
-			/// Called when the <see cref="Title"/> has been changed. Invokes the <see cref="TitleChanged"/> event.
-			/// </summary>
-			/// <param name="oldTitle">The <see cref="Title"/> that is/has been replaced.</param>
-			/// <param name="newTitle">The new <see cref="Title"/> to be replaced.</param>
-			public virtual void OnTitleChanged (ustring oldTitle, ustring newTitle)
-			{
-				var args = new TitleEventArgs (oldTitle, newTitle);
-				TitleChanged?.Invoke (this, args);
-			}
-
-			/// <summary>
-			/// Event fired after the <see cref="Title"/> has been changed. 
-			/// </summary>
-			public event EventHandler<TitleEventArgs> TitleChanged;
-
 			// The contentView works like the ContentView in FrameView.
 			private View contentView = new View () { Data = "WizardContentView" };
 

+ 1 - 1
UICatalog/UICatalog.cs

@@ -237,7 +237,7 @@ namespace UICatalog {
 
 		static bool _useSystemConsole = false;
 		static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
-		static bool _enableConsoleScrolling = false;
+		//static bool _enableConsoleScrolling = false;
 		static bool _isFirstRunning = true;
 		static string _topLevelColorScheme;
 

+ 4 - 7
UnitTests/TopLevels/WindowTests.cs

@@ -38,7 +38,6 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.Null (r.Y);
 			Assert.False (r.IsCurrentTop);
 			Assert.Empty (r.Id);
-			Assert.NotEmpty (r.Subviews);
 			Assert.False (r.WantContinuousButtonPressed);
 			Assert.False (r.WantMousePositionReports);
 			Assert.Null (r.SuperView);
@@ -50,7 +49,7 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.NotNull (r);
 			Assert.Equal ("title", r.Title);
 			Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
-			Assert.Equal ("Window()({X=0,Y=0,Width=0,Height=0})", r.ToString ());
+			Assert.Equal ("Window(title)({X=0,Y=0,Width=0,Height=0})", r.ToString ());
 			Assert.True (r.CanFocus);
 			Assert.False (r.HasFocus);
 			Assert.Equal (new Rect (0, 0, 0, 0), r.Bounds);
@@ -62,8 +61,7 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.Null (r.X);           // All view Pos are initialized now in the IsAdded setter,
 			Assert.Null (r.Y);           // avoiding Pos errors.
 			Assert.False (r.IsCurrentTop);
-			Assert.Empty (r.Id);
-			Assert.NotEmpty (r.Subviews);
+			Assert.Equal (r.Title, r.Id);
 			Assert.False (r.WantContinuousButtonPressed);
 			Assert.False (r.WantMousePositionReports);
 			Assert.Null (r.SuperView);
@@ -75,7 +73,7 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.Equal ("title", r.Title);
 			Assert.NotNull (r);
 			Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
-			Assert.Equal ("Window()({X=1,Y=2,Width=3,Height=4})", r.ToString ());
+			Assert.Equal ("Window(title)({X=1,Y=2,Width=3,Height=4})", r.ToString ());
 			Assert.True (r.CanFocus);
 			Assert.False (r.HasFocus);
 			Assert.Equal (new Rect (0, 0, 3, 4), r.Bounds);
@@ -87,8 +85,7 @@ namespace Terminal.Gui.TopLevelTests {
 			Assert.Null (r.X);
 			Assert.Null (r.Y);
 			Assert.False (r.IsCurrentTop);
-			Assert.Empty (r.Id);
-			Assert.NotEmpty (r.Subviews);
+			Assert.Equal (r.Title, r.Id);
 			Assert.False (r.WantContinuousButtonPressed);
 			Assert.False (r.WantMousePositionReports);
 			Assert.Null (r.SuperView);