Browse Source

Removed Frame overrides

Tig Kindel 1 year ago
parent
commit
baf66ef704

+ 0 - 11
Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs

@@ -23,17 +23,6 @@ namespace Terminal.Gui {
 				WantMousePositionReports = true;
 			}
 
-			public override Rect Frame {
-				get => base.Frame;
-				set {
-					base.Frame = value;
-					X = value.X;
-					Y = value.Y;
-					Width = value.Width;
-					Height = value.Height;
-				}
-			}
-
 			public override void OnDrawContent (Rect contentArea)
 			{
 				if (autocomplete.LastPopupPos == null) {

+ 1 - 1
Terminal.Gui/View/Frame.cs

@@ -58,7 +58,7 @@ namespace Terminal.Gui {
 		/// <inheritdoc/>
 		public override Rect FrameToScreen ()
 		{
-			// Frames are *Children* of a View, not SubViews. Thus View.FramToScreen will not work.
+			// Frames are *Children* of a View, not SubViews. Thus View.FrameToScreen will not work.
 			// To get the screen-relative coordinates of a Frame, we need to know who
 			// the Parent is
 			var ret = Parent?.Frame ?? Frame;

+ 1 - 2
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -52,8 +52,7 @@ public partial class View {
 	///         </para>
 	///         <para>
 	///         Altering the Frame will eventually (when the view is next drawn) cause the
-	///         <see cref="LayoutSubview(View, Rect)"/>
-	///         and <see cref="OnDrawContent(Rect)"/> methods to be called.
+	///         <see cref="LayoutSubview(View, Rect)"/> and <see cref="OnDrawContent(Rect)"/> methods to be called.
 	///         </para>
 	/// </remarks>
 	public virtual Rect Frame {

+ 12 - 14
Terminal.Gui/Views/TextField.cs

@@ -110,6 +110,8 @@ namespace Terminal.Gui {
 
 			Initialized += TextField_Initialized;
 
+			LayoutComplete += TextField_LayoutComplete;
+
 			// Things this view knows how to do
 			AddCommand (Command.DeleteCharRight, () => { DeleteCharRight (); return true; });
 			AddCommand (Command.DeleteCharLeft, () => { DeleteCharLeft (false); return true; });
@@ -219,6 +221,16 @@ namespace Terminal.Gui {
 			KeyBindings.Add (ContextMenu.Key.KeyCode, KeyBindingScope.HotKey, Command.ShowContextMenu);
 		}
 
+		private void TextField_LayoutComplete (object sender, LayoutEventArgs e)
+		{
+			// Don't let height > 1
+			if (Frame.Height > 1) {
+				Height = 1;
+			} 
+			Adjust ();
+		}
+
+
 		private MenuBarItem BuildContextMenuBarItem ()
 		{
 			return new MenuBarItem (new MenuItem [] {
@@ -280,20 +292,6 @@ namespace Terminal.Gui {
 		/// </summary>
 		public IAutocomplete Autocomplete { get; set; } = new TextFieldAutocomplete ();
 
-		///<inheritdoc/>
-		public override Rect Frame {
-			get => base.Frame;
-			set {
-				if (value.Height > 1) {
-					base.Frame = new Rect (value.X, value.Y, value.Width, 1);
-					Height = 1;
-				} else {
-					base.Frame = value;
-				}
-				Adjust ();
-			}
-		}
-
 		/// <summary>
 		///   Sets or gets the text held by the view.
 		/// </summary>