فهرست منبع

Removed a ton of code

Tig Kindel 2 سال پیش
والد
کامیت
4bbd359745

+ 782 - 835
Terminal.Gui/Core/Border.cs

@@ -103,60 +103,7 @@ namespace Terminal.Gui {
 			return new Rect (new Point (rect.X + Left, rect.Y + Top), size);
 		}
 
-		/// <summary>
-		/// Draws the thickness rectangle with an optional diagnostics label.
-		/// </summary>
-		/// <param name="rect">The location and size of the rectangle that bounds the thickness rectangle, in 
-		/// screen coordinates.</param>
-		/// <param name="label">The diagnostics label to draw on the bottom of the <see cref="Bottom"/>.</param>
-		/// <returns>The inner rectangle remaining to be drawn.</returns>
-		public Rect Draw (Rect rect, string label = null)
-		{
-			// Draw the Top side
-			for (var r = rect.Y; r < Math.Min (rect.Y + rect.Height, rect.Y + Top); r++) {
-				for (var c = rect.X; c < rect.X + rect.Width; c++) {
-					Application.Driver.Move (c, r);
-					Application.Driver.AddRune (' ');
-				}
-			}
-
-			// Draw the Left side
-			for (var r = rect.Y; r < rect.Y + rect.Height; r++) {
-				for (var c = rect.X; c < Math.Min (rect.X + rect.Width, rect.X + Left); c++) {
-					Application.Driver.Move (c, r);
-					Application.Driver.AddRune (' ');
-				}
-			}
-
-			// Draw the Right side			
-			for (var r = rect.Y; r < rect.Y + rect.Height; r++) {
-				for (var c = rect.X + Math.Max (0, rect.Width - Right); c < rect.X + rect.Width; c++) {
-					Application.Driver.Move (c, r);
-					Application.Driver.AddRune (' ');
-				}
-			}
-
-			// Draw the Bottom side
-			for (var r = rect.Y + Math.Max (0, rect.Height - Bottom); r < rect.Y + rect.Height; r++) {
-				for (var c = rect.X; c < rect.X + rect.Width; c++) {
-					Application.Driver.Move (c, r);
-					Application.Driver.AddRune (' ');
-				}
-			}
-
-			// Draw the diagnostics label on the bottom
-			var tf = new TextFormatter () {
-				Text = label == null ? string.Empty : $"{label} {this}",
-				Alignment = TextAlignment.Centered,
-				VerticalAlignment = VerticalTextAlignment.Bottom
-			};
-			tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute);
-
-			return GetInnerRect (rect);
-
-		}
-
-		// TODO: Add GetHashCode, and operator overloads
+		// TODO: add operator overloads
 		/// <summary>
 		/// Gets an empty thickness.
 		/// </summary>
@@ -216,220 +163,220 @@ namespace Terminal.Gui {
 	public class Border {
 		private int marginFrame => DrawMarginFrame ? 1 : 0;
 
-		/// <summary>
-		/// A sealed <see cref="Toplevel"/> derived class to implement <see cref="Border"/> feature.
-		/// This is only a wrapper to get borders on a toplevel and is recommended using another
-		/// derived, like <see cref="Window"/> where is possible to have borders with or without
-		/// border line or spacing around.
-		/// </summary>
-		public sealed class ToplevelContainer : Toplevel {
-			/// <inheritdoc/>
-			public override Border Border {
-				get => base.Border;
-				set {
-					if (base.Border != null && base.Border.Child != null && value.Child == null) {
-						value.Child = base.Border.Child;
-					}
-					base.Border = value;
-					if (value == null) {
-						return;
-					}
-					Rect frame;
-					if (Border.Child != null && (Border.Child.Width is Dim || Border.Child.Height is Dim)) {
-						frame = Rect.Empty;
-					} else {
-						frame = Frame;
-					}
-					AdjustContentView (frame);
-
-					Border.BorderChanged += Border_BorderChanged;
-				}
-			}
-
-			void Border_BorderChanged (Border border)
-			{
-				Rect frame;
-				if (Border.Child != null && (Border.Child.Width is Dim || Border.Child.Height is Dim)) {
-					frame = Rect.Empty;
-				} else {
-					frame = Frame;
-				}
-				AdjustContentView (frame);
-			}
-
-			/// <summary>
-			/// Initializes with default null values.
-			/// </summary>
-			public ToplevelContainer () : this (null, string.Empty) { }
-
-			/// <summary>
-			/// Initializes a <see cref="ToplevelContainer"/> with a <see cref="LayoutStyle.Computed"/>
-			/// </summary>
-			/// <param name="border">The border.</param>
-			/// <param name="title">The title.</param>
-			public ToplevelContainer (Border border, string title = null)
-			{
-				Initialize (Rect.Empty, border, title ?? string.Empty);
-			}
-
-			/// <summary>
-			/// Initializes a <see cref="ToplevelContainer"/> with a <see cref="LayoutStyle.Absolute"/>
-			/// </summary>
-			/// <param name="frame">The frame.</param>
-			/// <param name="border">The border.</param>
-			/// <param name="title">The title.</param>
-			public ToplevelContainer (Rect frame, Border border, string title = null) : base (frame)
-			{
-				Initialize (frame, border, title ?? string.Empty);
-			}
-
-			private void Initialize (Rect frame, Border border, string title)
-			{
-				ColorScheme = Colors.TopLevel;
-				if (border == null) {
-					Border = new Border () {
-						BorderStyle = BorderStyle.Single,
-						BorderBrush = ColorScheme.Normal.Background,
-						Title = (ustring)title
-					};
-				} else {
-					Border = border;
-				}
-				AdjustContentView (frame);
-			}
-
-			void AdjustContentView (Rect frame)
-			{
-				var borderLength = Border.DrawMarginFrame ? 1 : 0;
-				var sumPadding = Border.GetSumThickness ();
-				var wp = new Point ();
-				var wb = new Size ();
-				if (frame == Rect.Empty) {
-					wp.X = borderLength + sumPadding.Left;
-					wp.Y = borderLength + sumPadding.Top;
-					wb.Width = borderLength + sumPadding.Right;
-					wb.Height = borderLength + sumPadding.Bottom;
-					if (Border.Child == null) {
-						Border.Child = new ChildContentView (this) {
-							X = wp.X,
-							Y = wp.Y,
-							Width = Dim.Fill (wb.Width),
-							Height = Dim.Fill (wb.Height)
-						};
-					} else {
-						Border.Child.X = wp.X;
-						Border.Child.Y = wp.Y;
-						Border.Child.Width = Dim.Fill (wb.Width);
-						Border.Child.Height = Dim.Fill (wb.Height);
-					}
-				} else {
-					wb.Width = (2 * borderLength) + sumPadding.Right + sumPadding.Left;
-					wb.Height = (2 * borderLength) + sumPadding.Bottom + sumPadding.Top;
-					var cFrame = new Rect (borderLength + sumPadding.Left, borderLength + sumPadding.Top, frame.Width - wb.Width, frame.Height - wb.Height);
-					if (Border.Child == null) {
-						Border.Child = new ChildContentView (cFrame, this);
-					} else {
-						Border.Child.Frame = cFrame;
-					}
-				}
-				if (Subviews?.Count == 0)
-					base.Add (Border.Child);
-				Border.ChildContainer = this;
-			}
-
-			/// <inheritdoc/>
-			public override void Add (View view)
-			{
-				Border.Child.Add (view);
-				if (view.CanFocus) {
-					CanFocus = true;
-				}
-				AddMenuStatusBar (view);
-			}
-
-			/// <inheritdoc/>
-			public override void Remove (View view)
-			{
-				if (view == null) {
-					return;
-				}
-
-				SetNeedsDisplay ();
-				var touched = view.Frame;
-				Border.Child.Remove (view);
-
-				if (Border.Child.InternalSubviews.Count < 1) {
-					CanFocus = false;
-				}
-				RemoveMenuStatusBar (view);
-			}
-
-			/// <inheritdoc/>
-			public override void RemoveAll ()
-			{
-				Border.Child.RemoveAll ();
-			}
-
-			/// <inheritdoc/>
-			public override void Redraw (Rect bounds)
-			{
-				if (!NeedDisplay.IsEmpty) {
-					Driver.SetAttribute (GetNormalColor ());
-					Clear ();
-				}
-				var savedClip = Border.Child.ClipToBounds ();
-				Border.Child.Redraw (Border.Child.Bounds);
-				Driver.Clip = savedClip;
-
-				ClearLayoutNeeded ();
-				ClearNeedsDisplay ();
-
-				Driver.SetAttribute (GetNormalColor ());
-				Border.DrawContent (this, false);
-				if (HasFocus)
-					Driver.SetAttribute (ColorScheme.HotNormal);
-				if (Border.DrawMarginFrame) {
-					if (!ustring.IsNullOrEmpty (Border.Title))
-						Border.DrawTitle (this);
-					else
-						Border.DrawTitle (this, Frame);
-				}
-				Driver.SetAttribute (GetNormalColor ());
-
-				// Checks if there are any SuperView view which intersect with this window.
-				if (SuperView != null) {
-					SuperView.SetNeedsLayout ();
-					SuperView.SetNeedsDisplay ();
-				}
-			}
-
-			/// <inheritdoc/>
-			public override void OnCanFocusChanged ()
-			{
-				if (Border.Child != null) {
-					Border.Child.CanFocus = CanFocus;
-				}
-				base.OnCanFocusChanged ();
-			}
-		}
-
-		private class ChildContentView : View {
-			View instance;
-
-			public ChildContentView (Rect frame, View instance) : base (frame)
-			{
-				this.instance = instance;
-			}
-			public ChildContentView (View instance)
-			{
-				this.instance = instance;
-			}
-
-			public override bool MouseEvent (MouseEvent mouseEvent)
-			{
-				return instance.MouseEvent (mouseEvent);
-			}
-		}
+		///// <summary>
+		///// A sealed <see cref="Toplevel"/> derived class to implement <see cref="Border"/> feature.
+		///// This is only a wrapper to get borders on a toplevel and is recommended using another
+		///// derived, like <see cref="Window"/> where is possible to have borders with or without
+		///// border line or spacing around.
+		///// </summary>
+		//public sealed class ToplevelContainer : Toplevel {
+		//	/// <inheritdoc/>
+		//	public override Border Border {
+		//		get => base.Border;
+		//		set {
+		//			if (base.Border != null && base.Border.Child != null && value.Child == null) {
+		//				value.Child = base.Border.Child;
+		//			}
+		//			base.Border = value;
+		//			if (value == null) {
+		//				return;
+		//			}
+		//			Rect frame;
+		//			if (Border.Child != null && (Border.Child.Width is Dim || Border.Child.Height is Dim)) {
+		//				frame = Rect.Empty;
+		//			} else {
+		//				frame = Frame;
+		//			}
+		//			AdjustContentView (frame);
+
+		//			Border.BorderChanged += Border_BorderChanged;
+		//		}
+		//	}
+
+		//	void Border_BorderChanged (Border border)
+		//	{
+		//		Rect frame;
+		//		if (Border.Child != null && (Border.Child.Width is Dim || Border.Child.Height is Dim)) {
+		//			frame = Rect.Empty;
+		//		} else {
+		//			frame = Frame;
+		//		}
+		//		AdjustContentView (frame);
+		//	}
+
+		//	/// <summary>
+		//	/// Initializes with default null values.
+		//	/// </summary>
+		//	public ToplevelContainer () : this (null, string.Empty) { }
+
+		//	/// <summary>
+		//	/// Initializes a <see cref="ToplevelContainer"/> with a <see cref="LayoutStyle.Computed"/>
+		//	/// </summary>
+		//	/// <param name="border">The border.</param>
+		//	/// <param name="title">The title.</param>
+		//	public ToplevelContainer (Border border, string title = null)
+		//	{
+		//		Initialize (Rect.Empty, border, title ?? string.Empty);
+		//	}
+
+		//	/// <summary>
+		//	/// Initializes a <see cref="ToplevelContainer"/> with a <see cref="LayoutStyle.Absolute"/>
+		//	/// </summary>
+		//	/// <param name="frame">The frame.</param>
+		//	/// <param name="border">The border.</param>
+		//	/// <param name="title">The title.</param>
+		//	public ToplevelContainer (Rect frame, Border border, string title = null) : base (frame)
+		//	{
+		//		Initialize (frame, border, title ?? string.Empty);
+		//	}
+
+		//	private void Initialize (Rect frame, Border border, string title)
+		//	{
+		//		ColorScheme = Colors.TopLevel;
+		//		if (border == null) {
+		//			Border = new Border () {
+		//				BorderStyle = BorderStyle.Single,
+		//				BorderBrush = ColorScheme.Normal.Background,
+		//				Title = (ustring)title
+		//			};
+		//		} else {
+		//			Border = border;
+		//		}
+		//		AdjustContentView (frame);
+		//	}
+
+		//	void AdjustContentView (Rect frame)
+		//	{
+		//		var borderLength = Border.DrawMarginFrame ? 1 : 0;
+		//		var sumPadding = Border.GetSumThickness ();
+		//		var wp = new Point ();
+		//		var wb = new Size ();
+		//		if (frame == Rect.Empty) {
+		//			wp.X = borderLength + sumPadding.Left;
+		//			wp.Y = borderLength + sumPadding.Top;
+		//			wb.Width = borderLength + sumPadding.Right;
+		//			wb.Height = borderLength + sumPadding.Bottom;
+		//			if (Border.Child == null) {
+		//				Border.Child = new ChildContentView (this) {
+		//					X = wp.X,
+		//					Y = wp.Y,
+		//					Width = Dim.Fill (wb.Width),
+		//					Height = Dim.Fill (wb.Height)
+		//				};
+		//			} else {
+		//				Border.Child.X = wp.X;
+		//				Border.Child.Y = wp.Y;
+		//				Border.Child.Width = Dim.Fill (wb.Width);
+		//				Border.Child.Height = Dim.Fill (wb.Height);
+		//			}
+		//		} else {
+		//			wb.Width = (2 * borderLength) + sumPadding.Right + sumPadding.Left;
+		//			wb.Height = (2 * borderLength) + sumPadding.Bottom + sumPadding.Top;
+		//			var cFrame = new Rect (borderLength + sumPadding.Left, borderLength + sumPadding.Top, frame.Width - wb.Width, frame.Height - wb.Height);
+		//			if (Border.Child == null) {
+		//				Border.Child = new ChildContentView (cFrame, this);
+		//			} else {
+		//				Border.Child.Frame = cFrame;
+		//			}
+		//		}
+		//		if (Subviews?.Count == 0)
+		//			base.Add (Border.Child);
+		//		Border.ChildContainer = this;
+		//	}
+
+		//	/// <inheritdoc/>
+		//	public override void Add (View view)
+		//	{
+		//		Border.Child.Add (view);
+		//		if (view.CanFocus) {
+		//			CanFocus = true;
+		//		}
+		//		AddMenuStatusBar (view);
+		//	}
+
+		//	/// <inheritdoc/>
+		//	public override void Remove (View view)
+		//	{
+		//		if (view == null) {
+		//			return;
+		//		}
+
+		//		SetNeedsDisplay ();
+		//		var touched = view.Frame;
+		//		Border.Child.Remove (view);
+
+		//		if (Border.Child.InternalSubviews.Count < 1) {
+		//			CanFocus = false;
+		//		}
+		//		RemoveMenuStatusBar (view);
+		//	}
+
+		//	/// <inheritdoc/>
+		//	public override void RemoveAll ()
+		//	{
+		//		Border.Child.RemoveAll ();
+		//	}
+
+		//	/// <inheritdoc/>
+		//	public override void Redraw (Rect bounds)
+		//	{
+		//		if (!NeedDisplay.IsEmpty) {
+		//			Driver.SetAttribute (GetNormalColor ());
+		//			Clear ();
+		//		}
+		//		var savedClip = Border.Child.ClipToBounds ();
+		//		Border.Child.Redraw (Border.Child.Bounds);
+		//		Driver.Clip = savedClip;
+
+		//		ClearLayoutNeeded ();
+		//		ClearNeedsDisplay ();
+
+		//		Driver.SetAttribute (GetNormalColor ());
+		//		Border.DrawContent (this, false);
+		//		if (HasFocus)
+		//			Driver.SetAttribute (ColorScheme.HotNormal);
+		//		if (Border.DrawMarginFrame) {
+		//			if (!ustring.IsNullOrEmpty (Border.Title))
+		//				Border.DrawTitle (this);
+		//			else
+		//				Border.DrawTitle (this, Frame);
+		//		}
+		//		Driver.SetAttribute (GetNormalColor ());
+
+		//		// Checks if there are any SuperView view which intersect with this window.
+		//		if (SuperView != null) {
+		//			SuperView.SetNeedsLayout ();
+		//			SuperView.SetNeedsDisplay ();
+		//		}
+		//	}
+
+		//	/// <inheritdoc/>
+		//	public override void OnCanFocusChanged ()
+		//	{
+		//		if (Border.Child != null) {
+		//			Border.Child.CanFocus = CanFocus;
+		//		}
+		//		base.OnCanFocusChanged ();
+		//	}
+		//}
+
+		//private class ChildContentView : View {
+		//	View instance;
+
+		//	public ChildContentView (Rect frame, View instance) : base (frame)
+		//	{
+		//		this.instance = instance;
+		//	}
+		//	public ChildContentView (View instance)
+		//	{
+		//		this.instance = instance;
+		//	}
+
+		//	public override bool MouseEvent (MouseEvent mouseEvent)
+		//	{
+		//		return instance.MouseEvent (mouseEvent);
+		//	}
+		//}
 
 		/// <summary>
 		/// Invoked when any property of Border changes (except <see cref="Child"/>).
@@ -530,52 +477,52 @@ namespace Terminal.Gui {
 			}
 		}
 
-		/// <summary>
-		/// Gets the rendered width of this element.
-		/// </summary>
-		[JsonIgnore]
-		public int ActualWidth {
-			get {
-				var driver = Application.Driver;
-				if (Parent?.Border == null) {
-					return Math.Min (Child?.Frame.Width + (2 * marginFrame) + Padding.Right
-						+ BorderThickness.Right + Padding.Left + BorderThickness.Left ?? 0, driver.Cols);
-				}
-				return Math.Min (Parent.Frame.Width, driver.Cols);
-			}
-		}
-		/// <summary>
-		/// Gets the rendered height of this element.
-		/// </summary>
-		[JsonIgnore]
-		public int ActualHeight {
-			get {
-				var driver = Application.Driver;
-				if (Parent?.Border == null) {
-					return Math.Min (Child?.Frame.Height + (2 * marginFrame) + Padding.Bottom
-						+ BorderThickness.Bottom + Padding.Top + BorderThickness.Top ?? 0, driver.Rows);
-				}
-				return Math.Min (Parent.Frame.Height, driver.Rows);
-			}
-		}
-
-		/// <summary>
-		/// Gets or sets the single child element of a <see cref="View"/>.
-		/// </summary>
-		[JsonIgnore]
-		public View Child { get; set; }
-
-		/// <summary>
-		/// Gets the parent <see cref="Child"/> parent if any.
-		/// </summary>
-		[JsonIgnore]
-		public View Parent { get => Child?.SuperView; }
-
-		/// <summary>
-		/// Gets or private sets by the <see cref="ToplevelContainer"/>
-		/// </summary>
-		[JsonIgnore]
-		public ToplevelContainer ChildContainer { get; private set; }
+		///// <summary>
+		///// Gets the rendered width of this element.
+		///// </summary>
+		//[JsonIgnore]
+		//public int ActualWidth {
+		//	get {
+		//		var driver = Application.Driver;
+		//		if (Parent?.Border == null) {
+		//			return Math.Min (Child?.Frame.Width + (2 * marginFrame) + Padding.Right
+		//				+ BorderThickness.Right + Padding.Left + BorderThickness.Left ?? 0, driver.Cols);
+		//		}
+		//		return Math.Min (Parent.Frame.Width, driver.Cols);
+		//	}
+		//}
+		///// <summary>
+		///// Gets the rendered height of this element.
+		///// </summary>
+		//[JsonIgnore]
+		//public int ActualHeight {
+		//	get {
+		//		var driver = Application.Driver;
+		//		if (Parent?.Border == null) {
+		//			return Math.Min (Child?.Frame.Height + (2 * marginFrame) + Padding.Bottom
+		//				+ BorderThickness.Bottom + Padding.Top + BorderThickness.Top ?? 0, driver.Rows);
+		//		}
+		//		return Math.Min (Parent.Frame.Height, driver.Rows);
+		//	}
+		//}
+
+		///// <summary>
+		///// Gets or sets the single child element of a <see cref="View"/>.
+		///// </summary>
+		//[JsonIgnore]
+		//public View Child { get; set; }
+
+		///// <summary>
+		///// Gets the parent <see cref="Child"/> parent if any.
+		///// </summary>
+		//[JsonIgnore]
+		//public View Parent { get => Child?.SuperView; }
+
+		///// <summary>
+		///// Gets or private sets by the <see cref="ToplevelContainer"/>
+		///// </summary>
+		//[JsonIgnore]
+		//public ToplevelContainer ChildContainer { get; private set; }
 
 		/// <summary>
 		/// Gets or sets the 3D effect around the <see cref="Border"/>.
@@ -619,527 +566,527 @@ namespace Terminal.Gui {
 			}
 		}
 
-		/// <summary>
-		/// The title to be displayed for this view.
-		/// </summary>
-		[JsonIgnore]
-		public ustring Title {
-			get => title;
-			set {
-				title = value;
-				OnBorderChanged ();
-			}
-		}
-
-		/// <summary>
-		/// Calculate the sum of the <see cref="Padding"/> and the <see cref="BorderThickness"/>
-		/// </summary>
-		/// <returns>The total of the <see cref="Border"/> <see cref="Thickness"/></returns>
-		public Thickness GetSumThickness ()
-		{
-			return new Thickness () {
-				Left = Padding.Left + BorderThickness.Left,
-				Top = Padding.Top + BorderThickness.Top,
-				Right = Padding.Right + BorderThickness.Right,
-				Bottom = Padding.Bottom + BorderThickness.Bottom
-			};
-		}
-
-		/// <summary>
-		/// Drawn the <see cref="BorderThickness"/> more the <see cref="Padding"/>
-		///  more the <see cref="Border.BorderStyle"/> and the <see cref="Effect3D"/>.
-		/// </summary>
-		/// <param name="view">The view to draw.</param>
-		/// <param name="fill">If it will clear or not the content area.</param>
-		public void DrawContent (View view = null, bool fill = true)
-		{
-			if (Child == null) {
-				Child = view;
-			}
-			if (Parent?.Border != null) {
-				DrawParentBorder (Parent.ViewToScreen (Parent.Bounds), fill);
-			} else {
-				DrawChildBorder (Child.ViewToScreen (Child.Bounds), fill);
-			}
-		}
-
-		/// <summary>
-		/// Same as <see cref="DrawContent"/> but drawing full frames for all borders.
-		/// </summary>
-		public void DrawFullContent ()
-		{
-			var borderThickness = BorderThickness;
-			var padding = Padding;
-			var marginFrame = DrawMarginFrame ? 1 : 0;
-			var driver = Application.Driver;
-			Rect scrRect;
-			if (Parent?.Border != null) {
-				scrRect = Parent.ViewToScreen (Parent.Bounds);
-			} else {
-				scrRect = Child.ViewToScreen (Child.Bounds);
-			}
-			Rect borderRect;
-			if (Parent?.Border != null) {
-				borderRect = scrRect;
-			} else {
-				borderRect = new Rect () {
-					X = scrRect.X - marginFrame - padding.Left - borderThickness.Left,
-					Y = scrRect.Y - marginFrame - padding.Top - borderThickness.Top,
-					Width = ActualWidth,
-					Height = ActualHeight
-				};
-			}
-			var savedAttribute = driver.GetAttribute ();
-
-			// Draw 3D effects
-			if (Effect3D) {
-				driver.SetAttribute ((Attribute)Effect3DBrush);
-
-				var effectBorder = new Rect () {
-					X = borderRect.X + Effect3DOffset.X,
-					Y = borderRect.Y + Effect3DOffset.Y,
-					Width = ActualWidth,
-					Height = ActualHeight
-				};
-				//Child.Clear (effectBorder);
-				for (int r = effectBorder.Y; r < Math.Min (effectBorder.Bottom, driver.Rows); r++) {
-					for (int c = effectBorder.X; c < Math.Min (effectBorder.Right, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-			}
-
-			// Draw border thickness
-			driver.SetAttribute (new Attribute (BorderBrush));
-			Child.Clear (borderRect);
-
-			borderRect = new Rect () {
-				X = borderRect.X + borderThickness.Left,
-				Y = borderRect.Y + borderThickness.Top,
-				Width = Math.Max (borderRect.Width - borderThickness.Right - borderThickness.Left, 0),
-				Height = Math.Max (borderRect.Height - borderThickness.Bottom - borderThickness.Top, 0)
-			};
-			if (borderRect != scrRect) {
-				// Draw padding
-				driver.SetAttribute (new Attribute (Background));
-				Child.Clear (borderRect);
-			}
-
-			driver.SetAttribute (savedAttribute);
-
-			// Draw margin frame
-			if (DrawMarginFrame) {
-				if (Parent?.Border != null) {
-					var sumPadding = GetSumThickness ();
-					borderRect = new Rect () {
-						X = scrRect.X + sumPadding.Left,
-						Y = scrRect.Y + sumPadding.Top,
-						Width = Math.Max (scrRect.Width - sumPadding.Right - sumPadding.Left, 0),
-						Height = Math.Max (scrRect.Height - sumPadding.Bottom - sumPadding.Top, 0)
-					};
-				} else {
-					borderRect = new Rect () {
-						X = borderRect.X + padding.Left,
-						Y = borderRect.Y + padding.Top,
-						Width = Math.Max (borderRect.Width - padding.Right - padding.Left, 0),
-						Height = Math.Max (borderRect.Height - padding.Bottom - padding.Top, 0)
-					};
-				}
-				if (borderRect.Width > 0 && borderRect.Height > 0) {
-					driver.DrawWindowFrame (borderRect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill: true, this);
-				}
-			}
-		}
-
-		private void DrawChildBorder (Rect frame, bool fill = true)
-		{
-			var drawMarginFrame = DrawMarginFrame ? 1 : 0;
-			var sumThickness = GetSumThickness ();
-			var padding = Padding;
-			var effect3DOffset = Effect3DOffset;
-			var driver = Application.Driver;
-
-			var savedAttribute = driver.GetAttribute ();
-
-			driver.SetAttribute (new Attribute (BorderBrush));
-
-			// Draw the upper BorderThickness
-			for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
-				r < frame.Y - drawMarginFrame - padding.Top; r++) {
-				for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-					c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the left BorderThickness
-			for (int r = frame.Y - drawMarginFrame - padding.Top;
-				r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
-				for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-					c < frame.X - drawMarginFrame - padding.Left; c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the right BorderThickness
-			for (int r = frame.Y - drawMarginFrame - padding.Top;
-				r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
-				for (int c = frame.Right + drawMarginFrame + padding.Right;
-					c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the lower BorderThickness
-			for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
-				r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom, driver.Rows); r++) {
-				for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-					c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			driver.SetAttribute (new Attribute (Background));
-
-			// Draw the upper Padding
-			for (int r = frame.Y - drawMarginFrame - padding.Top;
-				r < frame.Y - drawMarginFrame; r++) {
-				for (int c = frame.X - drawMarginFrame - padding.Left;
-					c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the left Padding
-			for (int r = frame.Y - drawMarginFrame;
-				r < Math.Min (frame.Bottom + drawMarginFrame, driver.Rows); r++) {
-				for (int c = frame.X - drawMarginFrame - padding.Left;
-					c < frame.X - drawMarginFrame; c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the right Padding
-			for (int r = frame.Y - drawMarginFrame;
-				r < Math.Min (frame.Bottom + drawMarginFrame, driver.Rows); r++) {
-				for (int c = frame.Right + drawMarginFrame;
-					c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the lower Padding
-			for (int r = frame.Bottom + drawMarginFrame;
-				r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
-				for (int c = frame.X - drawMarginFrame - padding.Left;
-					c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			driver.SetAttribute (savedAttribute);
-
-			// Draw the MarginFrame
-			if (DrawMarginFrame) {
-
-				var rect = new Rect () {
-					X = frame.X - drawMarginFrame,
-					Y = frame.Y - drawMarginFrame,
-					Width = frame.Width + (2 * drawMarginFrame),
-					Height = frame.Height + (2 * drawMarginFrame)
-				};
-				if (rect.Width > 0 && rect.Height > 0) {
-					driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
-					DrawTitle (Child);
-				}
-
-				//var rect = Child.ViewToScreen (new Rect (-1, -1, Child.Frame.Width + 2, Child.Frame.Height + 2));
-				//if (rect.Width > 0 && rect.Height > 0) {
-
-				//	var lc = new LineCanvas ();
-
-				//	lc.AddLine (rect.Location, rect.Width-1, Orientation.Horizontal, BorderStyle);
-				//	lc.AddLine (rect.Location, rect.Height-1, Orientation.Vertical, BorderStyle);
-
-				//	lc.AddLine (new Point (rect.X, rect.Y + rect.Height-1), rect.Width, Orientation.Horizontal, BorderStyle);
-				//	lc.AddLine (new Point (rect.X + rect.Width-1, rect.Y), rect.Height, Orientation.Vertical, BorderStyle);
-
-				//	//driver.SetAttribute (new Attribute(Color.Red, Color.BrightYellow));
-				//	foreach (var p in lc.GenerateImage (rect)) {
-				//		AddRuneAt (driver, p.Key.X, p.Key.Y, p.Value);
-				//	}
-				//	DrawTitle (Child);
-				//}
-			}
-
-			if (Effect3D) {
-				driver.SetAttribute ((Attribute)Effect3DBrush);
-
-				// Draw the upper Effect3D
-				for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-					r >= 0 && r < frame.Y - drawMarginFrame - sumThickness.Top; r++) {
-					for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-						c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the left Effect3D
-				for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-					r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-						c >= 0 && c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the right Effect3D
-				for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-					r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
-						c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the lower Effect3D
-				for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
-					r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-						c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-			}
-			driver.SetAttribute (savedAttribute);
-		}
-
-		private void DrawParentBorder (Rect frame, bool fill = true)
-		{
-			var sumThickness = GetSumThickness ();
-			var borderThickness = BorderThickness;
-			var effect3DOffset = Effect3DOffset;
-			var driver = Application.Driver;
-
-			var savedAttribute = driver.GetAttribute ();
-
-			driver.SetAttribute (new Attribute (BorderBrush));
-
-			// Draw the upper BorderThickness
-			for (int r = frame.Y;
-				r < Math.Min (frame.Y + borderThickness.Top, frame.Bottom); r++) {
-				for (int c = frame.X;
-					c < Math.Min (frame.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the left BorderThickness
-			for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
-				r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
-				for (int c = frame.X;
-					c < Math.Min (frame.X + borderThickness.Left, frame.Right); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the right BorderThickness
-			for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
-				r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
-				for (int c = Math.Max (frame.Right - borderThickness.Right, frame.X);
-					c < Math.Min (frame.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the lower BorderThickness
-			for (int r = Math.Max (frame.Bottom - borderThickness.Bottom, frame.Y);
-				r < Math.Min (frame.Bottom, driver.Rows); r++) {
-				for (int c = frame.X;
-					c < Math.Min (frame.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			driver.SetAttribute (new Attribute (Background));
-
-			// Draw the upper Padding
-			for (int r = frame.Y + borderThickness.Top;
-				r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < Math.Min (frame.Right - borderThickness.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the left Padding
-			for (int r = frame.Y + sumThickness.Top;
-				r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the right Padding
-			for (int r = frame.Y + sumThickness.Top;
-				r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
-				for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
-					c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			// Draw the lower Padding
-			for (int r = Math.Max (frame.Bottom - sumThickness.Bottom, frame.Y + borderThickness.Top);
-				r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < Math.Min (frame.Right - borderThickness.Right, driver.Cols); c++) {
-
-					AddRuneAt (driver, c, r, ' ');
-				}
-			}
-
-			driver.SetAttribute (savedAttribute);
-
-			// Draw the MarginFrame
-			if (DrawMarginFrame) {
-				var rect = new Rect () {
-					X = frame.X + sumThickness.Left,
-					Y = frame.Y + sumThickness.Top,
-					Width = Math.Max (frame.Width - sumThickness.Right - sumThickness.Left, 0),
-					Height = Math.Max (frame.Height - sumThickness.Bottom - sumThickness.Top, 0)
-				};
-				if (rect.Width > 0 && rect.Height > 0) {
-					driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
-					DrawTitle (Parent);
-				}
-			}
-
-			if (Effect3D) {
-				driver.SetAttribute ((Attribute)Effect3DBrush);
-
-				// Draw the upper Effect3D
-				for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
-					r < frame.Y; r++) {
-					for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
-						c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the left Effect3D
-				for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
-					r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
-						c < frame.X; c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the right Effect3D
-				for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
-					r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = frame.Right;
-						c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-
-				// Draw the lower Effect3D
-				for (int r = frame.Bottom;
-					r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
-					for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
-						c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
-
-						AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
-					}
-				}
-			}
-			driver.SetAttribute (savedAttribute);
-		}
-
-		private void AddRuneAt (ConsoleDriver driver, int col, int row, Rune ch)
-		{
-			if (col < driver.Cols && row < driver.Rows && col > 0 && driver.Contents [row, col, 2] == 0
-				&& Rune.ColumnWidth ((char)driver.Contents [row, col - 1, 0]) > 1) {
-
-				driver.Contents [row, col, 1] = driver.GetAttribute ();
-				return;
-			}
-			driver.Move (col, row);
-			driver.AddRune (ch);
-		}
-
-		/// <summary>
-		/// Draws the view <see cref="Title"/> to the screen.
-		/// </summary>
-		/// <param name="view">The view.</param>
-		public void DrawTitle (View view)
-		{
-			var driver = Application.Driver;
-			if (DrawMarginFrame) {
-				driver.SetAttribute (Child.GetNormalColor ());
-				if (Child.HasFocus)
-					driver.SetAttribute (Child.ColorScheme.HotNormal);
-				var padding = view.Border.GetSumThickness ();
-				Rect scrRect;
-				if (view == Child) {
-					scrRect = view.ViewToScreen (new Rect (0, 0, view.Frame.Width + 2, view.Frame.Height + 2));
-					scrRect = new Rect (scrRect.X - 1, scrRect.Y - 1, scrRect.Width, scrRect.Height);
-					driver.DrawWindowTitle (scrRect, Title, 0, 0, 0, 0);
-				} else {
-					scrRect = view.ViewToScreen (new Rect (0, 0, view.Frame.Width, view.Frame.Height));
-					driver.DrawWindowTitle (scrRect, Title,
-						padding.Left, padding.Top, padding.Right, padding.Bottom);
-				}
-			}
-			driver.SetAttribute (Child.GetNormalColor ());
-		}
-
-		/// <summary>
-		/// Draws the <see cref="View.Text"/> to the screen.
-		/// </summary>
-		/// <param name="view">The view.</param>
-		/// <param name="rect">The frame.</param>
-		public void DrawTitle (View view, Rect rect)
-		{
-			var driver = Application.Driver;
-			if (DrawMarginFrame) {
-				driver.SetAttribute (view.GetNormalColor ());
-				if (view.HasFocus) {
-					driver.SetAttribute (view.ColorScheme.HotNormal);
-				}
-				var padding = Parent.Border.GetSumThickness ();
-				var scrRect = Parent.ViewToScreen (new Rect (0, 0, rect.Width, rect.Height));
-				driver.DrawWindowTitle (scrRect, view.Text,
-					padding.Left, padding.Top, padding.Right, padding.Bottom);
-			}
-			driver.SetAttribute (view.GetNormalColor ());
-		}
+		///// <summary>
+		///// The title to be displayed for this view.
+		///// </summary>
+		//[JsonIgnore]
+		//public ustring Title {
+		//	get => title;
+		//	set {
+		//		title = value;
+		//		OnBorderChanged ();
+		//	}
+		//}
+
+		///// <summary>
+		///// Calculate the sum of the <see cref="Padding"/> and the <see cref="BorderThickness"/>
+		///// </summary>
+		///// <returns>The total of the <see cref="Border"/> <see cref="Thickness"/></returns>
+		//public Thickness GetSumThickness ()
+		//{
+		//	return new Thickness () {
+		//		Left = Padding.Left + BorderThickness.Left,
+		//		Top = Padding.Top + BorderThickness.Top,
+		//		Right = Padding.Right + BorderThickness.Right,
+		//		Bottom = Padding.Bottom + BorderThickness.Bottom
+		//	};
+		//}
+
+		///// <summary>
+		///// Drawn the <see cref="BorderThickness"/> more the <see cref="Padding"/>
+		/////  more the <see cref="Border.BorderStyle"/> and the <see cref="Effect3D"/>.
+		///// </summary>
+		///// <param name="view">The view to draw.</param>
+		///// <param name="fill">If it will clear or not the content area.</param>
+		//public void DrawContent (View view = null, bool fill = true)
+		//{
+		//	if (Child == null) {
+		//		Child = view;
+		//	}
+		//	if (Parent?.Border != null) {
+		//		DrawParentBorder (Parent.ViewToScreen (Parent.Bounds), fill);
+		//	} else {
+		//		DrawChildBorder (Child.ViewToScreen (Child.Bounds), fill);
+		//	}
+		//}
+
+		///// <summary>
+		///// Same as <see cref="DrawContent"/> but drawing full frames for all borders.
+		///// </summary>
+		//public void DrawFullContent ()
+		//{
+		//	var borderThickness = BorderThickness;
+		//	var padding = Padding;
+		//	var marginFrame = DrawMarginFrame ? 1 : 0;
+		//	var driver = Application.Driver;
+		//	Rect scrRect;
+		//	if (Parent?.Border != null) {
+		//		scrRect = Parent.ViewToScreen (Parent.Bounds);
+		//	} else {
+		//		scrRect = Child.ViewToScreen (Child.Bounds);
+		//	}
+		//	Rect borderRect;
+		//	if (Parent?.Border != null) {
+		//		borderRect = scrRect;
+		//	} else {
+		//		borderRect = new Rect () {
+		//			X = scrRect.X - marginFrame - padding.Left - borderThickness.Left,
+		//			Y = scrRect.Y - marginFrame - padding.Top - borderThickness.Top,
+		//			Width = ActualWidth,
+		//			Height = ActualHeight
+		//		};
+		//	}
+		//	var savedAttribute = driver.GetAttribute ();
+
+		//	// Draw 3D effects
+		//	if (Effect3D) {
+		//		driver.SetAttribute ((Attribute)Effect3DBrush);
+
+		//		var effectBorder = new Rect () {
+		//			X = borderRect.X + Effect3DOffset.X,
+		//			Y = borderRect.Y + Effect3DOffset.Y,
+		//			Width = ActualWidth,
+		//			Height = ActualHeight
+		//		};
+		//		//Child.Clear (effectBorder);
+		//		for (int r = effectBorder.Y; r < Math.Min (effectBorder.Bottom, driver.Rows); r++) {
+		//			for (int c = effectBorder.X; c < Math.Min (effectBorder.Right, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+		//	}
+
+		//	// Draw border thickness
+		//	driver.SetAttribute (new Attribute (BorderBrush));
+		//	Child.Clear (borderRect);
+
+		//	borderRect = new Rect () {
+		//		X = borderRect.X + borderThickness.Left,
+		//		Y = borderRect.Y + borderThickness.Top,
+		//		Width = Math.Max (borderRect.Width - borderThickness.Right - borderThickness.Left, 0),
+		//		Height = Math.Max (borderRect.Height - borderThickness.Bottom - borderThickness.Top, 0)
+		//	};
+		//	if (borderRect != scrRect) {
+		//		// Draw padding
+		//		driver.SetAttribute (new Attribute (Background));
+		//		Child.Clear (borderRect);
+		//	}
+
+		//	driver.SetAttribute (savedAttribute);
+
+		//	// Draw margin frame
+		//	if (DrawMarginFrame) {
+		//		if (Parent?.Border != null) {
+		//			var sumPadding = GetSumThickness ();
+		//			borderRect = new Rect () {
+		//				X = scrRect.X + sumPadding.Left,
+		//				Y = scrRect.Y + sumPadding.Top,
+		//				Width = Math.Max (scrRect.Width - sumPadding.Right - sumPadding.Left, 0),
+		//				Height = Math.Max (scrRect.Height - sumPadding.Bottom - sumPadding.Top, 0)
+		//			};
+		//		} else {
+		//			borderRect = new Rect () {
+		//				X = borderRect.X + padding.Left,
+		//				Y = borderRect.Y + padding.Top,
+		//				Width = Math.Max (borderRect.Width - padding.Right - padding.Left, 0),
+		//				Height = Math.Max (borderRect.Height - padding.Bottom - padding.Top, 0)
+		//			};
+		//		}
+		//		if (borderRect.Width > 0 && borderRect.Height > 0) {
+		//			driver.DrawWindowFrame (borderRect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill: true, this);
+		//		}
+		//	}
+		//}
+
+		//private void DrawChildBorder (Rect frame, bool fill = true)
+		//{
+		//	var drawMarginFrame = DrawMarginFrame ? 1 : 0;
+		//	var sumThickness = GetSumThickness ();
+		//	var padding = Padding;
+		//	var effect3DOffset = Effect3DOffset;
+		//	var driver = Application.Driver;
+
+		//	var savedAttribute = driver.GetAttribute ();
+
+		//	driver.SetAttribute (new Attribute (BorderBrush));
+
+		//	// Draw the upper BorderThickness
+		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
+		//		r < frame.Y - drawMarginFrame - padding.Top; r++) {
+		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
+		//			c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the left BorderThickness
+		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
+		//			c < frame.X - drawMarginFrame - padding.Left; c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the right BorderThickness
+		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.Right + drawMarginFrame + padding.Right;
+		//			c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the lower BorderThickness
+		//	for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
+		//			c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	driver.SetAttribute (new Attribute (Background));
+
+		//	// Draw the upper Padding
+		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
+		//		r < frame.Y - drawMarginFrame; r++) {
+		//		for (int c = frame.X - drawMarginFrame - padding.Left;
+		//			c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the left Padding
+		//	for (int r = frame.Y - drawMarginFrame;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame, driver.Rows); r++) {
+		//		for (int c = frame.X - drawMarginFrame - padding.Left;
+		//			c < frame.X - drawMarginFrame; c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the right Padding
+		//	for (int r = frame.Y - drawMarginFrame;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame, driver.Rows); r++) {
+		//		for (int c = frame.Right + drawMarginFrame;
+		//			c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the lower Padding
+		//	for (int r = frame.Bottom + drawMarginFrame;
+		//		r < Math.Min (frame.Bottom + drawMarginFrame + padding.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X - drawMarginFrame - padding.Left;
+		//			c < Math.Min (frame.Right + drawMarginFrame + padding.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	driver.SetAttribute (savedAttribute);
+
+		//	// Draw the MarginFrame
+		//	if (DrawMarginFrame) {
+
+		//		var rect = new Rect () {
+		//			X = frame.X - drawMarginFrame,
+		//			Y = frame.Y - drawMarginFrame,
+		//			Width = frame.Width + (2 * drawMarginFrame),
+		//			Height = frame.Height + (2 * drawMarginFrame)
+		//		};
+		//		if (rect.Width > 0 && rect.Height > 0) {
+		//			driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
+		//			DrawTitle (Child);
+		//		}
+
+		//		//var rect = Child.ViewToScreen (new Rect (-1, -1, Child.Frame.Width + 2, Child.Frame.Height + 2));
+		//		//if (rect.Width > 0 && rect.Height > 0) {
+
+		//		//	var lc = new LineCanvas ();
+
+		//		//	lc.AddLine (rect.Location, rect.Width-1, Orientation.Horizontal, BorderStyle);
+		//		//	lc.AddLine (rect.Location, rect.Height-1, Orientation.Vertical, BorderStyle);
+
+		//		//	lc.AddLine (new Point (rect.X, rect.Y + rect.Height-1), rect.Width, Orientation.Horizontal, BorderStyle);
+		//		//	lc.AddLine (new Point (rect.X + rect.Width-1, rect.Y), rect.Height, Orientation.Vertical, BorderStyle);
+
+		//		//	//driver.SetAttribute (new Attribute(Color.Red, Color.BrightYellow));
+		//		//	foreach (var p in lc.GenerateImage (rect)) {
+		//		//		AddRuneAt (driver, p.Key.X, p.Key.Y, p.Value);
+		//		//	}
+		//		//	DrawTitle (Child);
+		//		//}
+		//	}
+
+		//	if (Effect3D) {
+		//		driver.SetAttribute ((Attribute)Effect3DBrush);
+
+		//		// Draw the upper Effect3D
+		//		for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
+		//			r >= 0 && r < frame.Y - drawMarginFrame - sumThickness.Top; r++) {
+		//			for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
+		//				c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the left Effect3D
+		//		for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
+		//			r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
+		//				c >= 0 && c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the right Effect3D
+		//		for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
+		//			r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
+		//				c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the lower Effect3D
+		//		for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
+		//			r >= 0 && r < Math.Min (frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
+		//				c >= 0 && c < Math.Min (frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+		//	}
+		//	driver.SetAttribute (savedAttribute);
+		//}
+
+		//private void DrawParentBorder (Rect frame, bool fill = true)
+		//{
+		//	var sumThickness = GetSumThickness ();
+		//	var borderThickness = BorderThickness;
+		//	var effect3DOffset = Effect3DOffset;
+		//	var driver = Application.Driver;
+
+		//	var savedAttribute = driver.GetAttribute ();
+
+		//	driver.SetAttribute (new Attribute (BorderBrush));
+
+		//	// Draw the upper BorderThickness
+		//	for (int r = frame.Y;
+		//		r < Math.Min (frame.Y + borderThickness.Top, frame.Bottom); r++) {
+		//		for (int c = frame.X;
+		//			c < Math.Min (frame.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the left BorderThickness
+		//	for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
+		//		r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X;
+		//			c < Math.Min (frame.X + borderThickness.Left, frame.Right); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the right BorderThickness
+		//	for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
+		//		r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = Math.Max (frame.Right - borderThickness.Right, frame.X);
+		//			c < Math.Min (frame.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the lower BorderThickness
+		//	for (int r = Math.Max (frame.Bottom - borderThickness.Bottom, frame.Y);
+		//		r < Math.Min (frame.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X;
+		//			c < Math.Min (frame.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	driver.SetAttribute (new Attribute (Background));
+
+		//	// Draw the upper Padding
+		//	for (int r = frame.Y + borderThickness.Top;
+		//		r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
+		//		for (int c = frame.X + borderThickness.Left;
+		//			c < Math.Min (frame.Right - borderThickness.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the left Padding
+		//	for (int r = frame.Y + sumThickness.Top;
+		//		r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X + borderThickness.Left;
+		//			c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the right Padding
+		//	for (int r = frame.Y + sumThickness.Top;
+		//		r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
+		//			c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	// Draw the lower Padding
+		//	for (int r = Math.Max (frame.Bottom - sumThickness.Bottom, frame.Y + borderThickness.Top);
+		//		r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
+		//		for (int c = frame.X + borderThickness.Left;
+		//			c < Math.Min (frame.Right - borderThickness.Right, driver.Cols); c++) {
+
+		//			AddRuneAt (driver, c, r, ' ');
+		//		}
+		//	}
+
+		//	driver.SetAttribute (savedAttribute);
+
+		//	// Draw the MarginFrame
+		//	if (DrawMarginFrame) {
+		//		var rect = new Rect () {
+		//			X = frame.X + sumThickness.Left,
+		//			Y = frame.Y + sumThickness.Top,
+		//			Width = Math.Max (frame.Width - sumThickness.Right - sumThickness.Left, 0),
+		//			Height = Math.Max (frame.Height - sumThickness.Bottom - sumThickness.Top, 0)
+		//		};
+		//		if (rect.Width > 0 && rect.Height > 0) {
+		//			driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
+		//			DrawTitle (Parent);
+		//		}
+		//	}
+
+		//	if (Effect3D) {
+		//		driver.SetAttribute ((Attribute)Effect3DBrush);
+
+		//		// Draw the upper Effect3D
+		//		for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
+		//			r < frame.Y; r++) {
+		//			for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
+		//				c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the left Effect3D
+		//		for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
+		//			r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
+		//				c < frame.X; c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the right Effect3D
+		//		for (int r = Math.Max (frame.Y + effect3DOffset.Y, 0);
+		//			r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = frame.Right;
+		//				c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+
+		//		// Draw the lower Effect3D
+		//		for (int r = frame.Bottom;
+		//			r < Math.Min (frame.Bottom + effect3DOffset.Y, driver.Rows); r++) {
+		//			for (int c = Math.Max (frame.X + effect3DOffset.X, 0);
+		//				c < Math.Min (frame.Right + effect3DOffset.X, driver.Cols); c++) {
+
+		//				AddRuneAt (driver, c, r, (Rune)driver.Contents [r, c, 0]);
+		//			}
+		//		}
+		//	}
+		//	driver.SetAttribute (savedAttribute);
+		//}
+
+		//private void AddRuneAt (ConsoleDriver driver, int col, int row, Rune ch)
+		//{
+		//	if (col < driver.Cols && row < driver.Rows && col > 0 && driver.Contents [row, col, 2] == 0
+		//		&& Rune.ColumnWidth ((char)driver.Contents [row, col - 1, 0]) > 1) {
+
+		//		driver.Contents [row, col, 1] = driver.GetAttribute ();
+		//		return;
+		//	}
+		//	driver.Move (col, row);
+		//	driver.AddRune (ch);
+		//}
+
+		///// <summary>
+		///// Draws the view <see cref="Title"/> to the screen.
+		///// </summary>
+		///// <param name="view">The view.</param>
+		//public void DrawTitle (View view)
+		//{
+		//	var driver = Application.Driver;
+		//	if (DrawMarginFrame) {
+		//		driver.SetAttribute (Child.GetNormalColor ());
+		//		if (Child.HasFocus)
+		//			driver.SetAttribute (Child.ColorScheme.HotNormal);
+		//		var padding = view.Border.GetSumThickness ();
+		//		Rect scrRect;
+		//		if (view == Child) {
+		//			scrRect = view.ViewToScreen (new Rect (0, 0, view.Frame.Width + 2, view.Frame.Height + 2));
+		//			scrRect = new Rect (scrRect.X - 1, scrRect.Y - 1, scrRect.Width, scrRect.Height);
+		//			driver.DrawWindowTitle (scrRect, Title, 0, 0, 0, 0);
+		//		} else {
+		//			scrRect = view.ViewToScreen (new Rect (0, 0, view.Frame.Width, view.Frame.Height));
+		//			driver.DrawWindowTitle (scrRect, Title,
+		//				padding.Left, padding.Top, padding.Right, padding.Bottom);
+		//		}
+		//	}
+		//	driver.SetAttribute (Child.GetNormalColor ());
+		//}
+
+		///// <summary>
+		///// Draws the <see cref="View.Text"/> to the screen.
+		///// </summary>
+		///// <param name="view">The view.</param>
+		///// <param name="rect">The frame.</param>
+		//public void DrawTitle (View view, Rect rect)
+		//{
+		//	var driver = Application.Driver;
+		//	if (DrawMarginFrame) {
+		//		driver.SetAttribute (view.GetNormalColor ());
+		//		if (view.HasFocus) {
+		//			driver.SetAttribute (view.ColorScheme.HotNormal);
+		//		}
+		//		var padding = Parent.Border.GetSumThickness ();
+		//		var scrRect = Parent.ViewToScreen (new Rect (0, 0, rect.Width, rect.Height));
+		//		driver.DrawWindowTitle (scrRect, view.Text,
+		//			padding.Left, padding.Top, padding.Right, padding.Bottom);
+		//	}
+		//	driver.SetAttribute (view.GetNormalColor ());
+		//}
 
 		/// <summary>
 		/// Invoke the <see cref="BorderChanged"/> event.

+ 10 - 22
Terminal.Gui/Core/Container.cs

@@ -7,8 +7,7 @@ using Terminal.Gui.Graphs;
 
 namespace Terminal.Gui {
 
-	public class Container : View
-	{
+	public class Container : View {
 		public Container ()
 		{
 			IgnoreBorderPropertyOnRedraw = true;
@@ -86,21 +85,7 @@ namespace Terminal.Gui {
 		public Label DiagnosticsLabel { get; set; }
 		public BorderStyle BorderStyle { get; set; } = BorderStyle.None;
 
-		public Frame ()
-		{
-			IgnoreBorderPropertyOnRedraw = true;
-
-			DiagnosticsLabel = new Label () {
-				AutoSize = false,
-				X = 0,
-				Y = Pos.AnchorEnd (1),
-				Width = Dim.Fill (),
-				TextAlignment = TextAlignment.Centered
-
-			};
-			Add (DiagnosticsLabel);
-			SetNeedsLayout ();
-		}
+		public Frame () => IgnoreBorderPropertyOnRedraw = true;
 		
 		public Thickness Thickness { get; set; }
 
@@ -132,9 +117,9 @@ namespace Terminal.Gui {
 				Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
 			}
 
-			if (Text != null) {
-				Thickness?.Draw (Frame, $"{Text} {DiagnosticsLabel?.Text}");
-			}
+			//if (Text != null) {
+			//	Thickness?.Draw (Frame, $"{Text} {DiagnosticsLabel?.Text}");
+			//}
 			if (BorderStyle != BorderStyle.None) {
 				var lc = new LineCanvas ();
 				lc.AddLine (Frame.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
@@ -142,11 +127,14 @@ namespace Terminal.Gui {
 
 				lc.AddLine (new Point (Frame.X, Frame.Y + Frame.Height - 1), Frame.Width - 1, Orientation.Horizontal, BorderStyle);
 				lc.AddLine (new Point (Frame.X + Frame.Width - 1, Frame.Y), Frame.Height - 1, Orientation.Vertical, BorderStyle);
-				foreach (var p in lc.GenerateImage(Frame)) {
+				foreach (var p in lc.GenerateImage (Frame)) {
 					Driver.Move (p.Key.X, p.Key.Y);
 					Driver.AddRune (p.Value);
 				}
-				Driver.DrawWindowTitle (Frame, $"{Text} {Thickness}", 0, 0, 0, 0);
+
+				if (!ustring.IsNullOrEmpty (Title)) {
+					Driver.DrawWindowTitle (Frame, Title, 0, 0, 0, 0);
+				}
 			}
 
 			base.Redraw (bounds);

+ 26 - 21
Terminal.Gui/Core/View.cs

@@ -458,28 +458,32 @@ namespace Terminal.Gui {
 		public Frame Margin { get; set; }
 		public Frame BorderFrame { get; set; }
 		public Frame Padding { get; set; }
+
 		/// <summary>
 		/// Temporary API to support the new v2 API
 		/// </summary>
 		public void EnableFrames ()
 		{
 			IgnoreBorderPropertyOnRedraw = true;
+			Margin?.Dispose ();
 			Margin = new Frame () {
-				Text = "Margin",
+				Data = "Margin",
 				Thickness = new Thickness (0),
 				ColorScheme = Colors.ColorSchemes ["Error"]
 			};
 			//Margin.DiagnosticsLabel.Text = "Margin";
 
+			BorderFrame?.Dispose ();
 			BorderFrame = new Frame () {
-				Text = "BorderFrame",
+				Data = "BorderFrame",
 				BorderStyle = BorderStyle.Single,
-				Thickness = new Thickness (1),
-				ColorScheme = Colors.ColorSchemes ["Dialog"]
+				Thickness = new Thickness (0),
+				ColorScheme = ColorScheme
 			};
 
+			Padding?.Dispose ();
 			Padding = new Frame () {
-				Text = "Padding",
+				Data = "Padding",
 				Thickness = new Thickness (0),
 				ColorScheme = Colors.ColorSchemes ["Toplevel"]
 			};
@@ -544,9 +548,6 @@ namespace Terminal.Gui {
 			set {
 				Debug.WriteLine ($"It makes no sense to set Bounds. Use Frame instead. Bounds: {value}");
 				Frame = new Rect (Frame.Location, value.Size);
-				//	+ new Size (Margin.Thickness.Right, Margin.Thickness.Bottom)
-				//	+ new Size (BorderFrame.Thickness.Right, BorderFrame.Thickness.Bottom)
-				//	+ new Size (BorderFrame.Thickness.Right, BorderFrame.Thickness.Bottom));
 			}
 		}
 
@@ -832,9 +833,6 @@ namespace Terminal.Gui {
 			TextFormatter.HotKeyChanged += TextFormatter_HotKeyChanged;
 			TextDirection = direction;
 			Border = border;
-			if (Border != null) {
-				Border.Child = this;
-			}
 			shortcutHelper = new ShortcutHelper ();
 			CanFocus = false;
 			TabIndex = -1;
@@ -1286,6 +1284,7 @@ namespace Terminal.Gui {
 		/// <param name="fill">If set to <see langword="true"/> it fill will the contents.</param>
 		public void DrawFrame (Rect region, int padding = 0, bool fill = false)
 		{
+			// TODO: Refactor to use Frames
 			var scrRect = ViewToScreen (region);
 			var savedClip = ClipToBounds ();
 			Driver.DrawWindowFrame (scrRect, padding + 1, padding + 1, padding + 1, padding + 1, border: true, fill: fill);
@@ -1548,6 +1547,7 @@ namespace Terminal.Gui {
 			}
 			
 			Margin.Redraw (Margin.Bounds);
+			BorderFrame.Title = Title;
 			BorderFrame.Redraw (BorderFrame.Bounds);
 			Padding.Redraw (BorderFrame.Bounds);
 
@@ -1555,13 +1555,13 @@ namespace Terminal.Gui {
 			var padding = BorderFrame.Thickness.GetInnerRect (border);
 			var content = Padding.Thickness.GetInnerRect (padding);
 
-			// Draw the diagnostics label on the bottom of the content
-			var tf = new TextFormatter () {
-				Text = $"Content {Bounds}",
-				Alignment = TextAlignment.Centered,
-				VerticalAlignment = VerticalTextAlignment.Bottom
-			};
-			tf.Draw (content, ColorScheme.Normal, ColorScheme.Normal);
+			//// Draw the diagnostics label on the bottom of the content
+			//var tf = new TextFormatter () {
+			//	Text = $"Content {Bounds}",
+			//	Alignment = TextAlignment.Centered,
+			//	VerticalAlignment = VerticalTextAlignment.Bottom
+			//};
+			//tf.Draw (content, ColorScheme.Normal, ColorScheme.Normal);
 
 			return true;
 		}
@@ -1583,7 +1583,6 @@ namespace Terminal.Gui {
 		///    larger than the <ref name="bounds"/> parameter, as this will cause the driver to clip the entire region.
 		/// </para>
 		/// </remarks>
-
 		public virtual void Redraw (Rect bounds)
 		{
 			if (!CanBeVisible (this)) {
@@ -1601,8 +1600,9 @@ namespace Terminal.Gui {
 
 			var boundsAdjustedForBorder = Bounds;
 			if (!IgnoreBorderPropertyOnRedraw && Border != null) {
-				Border.DrawContent (this);
-				boundsAdjustedForBorder = new Rect (bounds.X + 1, bounds.Y + 1, Math.Max (0, bounds.Width - 2), Math.Max (0, bounds.Height - 2));
+				throw new InvalidOperationException ("Don't use Border!");
+				//Border.DrawContent (this);
+				//boundsAdjustedForBorder = new Rect (bounds.X + 1, bounds.Y + 1, Math.Max (0, bounds.Width - 2), Math.Max (0, bounds.Height - 2));
 			} else if (ustring.IsNullOrEmpty (TextFormatter.Text) &&
 				(GetType ().IsNestedPublic) && !IsOverridden (this, "Redraw") &&
 				(!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) {
@@ -2883,6 +2883,11 @@ namespace Terminal.Gui {
 			set {
 				if (border != value) {
 					border = value;
+					EnableFrames ();
+					Margin.Thickness = border.BorderThickness;
+					BorderFrame.Thickness = new Thickness (border.BorderStyle != BorderStyle.None ? 1 : 0);
+					BorderFrame.BorderStyle = border.BorderStyle;
+					Padding.Thickness = border.Padding;
 					SetNeedsDisplay ();
 				}
 			}

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

@@ -25,91 +25,6 @@ namespace Terminal.Gui {
 	/// API to determine this rectangle.
 	/// </remarks>
 	public class Window : Toplevel {
-		View contentView;
-		ustring title = ustring.Empty;
-
-		/// <summary>
-		/// The title to be displayed for this window.
-		/// </summary>
-		/// <value>The title</value>
-		public ustring Title {
-			get => title;
-			set {
-				if (!OnTitleChanging (title, value)) {
-					var old = title;
-					title = value;
-					OnTitleChanged (old, title);
-				}
-				SetNeedsDisplay ();
-			}
-		}
-
-		/// <inheritdoc/>
-		public override Border Border {
-			get => base.Border;
-			set {
-				if (base.Border != null && base.Border.Child != null && value.Child == null) {
-					value.Child = base.Border.Child;
-				}
-				base.Border = value;
-				if (value == null) {
-					return;
-				}
-				Rect frame;
-				if (contentView != null && (contentView.Width is Dim || contentView.Height is Dim)) {
-					frame = Rect.Empty;
-				} else {
-					frame = Frame;
-				}
-				AdjustContentView (frame);
-
-				Border.BorderChanged += Border_BorderChanged;
-			}
-		}
-
-		void Border_BorderChanged (Border border)
-		{
-			Rect frame;
-			if (contentView != null && (contentView.Width is Dim || contentView.Height is Dim)) {
-				frame = Rect.Empty;
-			} else {
-				frame = Frame;
-			}
-			AdjustContentView (frame);
-		}
-
-		/// <summary>
-		/// ContentView is an internal implementation detail of Window. It is used to host Views added with <see cref="Add(View)"/>. 
-		/// Its ONLY reason for being is to provide a simple way for Window to expose to those SubViews that the Window's Bounds 
-		/// are actually deflated due to the border. 
-		/// </summary>
-		class ContentView : View {
-			Window instance;
-
-			public ContentView (Rect frame, Window instance) : base (frame)
-			{
-				this.instance = instance;
-			}
-			public ContentView (Window instance) : base ()
-			{
-				this.instance = instance;
-			}
-
-			public override void OnCanFocusChanged ()
-			{
-				if (MostFocused == null && CanFocus && Visible) {
-					EnsureFocus ();
-				}
-
-				base.OnCanFocusChanged ();
-			}
-
-			public override bool OnMouseEvent (MouseEvent mouseEvent)
-			{
-				return instance.OnMouseEvent (mouseEvent);
-			}
-		}
-
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Gui.Window"/> class with an optional title using <see cref="LayoutStyle.Absolute"/> positioning.
 		/// </summary>
@@ -197,61 +112,12 @@ namespace Terminal.Gui {
 			} else {
 				Border = border;
 			}
-			AdjustContentView (frame);
-		}
-
-		void AdjustContentView (Rect frame)
-		{
-			var borderLength = Border.DrawMarginFrame ? 1 : 0;
-			var sumPadding = Border.GetSumThickness ();
-			var wp = new Point ();
-			var wb = new Size ();
-			if (frame == Rect.Empty) {
-				wp.X = borderLength + sumPadding.Left;
-				wp.Y = borderLength + sumPadding.Top;
-				wb.Width = borderLength + sumPadding.Right;
-				wb.Height = borderLength + sumPadding.Bottom;
-				if (contentView == null) {
-					contentView = new ContentView (this) {
-						X = wp.X,
-						Y = wp.Y,
-						Width = Dim.Fill (wb.Width),
-						Height = Dim.Fill (wb.Height)
-					};
-				} else {
-					contentView.X = wp.X;
-					contentView.Y = wp.Y;
-					contentView.Width = Dim.Fill (wb.Width);
-					contentView.Height = Dim.Fill (wb.Height);
-				}
-			} else {
-				wb.Width = (2 * borderLength) + sumPadding.Right + sumPadding.Left;
-				wb.Height = (2 * borderLength) + sumPadding.Bottom + sumPadding.Top;
-				var cFrame = new Rect (borderLength + sumPadding.Left, borderLength + sumPadding.Top, frame.Width - wb.Width, frame.Height - wb.Height);
-				if (contentView == null) {
-					contentView = new ContentView (cFrame, this);
-				} else {
-					contentView.Frame = cFrame;
-				}
-			}
-			if (Subviews?.Count == 0)
-				base.Add (contentView);
-			Border.Child = contentView;
 		}
 
-		///// <summary>
-		///// Enumerates the various <see cref="View"/>s in the embedded <see cref="ContentView"/>.
-		///// </summary>
-		///// <returns>The enumerator.</returns>
-		//public new IEnumerator GetEnumerator ()
-		//{
-		//	return contentView.GetEnumerator ();
-		//}
-
 		/// <inheritdoc/>
 		public override void Add (View view)
 		{
-			contentView.Add (view);
+			base.Add (view);
 			if (view.CanFocus) {
 				CanFocus = true;
 			}
@@ -267,86 +133,8 @@ namespace Terminal.Gui {
 			}
 
 			SetNeedsDisplay ();
-			contentView.Remove (view);
-
-			if (contentView.InternalSubviews.Count < 1) {
-				CanFocus = false;
-			}
+			base.Remove (view);
 			RemoveMenuStatusBar (view);
-			if (view != contentView && Focused == null) {
-				FocusFirst ();
-			}
-		}
-
-		/// <inheritdoc/>
-		public override void RemoveAll ()
-		{
-			contentView.RemoveAll ();
-		}
-
-		///<inheritdoc/>
-		public override void Redraw (Rect bounds)
-		{
-			var padding = Border.GetSumThickness ();
-			var scrRect = ViewToScreen (new Rect (0, 0, Frame.Width, Frame.Height));
-
-			if (!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded) {
-				Driver.SetAttribute (GetNormalColor ());
-				Clear ();
-				contentView.SetNeedsDisplay ();
-			}
-			var savedClip = contentView.ClipToBounds ();
-
-			// Redraw our contentView
-			// DONE: smartly constrict contentView.Bounds to just be what intersects with the 'bounds' we were passed
-			contentView.Redraw (!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded ? contentView.Bounds : bounds);
-			Driver.Clip = savedClip;
-
-			ClearLayoutNeeded ();
-			ClearNeedsDisplay ();
-
-			Driver.SetAttribute (GetNormalColor ());
-			//Driver.DrawWindowFrame (scrRect, padding.Left + borderLength, padding.Top + borderLength, padding.Right + borderLength, padding.Bottom + borderLength,
-			//	Border.BorderStyle != BorderStyle.None, fill: true, Border.BorderStyle);
-			Border.DrawContent (this, false);
-			if (HasFocus)
-				Driver.SetAttribute (ColorScheme.HotNormal);
-			if (Border.DrawMarginFrame)
-				Driver.DrawWindowTitle (scrRect, Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
-			Driver.SetAttribute (GetNormalColor ());
-		}
-
-		/// <inheritdoc/>
-		public override void OnCanFocusChanged ()
-		{
-			if (contentView != null) {
-				contentView.CanFocus = CanFocus;
-			}
-			base.OnCanFocusChanged ();
-		}
-
-		/// <summary>
-		///   The text displayed by the <see cref="Label"/>.
-		/// </summary>
-		public override ustring Text {
-			get => contentView?.Text;
-			set {
-				base.Text = value;
-				if (contentView != null) {
-					contentView.Text = value;
-				}
-			}
-		}
-
-		/// <summary>
-		/// Controls the text-alignment property of the label, changing it will redisplay the <see cref="Label"/>.
-		/// </summary>
-		/// <value>The text alignment.</value>
-		public override TextAlignment TextAlignment {
-			get => contentView.TextAlignment;
-			set {
-				base.TextAlignment = contentView.TextAlignment = value;
-			}
 		}
 
 		/// <summary>

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

@@ -1,19 +1,6 @@
-//
-// 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 NStack;
-using Terminal.Gui.Graphs;
 using static Terminal.Gui.Configuration.ConfigurationManager;
 
 namespace Terminal.Gui {
@@ -24,97 +11,6 @@ namespace Terminal.Gui {
 	/// </summary>
 	public class FrameView : View {
 
-		//internal class FrameViewConfig : Configuration.Config<FrameViewConfig> {
-
-		//	/// <summary>
-		//	/// 
-		//	/// </summary>
-		//	/// 
-		//	[JsonConverter (typeof (JsonStringEnumConverter))]
-		//	public BorderStyle? DefaultBorderStyle { get; set; }
-
-		//	public override void Apply ()
-		//	{
-		//		if (DefaultBorderStyle.HasValue) {
-		//			FrameView.DefaultBorderStyle = DefaultBorderStyle.Value;
-		//		}
-		//	}
-
-		//	public override void CopyUpdatedProperitesFrom (FrameViewConfig changedConfig)
-		//	{
-		//		if (changedConfig.DefaultBorderStyle.HasValue) {
-		//			DefaultBorderStyle = changedConfig.DefaultBorderStyle;
-		//		}
-		//	}
-
-		//	public override void GetHardCodedDefaults ()
-		//	{
-		//		DefaultBorderStyle = FrameView.DefaultBorderStyle;
-		//	}
-		//}
-
-		//[Configuration.ConfigProperty]
-		//internal static FrameViewConfig Config { get; set; } = new FrameViewConfig ();
-
-		View contentView;
-		ustring title;
-
-		/// <summary>
-		/// The title to be displayed for this <see cref="FrameView"/>.
-		/// </summary>
-		/// <value>The title.</value>
-		public ustring Title {
-			get => title;
-			set {
-				title = value;
-				SetNeedsDisplay ();
-			}
-		}
-
-		/// <inheritdoc/>
-		public override Border Border {
-			get => base.Border;
-			set {
-				if (base.Border != null && base.Border.Child != null && value.Child == null) {
-					value.Child = base.Border.Child;
-				}
-				base.Border = value;
-				if (value == null) {
-					return;
-				}
-				Rect frame;
-				if (contentView != null && (contentView.Width is Dim || contentView.Height is Dim)) {
-					frame = Rect.Empty;
-				} else {
-					frame = Frame;
-				}
-				AdjustContentView (frame);
-
-				Border.BorderChanged += Border_BorderChanged;
-			}
-		}
-
-		void Border_BorderChanged (Border border)
-		{
-			Rect frame;
-			if (contentView != null && (contentView.Width is Dim || contentView.Height is Dim)) {
-				frame = Rect.Empty;
-			} else {
-				frame = Frame;
-			}
-			AdjustContentView (frame);
-		}
-
-		/// <summary>
-		/// ContentView is an internal implementation detail of Window. It is used to host Views added with <see cref="Add(View)"/>. 
-		/// Its ONLY reason for being is to provide a simple way for Window to expose to those SubViews that the Window's Bounds 
-		/// are actually deflated due to the border. 
-		/// </summary>
-		class ContentView : View {
-			public ContentView (Rect frame) : base (frame) { }
-			public ContentView () : base () { }
-		}
-
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Gui.FrameView"/> class using <see cref="LayoutStyle.Absolute"/> layout.
 		/// </summary>
@@ -124,8 +20,6 @@ namespace Terminal.Gui {
 		/// <param name="border">The <see cref="Border"/>.</param>
 		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);
 		}
 
@@ -164,195 +58,6 @@ namespace Terminal.Gui {
 			} else {
 				Border = border;
 			}
-			AdjustContentView (frame, views);
-		}
-
-		void AdjustContentView (Rect frame, View [] views = null)
-		{
-			var borderLength = Border.DrawMarginFrame ? 1 : 0;
-			var sumPadding = Border.GetSumThickness ();
-			var wp = new Point ();
-			var wb = new Size ();
-			if (frame == Rect.Empty) {
-				wp.X = borderLength + sumPadding.Left;
-				wp.Y = borderLength + sumPadding.Top;
-				wb.Width = borderLength + sumPadding.Right;
-				wb.Height = borderLength + sumPadding.Bottom;
-				if (contentView == null) {
-					contentView = new ContentView () {
-						X = wp.X,
-						Y = wp.Y,
-						Width = Dim.Fill (wb.Width),
-						Height = Dim.Fill (wb.Height)
-					};
-				} else {
-					contentView.X = wp.X;
-					contentView.Y = wp.Y;
-					contentView.Width = Dim.Fill (wb.Width);
-					contentView.Height = Dim.Fill (wb.Height);
-				}
-			} else {
-				wb.Width = (2 * borderLength) + sumPadding.Right + sumPadding.Left;
-				wb.Height = (2 * borderLength) + sumPadding.Bottom + sumPadding.Top;
-				var cFrame = new Rect (borderLength + sumPadding.Left, borderLength + sumPadding.Top, frame.Width - wb.Width, frame.Height - wb.Height);
-				if (contentView == null) {
-					contentView = new ContentView (cFrame);
-				} else {
-					contentView.Frame = cFrame;
-				}
-			}
-			if (views != null) {
-				foreach (var view in views) {
-					contentView.Add (view);
-				}
-			}
-			if (Subviews?.Count == 0) {
-				base.Add (contentView);
-				contentView.Text = base.Text;
-			}
-			Border.Child = contentView;
-		}
-
-		void DrawFrame ()
-		{
-			DrawFrame (new Rect (0, 0, Frame.Width, Frame.Height), 0, fill: true);
-		}
-
-		/// <summary>
-		/// Add the specified <see cref="View"/> to this container.
-		/// </summary>
-		/// <param name="view"><see cref="View"/> to add to this container</param>
-		public override void Add (View view)
-		{
-			contentView.Add (view);
-			if (view.CanFocus)
-				CanFocus = true;
-		}
-
-
-		/// <summary>
-		///   Removes a <see cref="View"/> from this container.
-		/// </summary>
-		/// <remarks>
-		/// </remarks>
-		public override void Remove (View view)
-		{
-			if (view == null)
-				return;
-
-			SetNeedsDisplay ();
-			var touched = view.Frame;
-			contentView.Remove (view);
-
-			if (contentView.InternalSubviews.Count < 1)
-				this.CanFocus = false;
-		}
-
-		/// <summary>
-		///   Removes all <see cref="View"/>s from this container.
-		/// </summary>
-		/// <remarks>
-		/// </remarks>
-		public override void RemoveAll ()
-		{
-			contentView.RemoveAll ();
-		}
-
-		///<inheritdoc/>
-		public override void Redraw (Rect bounds)
-		{
-			var padding = Border.GetSumThickness ();
-			var scrRect = ViewToScreen (new Rect (0, 0, Frame.Width, Frame.Height));
-
-			if (!NeedDisplay.IsEmpty) {
-				Driver.SetAttribute (GetNormalColor ());
-				//Driver.DrawWindowFrame (scrRect, padding + 1, padding + 1, padding + 1, padding + 1, border: true, fill: true);
-				Clear ();
-			}
-
-			var savedClip = contentView.ClipToBounds ();
-			contentView.Redraw (!NeedDisplay.IsEmpty ? contentView.Bounds : bounds);
-			Driver.Clip = savedClip;
-
-			ClearNeedsDisplay ();
-
-			if (!IgnoreBorderPropertyOnRedraw) {
-				Driver.SetAttribute (GetNormalColor ());
-				//Driver.DrawWindowFrame (scrRect, padding + 1, padding + 1, padding + 1, padding + 1, border: true, fill: false);
-				Border.DrawContent (this, false);
-				if (HasFocus)
-					Driver.SetAttribute (ColorScheme.HotNormal);
-				if (Border.DrawMarginFrame)
-					Driver.DrawWindowTitle (scrRect, Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
-				Driver.SetAttribute (GetNormalColor ());
-			} else {
-				var lc = new LineCanvas ();
-
-				if (Border?.BorderStyle != BorderStyle.None) {
-
-					lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, Border.BorderStyle);
-					lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, Border.BorderStyle);
-
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, Border.BorderStyle);
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, Border.BorderStyle);
-				}
-
-				//foreach (var subview in contentView.Subviews) {
-				//	lc.AddLine (new Point (subview.Frame.X + 1, subview.Frame.Y + 1), subview.Frame.Width - 1, Orientation.Horizontal, subview.Border.BorderStyle);
-				//	lc.AddLine (new Point (subview.Frame.X + 1, subview.Frame.Y + 1), subview.Frame.Height - 1, Orientation.Vertical, subview.Border.BorderStyle);
-
-				//	lc.AddLine (new Point (subview.Frame.X + subview.Frame.Width, subview.Frame.Y + subview.Frame.Height), -subview.Frame.Width + 1, Orientation.Horizontal, subview.Border.BorderStyle);
-				//	lc.AddLine (new Point (subview.Frame.X + subview.Frame.Width, subview.Frame.Y + subview.Frame.Height), -subview.Frame.Height + 1, Orientation.Vertical, subview.Border.BorderStyle);
-
-				//}
-
-				Driver.SetAttribute (ColorScheme.Normal);
-				foreach (var p in lc.GenerateImage (bounds)) {
-					this.AddRune (p.Key.X, p.Key.Y, p.Value);
-				}
-				
-				// Redraw the lines so that focus/drag symbol renders
-				foreach (var subview in contentView.Subviews) {
-					//	line.DrawSplitterSymbol ();
-				}
-
-
-				// Draw Titles over Border
-				foreach (var subview in contentView.Subviews) {
-					// TODO: Use reflection to see if subview has a Title property
-					if (subview is FrameView viewWithTite) {
-						var rect = viewWithTite.Frame;
-						rect.X = rect.X + 1;
-						rect.Y = rect.Y + 2;
-						// TODO: Do focus color correctly
-						Driver.DrawWindowTitle (rect, viewWithTite.Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
-					}
-				}
-			}
-		}
-
-		/// <summary>
-		///   The text displayed by the <see cref="Label"/>.
-		/// </summary>
-		public override ustring Text {
-			get => contentView?.Text;
-			set {
-				base.Text = value;
-				if (contentView != null) {
-					contentView.Text = value;
-				}
-			}
-		}
-
-		/// <summary>
-		/// Controls the text-alignment property of the label, changing it will redisplay the <see cref="Label"/>.
-		/// </summary>
-		/// <value>The text alignment.</value>
-		public override TextAlignment TextAlignment {
-			get => contentView.TextAlignment;
-			set {
-				base.TextAlignment = contentView.TextAlignment = value;
-			}
 		}
 
 		///<inheritdoc/>
@@ -364,14 +69,5 @@ namespace Terminal.Gui {
 
 			return base.OnEnter (view);
 		}
-
-		/// <inheritdoc/>
-		public override void OnCanFocusChanged ()
-		{
-			if (contentView != null) {
-				contentView.CanFocus = CanFocus;
-			}
-			base.OnCanFocusChanged ();
-		}
 	}
 }

+ 0 - 250
Terminal.Gui/Views/PanelView.cs

@@ -1,250 +0,0 @@
-using System;
-
-namespace Terminal.Gui {
-	/// <summary>
-	/// A container for single <see cref="Child"/> that will allow to drawn <see cref="Border"/> in
-	///  two ways. If <see cref="UsePanelFrame"/> the borders and the child will be accommodated in the available
-	///  panel size, otherwise the panel will be resized based on the child and borders thickness sizes.
-	/// </summary>
-	public class PanelView : View {
-		ChildContentView childContentView;
-
-		private class ChildContentView : View { }
-
-		private class SavedPosDim {
-			public Pos X;
-			public Pos Y;
-			public Dim Width;
-			public Dim Height;
-		}
-
-		private SavedPosDim savedPanel;
-		private SavedPosDim savedChild;
-
-		private View child;
-		private bool usePanelFrame;
-
-		/// <summary>
-		/// Initializes a panel with a null child.
-		/// </summary>
-		public PanelView () : this (null) { }
-
-		/// <summary>
-		/// Initializes a panel with a valid child.
-		/// </summary>
-		/// <param name="child"></param>
-		public PanelView (View child)
-		{
-			childContentView = new ChildContentView ();
-			base.Add (childContentView);
-			CanFocus = false;
-			Child = child;
-			if (child != null) {
-				Visible = child.Visible;
-			}
-		}
-
-		/// <summary>
-		/// Gets or sets if the panel size will used, otherwise the child size.
-		/// </summary>
-		public bool UsePanelFrame {
-			get => usePanelFrame;
-			set {
-				usePanelFrame = value;
-				AdjustContainer ();
-			}
-		}
-
-		/// <summary>
-		/// The child that will use this panel.
-		/// </summary>
-		public View Child {
-			get => child;
-			set {
-				if (child != null && value == null) {
-					childContentView.Remove (child);
-					child = value;
-					return;
-				}
-				child = value;
-				savedChild = new SavedPosDim () {
-					X = child?.X ?? child?.Frame.X,
-					Y = child?.Y ?? child?.Frame.Y,
-					Width = child?.Width ?? child?.Frame.Width,
-					Height = child?.Height ?? child?.Frame.Height
-				};
-				if (child == null) {
-					Visible = false;
-					return;
-				}
-				if (child?.Border != null) {
-					Border = child.Border;
-				} else {
-					if (Border == null) {
-						Border = new Border ();
-					}
-					Child.Border = Border;
-				}
-				Border.Child = childContentView;
-				if (!child.IsInitialized) {
-					child.Initialized += Child_Initialized;
-				}
-				childContentView.Add (Child);
-			}
-		}
-
-		/// <inheritdoc />
-		public override Border Border {
-			get => base.Border;
-			set {
-				if (base.Border?.Child != null && value.Child == null) {
-					value.Child = base.Border.Child;
-				}
-				base.Border = value;
-				if (value == null) {
-					return;
-				}
-				Border.BorderChanged += Border_BorderChanged;
-				if (Child != null && (Child?.Border == null || Child?.Border != value)) {
-					if (Child?.Border == null) {
-						Child.Border = new Border ();
-					}
-					Child.Border = Border;
-					Child.Border.BorderChanged += Border_BorderChanged;
-				}
-				AdjustContainer ();
-			}
-		}
-
-		private void Child_Initialized (object sender, EventArgs e)
-		{
-			savedPanel = new SavedPosDim () {
-				X = X,
-				Y = Y,
-				Width = Width,
-				Height = Height
-			};
-			AdjustContainer ();
-			Child.Initialized -= Child_Initialized;
-		}
-
-		private void Border_BorderChanged (Border obj)
-		{
-			AdjustContainer ();
-		}
-
-		private void AdjustContainer ()
-		{
-			if (Child?.IsInitialized == true) {
-				if (Child?.Border != null && Child.Border != Border) {
-					Border = Child.Border;
-				}
-				var borderLength = Child.Border.DrawMarginFrame ? 1 : 0;
-				var sumPadding = Child.Border.GetSumThickness ();
-				var effect3DOffset = Child.Border.Effect3D ? Child.Border.Effect3DOffset : new Point ();
-				if (!UsePanelFrame) {
-					X = savedPanel.X;
-					childContentView.X = borderLength + sumPadding.Left;
-					Y = savedPanel.Y;
-					childContentView.Y = borderLength + sumPadding.Top;
-					if (savedChild.Width is Dim.DimFill) {
-						var margin = -savedChild.Width.Anchor (0);
-						Width = Dim.Fill (margin);
-						childContentView.Width = Dim.Fill (margin + borderLength + sumPadding.Right);
-					} else {
-						var savedLayout = LayoutStyle;
-						LayoutStyle = LayoutStyle.Absolute;
-						Width = savedChild.X.Anchor (0) + savedChild.Width + (2 * borderLength) + sumPadding.Right + sumPadding.Left;
-						LayoutStyle = savedLayout;
-						childContentView.Width = Dim.Fill (borderLength + sumPadding.Right);
-					}
-					if (savedChild.Height is Dim.DimFill) {
-						var margin = -savedChild.Height.Anchor (0);
-						Height = Dim.Fill (margin);
-						childContentView.Height = Dim.Fill (margin + borderLength + sumPadding.Bottom);
-					} else {
-						var savedLayout = LayoutStyle;
-						LayoutStyle = LayoutStyle.Absolute;
-						Height = savedChild.Y.Anchor (0) + savedChild.Height + (2 * borderLength) + sumPadding.Bottom + sumPadding.Top;
-						LayoutStyle = savedLayout;
-						childContentView.Height = Dim.Fill (borderLength + sumPadding.Bottom);
-					}
-				} else {
-					X = savedPanel.X - (effect3DOffset.X < 0 ? effect3DOffset.X : 0);
-					childContentView.X = borderLength + sumPadding.Left;
-					Y = savedPanel.Y - (effect3DOffset.Y < 0 ? effect3DOffset.Y : 0);
-					childContentView.Y = borderLength + sumPadding.Top;
-					Width = savedPanel.Width;
-					Height = savedPanel.Height;
-					if (Width is Dim.DimFill) {
-						var margin = -savedPanel.Width.Anchor (0) +
-							(effect3DOffset.X > 0 ? effect3DOffset.X : 0);
-						Width = Dim.Fill (margin);
-						childContentView.Width = Dim.Fill (margin + borderLength + sumPadding.Right +
-							(effect3DOffset.X > 0 ? effect3DOffset.X : 0));
-					} else {
-						childContentView.Width = Dim.Fill (borderLength + sumPadding.Right);
-					}
-					if (Height is Dim.DimFill) {
-						var margin = -savedPanel.Height.Anchor (0) +
-							(effect3DOffset.Y > 0 ? effect3DOffset.Y : 0);
-						Height = Dim.Fill (margin);
-						childContentView.Height = Dim.Fill (margin + borderLength + sumPadding.Bottom +
-							(effect3DOffset.Y > 0 ? effect3DOffset.Y : 0));
-					} else {
-						childContentView.Height = Dim.Fill (borderLength + sumPadding.Bottom);
-					}
-				}
-				Visible = Child.Visible;
-			} else {
-				Visible = false;
-			}
-		}
-
-		/// <inheritdoc/>
-		public override void Add (View view)
-		{
-			if (Child != null) {
-				Child = null;
-			}
-			Child = view;
-		}
-
-		/// <inheritdoc/>
-		public override void Remove (View view)
-		{
-			if (view == childContentView) {
-				base.Remove (view);
-				return;
-			}
-			childContentView.Remove (view);
-			if (Child != null) {
-				Child = null;
-			}
-		}
-
-		/// <inheritdoc/>
-		public override void RemoveAll ()
-		{
-			if (Child != null) {
-				Child = null;
-			}
-		}
-
-		/// <inheritdoc/>
-		public override void Redraw (Rect bounds)
-		{
-			if (!NeedDisplay.IsEmpty) {
-				Driver.SetAttribute (Child.GetNormalColor ());
-				Clear ();
-				Child.Border.DrawContent (Border.Child);
-			}
-			var savedClip = childContentView.ClipToBounds ();
-			childContentView.Redraw (childContentView.Bounds);
-			Driver.Clip = savedClip;
-
-			ClearLayoutNeeded ();
-			ClearNeedsDisplay ();
-		}
-	}
-}

+ 313 - 313
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -1,313 +1,313 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios {
-	[ScenarioMetadata (Name: "ASCIICustomButtonTest", Description: "ASCIICustomButton sample")]
-	[ScenarioCategory ("Controls")]
-	public class ASCIICustomButtonTest : Scenario {
-		private static bool smallerWindow;
-		private ScrollViewTestWindow scrollViewTestWindow;
-		private MenuItem miSmallerWindow;
-
-		public override void Init (ColorScheme colorScheme)
-		{
-			Application.Init ();
-			scrollViewTestWindow = new ScrollViewTestWindow ();
-			var menu = new MenuBar (new MenuBarItem [] {
-				new MenuBarItem("Window Size", new MenuItem [] {
-					miSmallerWindow = new MenuItem ("Smaller Window", "", ChangeWindowSize) {
-						CheckType = MenuItemCheckStyle.Checked
-					},
-					null,
-					new MenuItem("Quit", "",() => Application.RequestStop(),null,null, Key.Q | Key.CtrlMask)
-				})
-			});
-			Application.Top.Add (menu, scrollViewTestWindow);
-			Application.Run ();
-		}
-
-		private void ChangeWindowSize ()
-		{
-			smallerWindow = (bool)(miSmallerWindow.Checked = !miSmallerWindow.Checked);
-			scrollViewTestWindow.Dispose ();
-			Application.Top.Remove (scrollViewTestWindow);
-			scrollViewTestWindow = new ScrollViewTestWindow ();
-			Application.Top.Add (scrollViewTestWindow);
-		}
-
-		public override void Run ()
-		{
-		}
-
-		public class ASCIICustomButton : Button {
-			public string Description => $"Description of: {id}";
-
-			public event Action<ASCIICustomButton> PointerEnter;
-
-			private Label fill;
-			private FrameView border;
-			private string id;
-
-			public ASCIICustomButton (string text, Pos x, Pos y, int width, int height) : base (text)
-			{
-				CustomInitialize ("", text, x, y, width, height);
-			}
-
-			public ASCIICustomButton (string id, string text, Pos x, Pos y, int width, int height) : base (text)
-			{
-				CustomInitialize (id, text, x, y, width, height);
-			}
-
-			private void CustomInitialize (string id, string text, Pos x, Pos y, int width, int height)
-			{
-				this.id = id;
-				X = x;
-				Y = y;
-
-				Frame = new Rect {
-					Width = width,
-					Height = height
-				};
-
-				border = new FrameView () {
-					Width = width,
-					Height = height
-				};
-
-				AutoSize = false;
-
-				var fillText = new System.Text.StringBuilder ();
-				for (int i = 0; i < Bounds.Height; i++) {
-					if (i > 0) {
-						fillText.AppendLine ("");
-					}
-					for (int j = 0; j < Bounds.Width; j++) {
-						fillText.Append ("█");
-					}
-				}
-
-				fill = new Label (fillText.ToString ()) {
-					Visible = false,
-					CanFocus = false
-				};
-
-				var title = new Label (text) {
-					X = Pos.Center (),
-					Y = Pos.Center (),
-				};
-
-				border.MouseClick += This_MouseClick;
-				border.Subviews [0].MouseClick += This_MouseClick;
-				fill.MouseClick += This_MouseClick;
-				title.MouseClick += This_MouseClick;
-
-				Add (border, fill, title);
-			}
-
-			private void This_MouseClick (MouseEventArgs obj)
-			{
-				OnMouseEvent (obj.MouseEvent);
-			}
-
-			public override bool OnMouseEvent (MouseEvent mouseEvent)
-			{
-				Debug.WriteLine ($"{mouseEvent.Flags}");
-				if (mouseEvent.Flags == MouseFlags.Button1Clicked) {
-					if (!HasFocus && SuperView != null) {
-						if (!SuperView.HasFocus) {
-							SuperView.SetFocus ();
-						}
-						SetFocus ();
-						SetNeedsDisplay ();
-					}
-
-					OnClicked ();
-					return true;
-				}
-				return base.OnMouseEvent (mouseEvent);
-			}
-
-			public override bool OnEnter (View view)
-			{
-				border.Visible = false;
-				fill.Visible = true;
-				PointerEnter.Invoke (this);
-				view = this;
-				return base.OnEnter (view);
-			}
-
-			public override bool OnLeave (View view)
-			{
-				border.Visible = true;
-				fill.Visible = false;
-				if (view == null)
-					view = this;
-				return base.OnLeave (view);
-			}
-		}
-
-		public class ScrollViewTestWindow : Window {
-			private List<Button> buttons;
-			private const int BUTTONS_ON_PAGE = 7;
-			private const int BUTTON_HEIGHT = 3;
-
-			private ScrollView scrollView;
-			private ASCIICustomButton selected;
-
-			public ScrollViewTestWindow ()
-			{
-				Title = "ScrollViewTestWindow";
-
-				Label titleLabel = null;
-				if (smallerWindow) {
-					Width = 80;
-					Height = 25;
-
-					scrollView = new ScrollView () {
-						X = 3,
-						Y = 1,
-						Width = 24,
-						Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
-						ShowVerticalScrollIndicator = true,
-						ShowHorizontalScrollIndicator = false
-					};
-				} else {
-					Width = Dim.Fill ();
-					Height = Dim.Fill ();
-
-					titleLabel = new Label ("DOCUMENTS") {
-						X = 0,
-						Y = 0
-					};
-
-					scrollView = new ScrollView () {
-						X = 0,
-						Y = 1,
-						Width = 27,
-						Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
-						ShowVerticalScrollIndicator = true,
-						ShowHorizontalScrollIndicator = false
-					};
-				}
-
-				scrollView.ClearKeybindings ();
-
-				buttons = new List<Button> ();
-				Button prevButton = null;
-				int count = 20;
-				for (int j = 0; j < count; j++) {
-					Pos yPos = prevButton == null ? 0 : Pos.Bottom (prevButton);
-					var button = new ASCIICustomButton (j.ToString (), $"section {j}", 0, yPos, 25, BUTTON_HEIGHT);
-					button.Id = $"button{j}";
-					button.Clicked += Button_Clicked;
-					button.PointerEnter += Button_PointerEnter;
-					button.MouseClick += Button_MouseClick;
-					button.KeyPress += Button_KeyPress;
-					scrollView.Add (button);
-					buttons.Add (button);
-					prevButton = button;
-				}
-
-				var closeButton = new ASCIICustomButton ("close", "Close", 0, Pos.Bottom (prevButton), 25, BUTTON_HEIGHT);
-				closeButton.Clicked += Button_Clicked;
-				closeButton.PointerEnter += Button_PointerEnter;
-				closeButton.MouseClick += Button_MouseClick;
-				closeButton.KeyPress += Button_KeyPress;
-				scrollView.Add (closeButton);
-				buttons.Add (closeButton);
-
-				var pages = buttons.Count / BUTTONS_ON_PAGE;
-				if (buttons.Count % BUTTONS_ON_PAGE > 0)
-					pages++;
-
-				scrollView.ContentSize = new Size (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT);
-				if (smallerWindow) {
-					Add (scrollView);
-				} else {
-					Add (titleLabel, scrollView);
-				}
-			}
-
-			private void Button_KeyPress (KeyEventEventArgs obj)
-			{
-				switch (obj.KeyEvent.Key) {
-				case Key.End:
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						 -(scrollView.ContentSize.Height - scrollView.Frame.Height
-						 + (scrollView.ShowHorizontalScrollIndicator ? 1 : 0)));
-					obj.Handled = true;
-					return;
-				case Key.Home:
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X, 0);
-					obj.Handled = true;
-					return;
-				case Key.PageDown:
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						 Math.Max (scrollView.ContentOffset.Y - scrollView.Frame.Height,
-						 -(scrollView.ContentSize.Height - scrollView.Frame.Height
-						 + (scrollView.ShowHorizontalScrollIndicator ? 1 : 0))));
-					obj.Handled = true;
-					return;
-				case Key.PageUp:
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						 Math.Min (scrollView.ContentOffset.Y + scrollView.Frame.Height, 0));
-					obj.Handled = true;
-					return;
-				}
-			}
-
-			private void Button_MouseClick (MouseEventArgs obj)
-			{
-				if (obj.MouseEvent.Flags == MouseFlags.WheeledDown) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						scrollView.ContentOffset.Y - BUTTON_HEIGHT);
-					obj.Handled = true;
-				} else if (obj.MouseEvent.Flags == MouseFlags.WheeledUp) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						Math.Min (scrollView.ContentOffset.Y + BUTTON_HEIGHT, 0));
-					obj.Handled = true;
-				}
-			}
-
-			private void Button_Clicked ()
-			{
-				MessageBox.Query ("Button clicked.", $"'{selected.Text}' clicked!", "Ok");
-				if (selected.Text == "Close") {
-					Application.RequestStop ();
-				}
-			}
-
-			private void Button_PointerEnter (ASCIICustomButton obj)
-			{
-				bool? moveDown;
-				if (obj.Frame.Y > selected?.Frame.Y) {
-					moveDown = true;
-				} else if (obj.Frame.Y < selected?.Frame.Y) {
-					moveDown = false;
-				} else {
-					moveDown = null;
-				}
-				var offSet = selected != null ? obj.Frame.Y - selected.Frame.Y + (-scrollView.ContentOffset.Y % BUTTON_HEIGHT) : 0;
-				selected = obj;
-				if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y + BUTTON_HEIGHT >= scrollView.Frame.Height && offSet != BUTTON_HEIGHT) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						Math.Min (scrollView.ContentOffset.Y - BUTTON_HEIGHT, -(selected.Frame.Y - scrollView.Frame.Height + BUTTON_HEIGHT)));
-				} else if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y >= scrollView.Frame.Height) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						scrollView.ContentOffset.Y - BUTTON_HEIGHT);
-				} else if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y < 0) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						-selected.Frame.Y);
-				} else if (moveDown == false && selected.Frame.Y < -scrollView.ContentOffset.Y) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						Math.Max (scrollView.ContentOffset.Y + BUTTON_HEIGHT, selected.Frame.Y));
-				} else if (moveDown == false && selected.Frame.Y + scrollView.ContentOffset.Y > scrollView.Frame.Height) {
-					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
-						 -(selected.Frame.Y - scrollView.Frame.Height + BUTTON_HEIGHT));
-				}
-			}
-		}
-	}
-}
+//using System;
+//using System.Collections.Generic;
+//using System.Diagnostics;
+//using Terminal.Gui;
+
+//namespace UICatalog.Scenarios {
+//	[ScenarioMetadata (Name: "ASCIICustomButtonTest", Description: "ASCIICustomButton sample")]
+//	[ScenarioCategory ("Controls")]
+//	public class ASCIICustomButtonTest : Scenario {
+//		private static bool smallerWindow;
+//		private ScrollViewTestWindow scrollViewTestWindow;
+//		private MenuItem miSmallerWindow;
+
+//		public override void Init (ColorScheme colorScheme)
+//		{
+//			Application.Init ();
+//			scrollViewTestWindow = new ScrollViewTestWindow ();
+//			var menu = new MenuBar (new MenuBarItem [] {
+//				new MenuBarItem("Window Size", new MenuItem [] {
+//					miSmallerWindow = new MenuItem ("Smaller Window", "", ChangeWindowSize) {
+//						CheckType = MenuItemCheckStyle.Checked
+//					},
+//					null,
+//					new MenuItem("Quit", "",() => Application.RequestStop(),null,null, Key.Q | Key.CtrlMask)
+//				})
+//			});
+//			Application.Top.Add (menu, scrollViewTestWindow);
+//			Application.Run ();
+//		}
+
+//		private void ChangeWindowSize ()
+//		{
+//			smallerWindow = (bool)(miSmallerWindow.Checked = !miSmallerWindow.Checked);
+//			scrollViewTestWindow.Dispose ();
+//			Application.Top.Remove (scrollViewTestWindow);
+//			scrollViewTestWindow = new ScrollViewTestWindow ();
+//			Application.Top.Add (scrollViewTestWindow);
+//		}
+
+//		public override void Run ()
+//		{
+//		}
+
+//		public class ASCIICustomButton : Button {
+//			public string Description => $"Description of: {id}";
+
+//			public event Action<ASCIICustomButton> PointerEnter;
+
+//			private Label fill;
+//			private FrameView border;
+//			private string id;
+
+//			public ASCIICustomButton (string text, Pos x, Pos y, int width, int height) : base (text)
+//			{
+//				CustomInitialize ("", text, x, y, width, height);
+//			}
+
+//			public ASCIICustomButton (string id, string text, Pos x, Pos y, int width, int height) : base (text)
+//			{
+//				CustomInitialize (id, text, x, y, width, height);
+//			}
+
+//			private void CustomInitialize (string id, string text, Pos x, Pos y, int width, int height)
+//			{
+//				this.id = id;
+//				X = x;
+//				Y = y;
+
+//				Frame = new Rect {
+//					Width = width,
+//					Height = height
+//				};
+
+//				border = new FrameView () {
+//					Width = width,
+//					Height = height
+//				};
+
+//				AutoSize = false;
+
+//				var fillText = new System.Text.StringBuilder ();
+//				for (int i = 0; i < Bounds.Height; i++) {
+//					if (i > 0) {
+//						fillText.AppendLine ("");
+//					}
+//					for (int j = 0; j < Bounds.Width; j++) {
+//						fillText.Append ("█");
+//					}
+//				}
+
+//				fill = new Label (fillText.ToString ()) {
+//					Visible = false,
+//					CanFocus = false
+//				};
+
+//				var title = new Label (text) {
+//					X = Pos.Center (),
+//					Y = Pos.Center (),
+//				};
+
+//				border.MouseClick += This_MouseClick;
+//				//border.Subviews [0].MouseClick += This_MouseClick;
+//				fill.MouseClick += This_MouseClick;
+//				title.MouseClick += This_MouseClick;
+
+//				Add (border, fill, title);
+//			}
+
+//			private void This_MouseClick (MouseEventArgs obj)
+//			{
+//				OnMouseEvent (obj.MouseEvent);
+//			}
+
+//			public override bool OnMouseEvent (MouseEvent mouseEvent)
+//			{
+//				Debug.WriteLine ($"{mouseEvent.Flags}");
+//				if (mouseEvent.Flags == MouseFlags.Button1Clicked) {
+//					if (!HasFocus && SuperView != null) {
+//						if (!SuperView.HasFocus) {
+//							SuperView.SetFocus ();
+//						}
+//						SetFocus ();
+//						SetNeedsDisplay ();
+//					}
+
+//					OnClicked ();
+//					return true;
+//				}
+//				return base.OnMouseEvent (mouseEvent);
+//			}
+
+//			public override bool OnEnter (View view)
+//			{
+//				border.Visible = false;
+//				fill.Visible = true;
+//				PointerEnter.Invoke (this);
+//				view = this;
+//				return base.OnEnter (view);
+//			}
+
+//			public override bool OnLeave (View view)
+//			{
+//				border.Visible = true;
+//				fill.Visible = false;
+//				if (view == null)
+//					view = this;
+//				return base.OnLeave (view);
+//			}
+//		}
+
+//		public class ScrollViewTestWindow : Window {
+//			private List<Button> buttons;
+//			private const int BUTTONS_ON_PAGE = 7;
+//			private const int BUTTON_HEIGHT = 3;
+
+//			private ScrollView scrollView;
+//			private ASCIICustomButton selected;
+
+//			public ScrollViewTestWindow ()
+//			{
+//				Title = "ScrollViewTestWindow";
+
+//				Label titleLabel = null;
+//				if (smallerWindow) {
+//					Width = 80;
+//					Height = 25;
+
+//					scrollView = new ScrollView () {
+//						X = 3,
+//						Y = 1,
+//						Width = 24,
+//						Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
+//						ShowVerticalScrollIndicator = true,
+//						ShowHorizontalScrollIndicator = false
+//					};
+//				} else {
+//					Width = Dim.Fill ();
+//					Height = Dim.Fill ();
+
+//					titleLabel = new Label ("DOCUMENTS") {
+//						X = 0,
+//						Y = 0
+//					};
+
+//					scrollView = new ScrollView () {
+//						X = 0,
+//						Y = 1,
+//						Width = 27,
+//						Height = BUTTONS_ON_PAGE * BUTTON_HEIGHT,
+//						ShowVerticalScrollIndicator = true,
+//						ShowHorizontalScrollIndicator = false
+//					};
+//				}
+
+//				scrollView.ClearKeybindings ();
+
+//				buttons = new List<Button> ();
+//				Button prevButton = null;
+//				int count = 20;
+//				for (int j = 0; j < count; j++) {
+//					Pos yPos = prevButton == null ? 0 : Pos.Bottom (prevButton);
+//					var button = new ASCIICustomButton (j.ToString (), $"section {j}", 0, yPos, 25, BUTTON_HEIGHT);
+//					button.Id = $"button{j}";
+//					button.Clicked += Button_Clicked;
+//					button.PointerEnter += Button_PointerEnter;
+//					button.MouseClick += Button_MouseClick;
+//					button.KeyPress += Button_KeyPress;
+//					scrollView.Add (button);
+//					buttons.Add (button);
+//					prevButton = button;
+//				}
+
+//				var closeButton = new ASCIICustomButton ("close", "Close", 0, Pos.Bottom (prevButton), 25, BUTTON_HEIGHT);
+//				closeButton.Clicked += Button_Clicked;
+//				closeButton.PointerEnter += Button_PointerEnter;
+//				closeButton.MouseClick += Button_MouseClick;
+//				closeButton.KeyPress += Button_KeyPress;
+//				scrollView.Add (closeButton);
+//				buttons.Add (closeButton);
+
+//				var pages = buttons.Count / BUTTONS_ON_PAGE;
+//				if (buttons.Count % BUTTONS_ON_PAGE > 0)
+//					pages++;
+
+//				scrollView.ContentSize = new Size (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT);
+//				if (smallerWindow) {
+//					Add (scrollView);
+//				} else {
+//					Add (titleLabel, scrollView);
+//				}
+//			}
+
+//			private void Button_KeyPress (KeyEventEventArgs obj)
+//			{
+//				switch (obj.KeyEvent.Key) {
+//				case Key.End:
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						 -(scrollView.ContentSize.Height - scrollView.Frame.Height
+//						 + (scrollView.ShowHorizontalScrollIndicator ? 1 : 0)));
+//					obj.Handled = true;
+//					return;
+//				case Key.Home:
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X, 0);
+//					obj.Handled = true;
+//					return;
+//				case Key.PageDown:
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						 Math.Max (scrollView.ContentOffset.Y - scrollView.Frame.Height,
+//						 -(scrollView.ContentSize.Height - scrollView.Frame.Height
+//						 + (scrollView.ShowHorizontalScrollIndicator ? 1 : 0))));
+//					obj.Handled = true;
+//					return;
+//				case Key.PageUp:
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						 Math.Min (scrollView.ContentOffset.Y + scrollView.Frame.Height, 0));
+//					obj.Handled = true;
+//					return;
+//				}
+//			}
+
+//			private void Button_MouseClick (MouseEventArgs obj)
+//			{
+//				if (obj.MouseEvent.Flags == MouseFlags.WheeledDown) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						scrollView.ContentOffset.Y - BUTTON_HEIGHT);
+//					obj.Handled = true;
+//				} else if (obj.MouseEvent.Flags == MouseFlags.WheeledUp) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						Math.Min (scrollView.ContentOffset.Y + BUTTON_HEIGHT, 0));
+//					obj.Handled = true;
+//				}
+//			}
+
+//			private void Button_Clicked ()
+//			{
+//				MessageBox.Query ("Button clicked.", $"'{selected.Text}' clicked!", "Ok");
+//				if (selected.Text == "Close") {
+//					Application.RequestStop ();
+//				}
+//			}
+
+//			private void Button_PointerEnter (ASCIICustomButton obj)
+//			{
+//				bool? moveDown;
+//				if (obj.Frame.Y > selected?.Frame.Y) {
+//					moveDown = true;
+//				} else if (obj.Frame.Y < selected?.Frame.Y) {
+//					moveDown = false;
+//				} else {
+//					moveDown = null;
+//				}
+//				var offSet = selected != null ? obj.Frame.Y - selected.Frame.Y + (-scrollView.ContentOffset.Y % BUTTON_HEIGHT) : 0;
+//				selected = obj;
+//				if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y + BUTTON_HEIGHT >= scrollView.Frame.Height && offSet != BUTTON_HEIGHT) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						Math.Min (scrollView.ContentOffset.Y - BUTTON_HEIGHT, -(selected.Frame.Y - scrollView.Frame.Height + BUTTON_HEIGHT)));
+//				} else if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y >= scrollView.Frame.Height) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						scrollView.ContentOffset.Y - BUTTON_HEIGHT);
+//				} else if (moveDown == true && selected.Frame.Y + scrollView.ContentOffset.Y < 0) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						-selected.Frame.Y);
+//				} else if (moveDown == false && selected.Frame.Y < -scrollView.ContentOffset.Y) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						Math.Max (scrollView.ContentOffset.Y + BUTTON_HEIGHT, selected.Frame.Y));
+//				} else if (moveDown == false && selected.Frame.Y + scrollView.ContentOffset.Y > scrollView.Frame.Height) {
+//					scrollView.ContentOffset = new Point (scrollView.ContentOffset.X,
+//						 -(selected.Frame.Y - scrollView.Frame.Height + BUTTON_HEIGHT));
+//				}
+//			}
+//		}
+//	}
+//}

+ 0 - 470
UICatalog/Scenarios/Borders.cs

@@ -1,470 +0,0 @@
-using System;
-using System.Globalization;
-using System.Linq;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios {
-	[ScenarioMetadata (Name: "Borders with/without PanelView", Description: "Demonstrate with/without PanelView borders manipulation.")]
-	[ScenarioCategory ("Layout")]
-	[ScenarioCategory ("Borders")]
-	public class Borders : Scenario {
-		public override void Setup ()
-		{
-			var borderStyle = BorderStyle.Single;
-			var drawMarginFrame = true;
-			var borderThickness = new Thickness (2);
-			var borderBrush = Color.Red;
-			var padding = new Thickness (2);
-			var background = Color.BrightGreen;
-			var effect3D = true;
-
-			var smartPanel = new PanelView () {
-				X = Pos.Center () - 38,
-				Y = Pos.Center () - 3,
-				Width = 24,
-				Height = 13,
-				Border = new Border () {
-					BorderStyle = borderStyle,
-					DrawMarginFrame = drawMarginFrame,
-					BorderThickness = borderThickness,
-					BorderBrush = borderBrush,
-					Padding = padding,
-					Background = background,
-					Effect3D = effect3D,
-					Title = "Panel"
-				},
-				ColorScheme = Colors.TopLevel
-			};
-			smartPanel.Add (new Label () { // Or smartPanel.Child = 
-				X = 0,
-				Y = 0,
-				//Width = 24, commenting because now setting the size disable auto-size
-				//Height = 13,
-				ColorScheme = Colors.TopLevel,
-				Text = "This is a test\nwith a \nPanelView",
-				TextAlignment = TextAlignment.Centered
-			});
-
-			// Can be initialized this way too.
-
-			//var smartPanel = new PanelView (new Label () {
-			//	X = Pos.Center () - 38,
-			//	Y = Pos.Center () - 3,
-			//	Width = 24,
-			//	Height = 13,
-			//	Border = new Border () {
-			//		BorderStyle = borderStyle,
-			//		DrawMarginFrame = drawMarginFrame,
-			//		BorderThickness = borderThickness,
-			//		BorderBrush = borderBrush,
-			//		Padding = padding,
-			//		Background = background,
-			//		Effect3D = effect3D
-			//	},
-			//	ColorScheme = Colors.TopLevel,
-			//	Text = "This is a test\nwith a \nPanelView",
-			//	TextAlignment = TextAlignment.Centered
-			//}) {
-			//	X = Pos.Center () - 38,
-			//	Y = Pos.Center () - 3,
-			//	Width = 24,
-			//	Height = 13
-			//};
-
-			var smartView = new Label () {
-				X = Pos.Center () + 10,
-				Y = Pos.Center () + 2,
-				Border = new Border () {
-					BorderStyle = borderStyle,
-					DrawMarginFrame = drawMarginFrame,
-					BorderThickness = borderThickness,
-					BorderBrush = borderBrush,
-					Padding = padding,
-					Background = background,
-					Effect3D = effect3D,
-					Title = "Label"
-				},
-				ColorScheme = Colors.TopLevel,
-				Text = "This is a test\nwithout a \nPanelView",
-				TextAlignment = TextAlignment.Centered
-			};
-			smartView.Border.Child = smartView;
-
-			Win.Add (new Label ("Padding:") {
-				X = Pos.Center () - 23,
-			});
-
-			var paddingTopEdit = new TextField ("") {
-				X = Pos.Center () - 22,
-				Y = 1,
-				Width = 5
-			};
-			paddingTopEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Padding = new Thickness (smartPanel.Child.Border.Padding.Left,
-						int.Parse (e.NewText.ToString ()), smartPanel.Child.Border.Padding.Right,
-						smartPanel.Child.Border.Padding.Bottom);
-
-					smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left,
-						int.Parse (e.NewText.ToString ()), smartView.Border.Padding.Right,
-						smartView.Border.Padding.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			paddingTopEdit.Text = $"{smartView.Border.Padding.Top}";
-
-			Win.Add (paddingTopEdit);
-
-			var paddingLeftEdit = new TextField ("") {
-				X = Pos.Center () - 30,
-				Y = 2,
-				Width = 5
-			};
-			paddingLeftEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Padding = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartPanel.Child.Border.Padding.Top, smartPanel.Child.Border.Padding.Right,
-						smartPanel.Child.Border.Padding.Bottom);
-
-					smartView.Border.Padding = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartView.Border.Padding.Top, smartView.Border.Padding.Right,
-						smartView.Border.Padding.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			paddingLeftEdit.Text = $"{smartView.Border.Padding.Left}";
-			Win.Add (paddingLeftEdit);
-
-			var paddingRightEdit = new TextField ("") {
-				X = Pos.Center () - 15,
-				Y = 2,
-				Width = 5
-			};
-			paddingRightEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Padding = new Thickness (smartPanel.Child.Border.Padding.Left,
-						smartPanel.Child.Border.Padding.Top, int.Parse (e.NewText.ToString ()),
-						smartPanel.Child.Border.Padding.Bottom);
-
-					smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left,
-						smartView.Border.Padding.Top, int.Parse (e.NewText.ToString ()),
-						smartView.Border.Padding.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			paddingRightEdit.Text = $"{smartView.Border.Padding.Right}";
-			Win.Add (paddingRightEdit);
-
-			var paddingBottomEdit = new TextField ("") {
-				X = Pos.Center () - 22,
-				Y = 3,
-				Width = 5
-			};
-			paddingBottomEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Padding = new Thickness (smartPanel.Child.Border.Padding.Left,
-						smartPanel.Child.Border.Padding.Top, smartPanel.Child.Border.Padding.Right,
-						int.Parse (e.NewText.ToString ()));
-
-					smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left,
-						smartView.Border.Padding.Top, smartView.Border.Padding.Right,
-						int.Parse (e.NewText.ToString ()));
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			paddingBottomEdit.Text = $"{smartView.Border.Padding.Bottom}";
-			Win.Add (paddingBottomEdit);
-
-			var replacePadding = new Button ("Replace all based on top") {
-				X = Pos.Center () - 35,
-				Y = 5
-			};
-			replacePadding.Clicked += () => {
-				smartPanel.Child.Border.Padding = new Thickness (smartPanel.Child.Border.Padding.Top);
-				smartView.Border.Padding = new Thickness (smartView.Border.Padding.Top);
-				if (paddingTopEdit.Text.IsEmpty) {
-					paddingTopEdit.Text = "0";
-				}
-				paddingBottomEdit.Text = paddingLeftEdit.Text = paddingRightEdit.Text = paddingTopEdit.Text;
-			};
-			Win.Add (replacePadding);
-
-			var cbUseUsePanelFrame = new CheckBox ("UsePanelFrame") {
-				X = Pos.X (replacePadding),
-				Y = Pos.Y (replacePadding) + 3,
-				Checked = smartPanel.UsePanelFrame
-			};
-			cbUseUsePanelFrame.Toggled += (e) => smartPanel.UsePanelFrame = (bool)!e;
-			Win.Add (cbUseUsePanelFrame);
-
-			Win.Add (new Label ("Border:") {
-				X = Pos.Center () + 11,
-			});
-
-			var borderTopEdit = new TextField ("") {
-				X = Pos.Center () + 12,
-				Y = 1,
-				Width = 5
-			};
-			borderTopEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.BorderThickness = new Thickness (smartPanel.Child.Border.BorderThickness.Left,
-						int.Parse (e.NewText.ToString ()), smartPanel.Child.Border.BorderThickness.Right,
-						smartPanel.Child.Border.BorderThickness.Bottom);
-
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						int.Parse (e.NewText.ToString ()), smartView.Border.BorderThickness.Right,
-						smartView.Border.BorderThickness.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			borderTopEdit.Text = $"{smartView.Border.BorderThickness.Top}";
-
-			Win.Add (borderTopEdit);
-
-			var borderLeftEdit = new TextField ("") {
-				X = Pos.Center () + 5,
-				Y = 2,
-				Width = 5
-			};
-			borderLeftEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.BorderThickness = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartPanel.Child.Border.BorderThickness.Top, smartPanel.Child.Border.BorderThickness.Right,
-						smartPanel.Child.Border.BorderThickness.Bottom);
-
-					smartView.Border.BorderThickness = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartView.Border.BorderThickness.Top, smartView.Border.BorderThickness.Right,
-						smartView.Border.BorderThickness.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			borderLeftEdit.Text = $"{smartView.Border.BorderThickness.Left}";
-			Win.Add (borderLeftEdit);
-
-			var borderRightEdit = new TextField ("") {
-				X = Pos.Center () + 19,
-				Y = 2,
-				Width = 5
-			};
-			borderRightEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.BorderThickness = new Thickness (smartPanel.Child.Border.BorderThickness.Left,
-						smartPanel.Child.Border.BorderThickness.Top, int.Parse (e.NewText.ToString ()),
-						smartPanel.Child.Border.BorderThickness.Bottom);
-
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						smartView.Border.BorderThickness.Top, int.Parse (e.NewText.ToString ()),
-						smartView.Border.BorderThickness.Bottom);
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			borderRightEdit.Text = $"{smartView.Border.BorderThickness.Right}";
-			Win.Add (borderRightEdit);
-
-			var borderBottomEdit = new TextField ("") {
-				X = Pos.Center () + 12,
-				Y = 3,
-				Width = 5
-			};
-			borderBottomEdit.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.BorderThickness = new Thickness (smartPanel.Child.Border.BorderThickness.Left,
-						smartPanel.Child.Border.BorderThickness.Top, smartPanel.Child.Border.BorderThickness.Right,
-						int.Parse (e.NewText.ToString ()));
-
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						smartView.Border.BorderThickness.Top, smartView.Border.BorderThickness.Right,
-						int.Parse (e.NewText.ToString ()));
-				} catch {
-					if (!e.NewText.IsEmpty) {
-						e.Cancel = true;
-					}
-				}
-			};
-			borderBottomEdit.Text = $"{smartView.Border.BorderThickness.Bottom}";
-			Win.Add (borderBottomEdit);
-
-			var replaceBorder = new Button ("Replace all based on top") {
-				X = Pos.Center () + 1,
-				Y = 5
-			};
-			replaceBorder.Clicked += () => {
-				smartPanel.Child.Border.BorderThickness = new Thickness (smartPanel.Child.Border.BorderThickness.Top);
-				smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Top);
-				if (borderTopEdit.Text.IsEmpty) {
-					borderTopEdit.Text = "0";
-				}
-				borderBottomEdit.Text = borderLeftEdit.Text = borderRightEdit.Text = borderTopEdit.Text;
-			};
-			Win.Add (replaceBorder);
-
-			Win.Add (new Label ("BorderStyle:"));
-
-			var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
-			var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
-				e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
-
-				X = 2,
-				Y = 1,
-				SelectedItem = (int)smartView.Border.BorderStyle
-			};
-			Win.Add (rbBorderStyle);
-
-			var cbDrawMarginFrame = new CheckBox ("Draw Margin Frame", smartView.Border.DrawMarginFrame) {
-				X = Pos.AnchorEnd (20),
-				Y = 0,
-				Width = 5
-			};
-			cbDrawMarginFrame.Toggled += (e) => {
-				try {
-					smartPanel.Child.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
-					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
-					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
-						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
-					}
-				} catch { }
-			};
-			Win.Add (cbDrawMarginFrame);
-
-			rbBorderStyle.SelectedItemChanged += (e) => {
-				smartPanel.Child.Border.BorderStyle = (BorderStyle)e.SelectedItem;
-				smartView.Border.BorderStyle = (BorderStyle)e.SelectedItem;
-				smartView.SetNeedsDisplay ();
-				if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
-					cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
-				}
-			};
-
-			var cbEffect3D = new CheckBox ("Draw 3D effects", smartView.Border.Effect3D) {
-				X = Pos.AnchorEnd (20),
-				Y = 1,
-				Width = 5
-			};
-			Win.Add (cbEffect3D);
-
-			Win.Add (new Label ("Effect3D Offset:") {
-				X = Pos.AnchorEnd (20),
-				Y = 2
-			});
-			Win.Add (new Label ("X:") {
-				X = Pos.AnchorEnd (19),
-				Y = 3
-			});
-
-			var effect3DOffsetX = new TextField ("") {
-				X = Pos.AnchorEnd (16),
-				Y = 3,
-				Width = 5
-			};
-			effect3DOffsetX.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Effect3DOffset = new Point (int.Parse (e.NewText.ToString ()),
-						smartPanel.Child.Border.Effect3DOffset.Y);
-
-					smartView.Border.Effect3DOffset = new Point (int.Parse (e.NewText.ToString ()),
-						smartView.Border.Effect3DOffset.Y);
-				} catch {
-					if (!e.NewText.IsEmpty && e.NewText != CultureInfo.CurrentCulture.NumberFormat.NegativeSign) {
-						e.Cancel = true;
-					}
-				}
-			};
-			effect3DOffsetX.Text = $"{smartView.Border.Effect3DOffset.X}";
-			Win.Add (effect3DOffsetX);
-
-			Win.Add (new Label ("Y:") {
-				X = Pos.AnchorEnd (10),
-				Y = 3
-			});
-
-			var effect3DOffsetY = new TextField ("") {
-				X = Pos.AnchorEnd (7),
-				Y = 3,
-				Width = 5
-			};
-			effect3DOffsetY.TextChanging += (e) => {
-				try {
-					smartPanel.Child.Border.Effect3DOffset = new Point (smartPanel.Child.Border.Effect3DOffset.X,
-						int.Parse (e.NewText.ToString ()));
-
-					smartView.Border.Effect3DOffset = new Point (smartView.Border.Effect3DOffset.X,
-						int.Parse (e.NewText.ToString ()));
-				} catch {
-					if (!e.NewText.IsEmpty && e.NewText != CultureInfo.CurrentCulture.NumberFormat.NegativeSign) {
-						e.Cancel = true;
-					}
-				}
-			};
-			effect3DOffsetY.Text = $"{smartView.Border.Effect3DOffset.Y}";
-			Win.Add (effect3DOffsetY);
-
-			cbEffect3D.Toggled += (e) => {
-				try {
-					smartPanel.Child.Border.Effect3D = smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
-				} catch { }
-			};
-
-			Win.Add (new Label ("Background:") {
-				Y = 5
-			});
-
-			var colorEnum = Enum.GetValues (typeof (Color)).Cast<Color> ().ToList ();
-			var rbBackground = new RadioGroup (colorEnum.Select (
-				e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
-
-				X = 2,
-				Y = 6,
-				SelectedItem = (int)smartView.Border.Background
-			};
-			rbBackground.SelectedItemChanged += (e) => {
-				smartPanel.Child.Border.Background = smartView.Border.Background = (Color)e.SelectedItem;
-			};
-			Win.Add (rbBackground);
-
-			Win.Add (new Label ("BorderBrush:") {
-				X = Pos.AnchorEnd (20),
-				Y = 5
-			});
-
-			var rbBorderBrush = new RadioGroup (colorEnum.Select (
-				e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
-
-				X = Pos.AnchorEnd (18),
-				Y = 6,
-				SelectedItem = (int)smartView.Border.BorderBrush
-			};
-			rbBorderBrush.SelectedItemChanged += (e) => {
-				smartPanel.Child.Border.BorderBrush = smartView.Border.BorderBrush = (Color)e.SelectedItem;
-			};
-			Win.Add (rbBorderBrush);
-
-			Win.Add (smartPanel);
-			Win.Add (smartView);
-
-			Win.BringSubviewToFront (smartPanel);
-		}
-	}
-}

+ 2 - 2
UICatalog/Scenarios/BordersComparisons.cs

@@ -53,7 +53,7 @@ namespace UICatalog.Scenarios {
 			win.Add (tf1, button, label, tv, tf2);
 			Application.Top.Add (win);
 
-			var top2 = new Border.ToplevelContainer (new Rect (50, 5, 40, 20),
+			var top2 = new Window (new Rect (50, 5, 40, 20), "Test2", 0,
 				new Border () {
 					BorderStyle = borderStyle,
 					DrawMarginFrame = drawMarginFrame,
@@ -62,7 +62,7 @@ namespace UICatalog.Scenarios {
 					Padding = padding,
 					Background = background,
 					Effect3D = effect3D,
-					Title = "Test2"
+					//Title = "Test2"
 				}) {
 				ColorScheme = Colors.Base,
 			};

+ 1 - 1
UICatalog/Scenarios/BordersOnFrameView.cs

@@ -31,8 +31,8 @@ namespace UICatalog.Scenarios {
 					Padding = padding,
 					Background = background,
 					Effect3D = effect3D,
-					Title = "Frame"
 				},
+				Title = "Frame",
 				ColorScheme = Colors.TopLevel
 			};
 

+ 2 - 2
UICatalog/Scenarios/BordersOnToplevel.cs

@@ -18,7 +18,7 @@ namespace UICatalog.Scenarios {
 			var background = Colors.Base.HotNormal.Foreground;
 			var effect3D = true;
 
-			var smartView = new Border.ToplevelContainer () {
+			var smartView = new Window () {
 				X = Pos.Center (),
 				Y = Pos.Center () - 7,
 				Width = 40,
@@ -31,8 +31,8 @@ namespace UICatalog.Scenarios {
 					Padding = padding,
 					Background = background,
 					Effect3D = effect3D,
-					Title = "Toplevel"
 				},
+				Title = "Toplevel",
 				ColorScheme = Colors.TopLevel
 			};
 

+ 1 - 1
UICatalog/Scenarios/BordersOnWindow.cs

@@ -31,8 +31,8 @@ namespace UICatalog.Scenarios {
 					Padding = padding,
 					Background = background,
 					Effect3D = effect3D,
-					Title = "Window"
 				},
+				Title = "Window",
 				ColorScheme = Colors.TopLevel
 			};
 

+ 7 - 17
UICatalog/Scenarios/ComputedLayout.cs

@@ -19,25 +19,14 @@ namespace UICatalog.Scenarios {
 
 		public override void Setup ()
 		{
-			var menu = new MenuBar (new MenuBarItem [] {
-				new MenuBarItem ("_Settings", new MenuItem [] {
-					null,
-					new MenuItem ("_Quit", "", () => Quit()),
-				}),
-			});
-			Application.Top.Add (menu);
-
-			var statusBar = new StatusBar (new StatusItem [] {
-				new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
-			});
-			Application.Top.Add (statusBar);
-
 			// Demonstrate using Dim to create a horizontal ruler that always measures the parent window's width
 			const string rule = "|123456789";
-			var horizontalRuler = new Label ("") {
+			var horizontalRuler = new Label (rule, false) {
+				AutoSize = false,
 				X = 0,
 				Y = 0,
-				Width = Dim.Fill (),  
+				Width = Dim.Fill (),
+				Height = 1,
 				ColorScheme = Colors.Error
 			};
 
@@ -46,7 +35,8 @@ namespace UICatalog.Scenarios {
 			// Demonstrate using Dim to create a vertical ruler that always measures the parent window's height
 			const string vrule = "|\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
 
-			var verticalRuler = new Label ("") {
+			var verticalRuler = new Label (vrule, false) {
+				AutoSize = false,
 				X = 0,
 				Y = 0,
 				Width = 1,
@@ -140,7 +130,7 @@ namespace UICatalog.Scenarios {
 				ColorScheme = Colors.Menu,
 				Width = Dim.Fill (),
 				X = Pos.Center (),
-				Y = Pos.AnchorEnd () - 2 
+				Y = Pos.AnchorEnd (2)
 			};
 			Win.Add (bottomLabel);
 

+ 6 - 1
UICatalog/Scenarios/Dialogs.cs

@@ -27,6 +27,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			frame.Add (label);
+			
 			var widthEdit = new TextField ("0") {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -43,6 +44,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			frame.Add (label);
+			
 			var heightEdit = new TextField ("0") {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -68,6 +70,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			frame.Add (label);
+			
 			var titleEdit = new TextField ("Title") {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -84,6 +87,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			frame.Add (label);
+			
 			var numButtonsEdit = new TextField ("3") {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -99,13 +103,13 @@ namespace UICatalog.Scenarios {
 			};
 			frame.Add (glyphsNotWords);
 
-
 			label = new Label ("Button Style:") {
 				X = 0,
 				Y = Pos.Bottom (glyphsNotWords),
 				TextAlignment = Terminal.Gui.TextAlignment.Right
 			};
 			frame.Add (label);
+			
 			var styleRadioGroup = new RadioGroup (new ustring [] { "Center", "Justify", "Left", "Right" }) {
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label),
@@ -127,6 +131,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 			};
 			Win.Add (label);
+
 			var buttonPressedLabel = new Label (" ") {
 				X = Pos.Center (),
 				Y = Pos.Bottom (frame) + 5,

+ 0 - 1
UICatalog/Scenarios/TileViewExperiment.cs

@@ -66,7 +66,6 @@ namespace UICatalog.Scenarios {
 					DrawMarginFrame = true,
 					Padding = new Thickness(1),
 					BorderBrush = Color.BrightMagenta,
-					Title = "Border Title"
 				}
 			};
 

+ 141 - 398
UnitTests/Core/BorderTests.cs

@@ -23,14 +23,9 @@ namespace Terminal.Gui.CoreTests {
 			Assert.Equal (Color.Black, b.BorderBrush);
 			Assert.Equal (Color.Black, b.Background);
 			Assert.Equal (Thickness.Empty, b.Padding);
-			Assert.Equal (0, b.ActualWidth);
-			Assert.Equal (0, b.ActualHeight);
-			Assert.Null (b.Child);
-			Assert.Null (b.ChildContainer);
 			Assert.False (b.Effect3D);
 			Assert.Equal (new Point (1, 1), b.Effect3DOffset);
 			Assert.Null (b.Effect3DBrush);
-			Assert.Equal (NStack.ustring.Empty, b.Title);
 		}
 
 		[Fact]
@@ -49,263 +44,6 @@ namespace Terminal.Gui.CoreTests {
 			Assert.False (b.DrawMarginFrame);
 		}
 
-		[Fact, AutoInitShutdown]
-		public void ActualWidth_ActualHeight ()
-		{
-			var v = new View (new Rect (5, 10, 60, 20), "", new Border ());
-
-			Assert.Equal (60, v.Border.ActualWidth);
-			Assert.Equal (20, v.Border.ActualHeight);
-		}
-
-		[Fact]
-		public void ToplevelContainer_LayoutStyle_Computed_Constuctor_ ()
-		{
-			var tc = new Border.ToplevelContainer (new Border ());
-
-			Assert.Equal (LayoutStyle.Computed, tc.LayoutStyle);
-		}
-
-		[Fact]
-		public void ToplevelContainer_LayoutStyle_Absolute_Constuctor_ ()
-		{
-			var tc = new Border.ToplevelContainer (new Rect (1, 2, 3, 4), new Border ());
-
-			Assert.Equal (LayoutStyle.Absolute, tc.LayoutStyle);
-		}
-
-		[Fact]
-		public void GetSumThickness_Test ()
-		{
-			var b = new Border () {
-				BorderThickness = new Thickness (1, 2, 3, 4),
-				Padding = new Thickness (4, 3, 2, 1)
-			};
-			Assert.Equal (new Thickness (5, 5, 5, 5), b.GetSumThickness ());
-		}
-
-		//[Fact]
-		//[AutoInitShutdown]
-		//public void DrawContent_With_Child_Border ()
-		//{
-		//	var top = Application.Top;
-		//	var driver = (FakeDriver)Application.Driver;
-
-		//	var label = new Label () {
-		//		X = Pos.Center (),
-		//		Y = Pos.Center (),
-		//		Border = new Border () {
-		//			BorderStyle = BorderStyle.Single,
-		//			Padding = new Thickness (2),
-		//			BorderThickness = new Thickness (2),
-		//			BorderBrush = Color.Red,
-		//			Background = Color.BrightGreen,
-		//			Effect3D = true,
-		//			Effect3DOffset = new Point (2, -3)
-		//		},
-		//		ColorScheme = Colors.TopLevel,
-		//		Text = "This is a test"
-		//	};
-		//	label.Border.Child = label;
-		//	top.Add (label);
-
-		//	top.LayoutSubviews ();
-		//	label.Redraw (label.Bounds);
-
-		//	var frame = label.Frame;
-		//	var drawMarginFrame = label.Border.DrawMarginFrame ? 1 : 0;
-		//	var sumThickness = label.Border.GetSumThickness ();
-		//	var padding = label.Border.Padding;
-		//	var effect3DOffset = label.Border.Effect3DOffset;
-		//	var borderStyle = label.Border.BorderStyle;
-
-		//	// Check the upper BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
-		//		r < frame.Y - drawMarginFrame - padding.Top; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.X - drawMarginFrame - padding.Left; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.Right + drawMarginFrame + padding.Right;
-		//			c < frame.Right + drawMarginFrame - sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower BorderThickness
-		//	for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the upper Padding
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Y - drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.Right + drawMarginFrame + padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left Padding
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.X - drawMarginFrame; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right Padding
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.Right + drawMarginFrame;
-		//			c < frame.Right + drawMarginFrame - padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower Padding
-		//	for (int r = frame.Bottom + drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.Right + drawMarginFrame + padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
-		//	Rune vLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.VLine : (borderStyle == BorderStyle.Double ? driver.VDLine : ' ')) : ' ';
-		//	Rune uRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.URCorner : (borderStyle == BorderStyle.Double ? driver.URDCorner : ' ')) : ' ';
-		//	Rune uLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.ULCorner : (borderStyle == BorderStyle.Double ? driver.ULDCorner : ' ')) : ' ';
-		//	Rune lLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LLCorner : (borderStyle == BorderStyle.Double ? driver.LLDCorner : ' ')) : ' ';
-		//	Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
-
-		//	var text = "";
-		//	// Check the MarginFrame
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame;
-		//			c <= frame.Right + drawMarginFrame - 1; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			var rune = (Rune)driver.Contents [r, c, 0];
-		//			Assert.Equal (Color.Black, color.Background);
-		//			if (c == frame.X - drawMarginFrame && r == frame.Y - drawMarginFrame) {
-		//				Assert.Equal (uLCorner, rune);
-		//			} else if (c == frame.Right && r == frame.Y - drawMarginFrame) {
-		//				Assert.Equal (uRCorner, rune);
-		//			} else if (c == frame.X - drawMarginFrame && r == frame.Bottom) {
-		//				Assert.Equal (lLCorner, rune);
-		//			} else if (c == frame.Right && r == frame.Bottom) {
-		//				Assert.Equal (lRCorner, rune);
-		//			} else if (c >= frame.X && (r == frame.Y - drawMarginFrame
-		//				|| r == frame.Bottom)) {
-		//				Assert.Equal (hLine, rune);
-		//			} else if ((c == frame.X - drawMarginFrame || c == frame.Right)
-		//				&& r >= frame.Y && r <= frame.Bottom - drawMarginFrame) {
-		//				Assert.Equal (vLine, rune);
-		//			} else {
-		//				text += rune.ToString ();
-		//			}
-		//		}
-		//	}
-		//	Assert.Equal ("This is a test", text.Trim ());
-
-		//	// Check the upper Effect3D
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-		//		r < frame.Y - drawMarginFrame - sumThickness.Top; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left Effect3D
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-		//			c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right Effect3D
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower Effect3D
-		//	for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the Child frame
-		//	for (int r = frame.Y; r < frame.Y + frame.Height; r++) {
-		//		for (int c = frame.X; c < frame.X + frame.Width; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Foreground);
-		//			Assert.Equal (Color.Black, color.Background);
-		//		}
-		//	}
-		//}
-
 		[Fact, AutoInitShutdown]
 		public void DrawContent_With_Parent_Border ()
 		{
@@ -339,7 +77,6 @@ namespace Terminal.Gui.CoreTests {
 
 			var frame = frameView.Frame;
 			var drawMarginFrame = frameView.Border.DrawMarginFrame ? 1 : 0;
-			var sumThickness = frameView.Border.GetSumThickness ();
 			var borderThickness = frameView.Border.BorderThickness;
 			var padding = frameView.Border.Padding;
 
@@ -390,51 +127,53 @@ namespace Terminal.Gui.CoreTests {
 				}
 			}
 
-			// Check the upper Padding
-			for (int r = frame.Y + borderThickness.Top;
-				r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < frame.Right - borderThickness.Right; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.BrightGreen, color.Background);
-				}
-			}
-
-			// Check the left Padding
-			for (int r = frame.Y + sumThickness.Top;
-							r < frame.Bottom - sumThickness.Bottom; r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
 
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.BrightGreen, color.Background);
-				}
-			}
-
-			// Check the right Padding
-			// Draw the right Padding
-			for (int r = frame.Y + sumThickness.Top;
-				r < frame.Bottom - sumThickness.Bottom; r++) {
-				for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
-					c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
-
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.BrightGreen, color.Background);
-				}
-			}
-
-			// Check the lower Padding
-			for (int r = Math.Max (frame.Bottom - sumThickness.Bottom, frame.Y + borderThickness.Top);
-				r < frame.Bottom - borderThickness.Bottom; r++) {
-				for (int c = frame.X + borderThickness.Left;
-					c < frame.Right - borderThickness.Right; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.BrightGreen, color.Background);
-				}
-			}
+			//TODO: Re-do padding tests
+
+			//// Check the upper Padding
+			//for (int r = frame.Y + borderThickness.Top;
+			//	r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
+			//	for (int c = frame.X + borderThickness.Left;
+			//		c < frame.Right - borderThickness.Right; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.BrightGreen, color.Background);
+			//	}
+			//}
+			//// Check the left Padding
+			//for (int r = frame.Y + sumThickness.Top;
+			//				r < frame.Bottom - sumThickness.Bottom; r++) {
+			//	for (int c = frame.X + borderThickness.Left;
+			//		c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.BrightGreen, color.Background);
+			//	}
+			//}
+
+			//// Check the right Padding
+			//// Draw the right Padding
+			//for (int r = frame.Y + sumThickness.Top;
+			//	r < frame.Bottom - sumThickness.Bottom; r++) {
+			//	for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
+			//		c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
+
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.BrightGreen, color.Background);
+			//	}
+			//}
+
+			//// Check the lower Padding
+			//for (int r = Math.Max (frame.Bottom - sumThickness.Bottom, frame.Y + borderThickness.Top);
+			//	r < frame.Bottom - borderThickness.Bottom; r++) {
+			//	for (int c = frame.X + borderThickness.Left;
+			//		c < frame.Right - borderThickness.Right; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.BrightGreen, color.Background);
+			//	}
+			//}
 
 			Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
 				? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
@@ -449,97 +188,101 @@ namespace Terminal.Gui.CoreTests {
 			Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
 				? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
 
-			var text = "";
-			// Check the MarginFrame
-			for (int r = frame.Y + sumThickness.Top;
-				r < frame.Bottom - sumThickness.Bottom; r++) {
-				for (int c = frame.X + sumThickness.Left;
-					c <= frame.Right - sumThickness.Right - 1; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					var rune = (Rune)driver.Contents [r, c, 0];
-					Assert.Equal (Color.Black, color.Background);
-					if (c == frame.X + sumThickness.Left && r == frame.Y + sumThickness.Top) {
-						Assert.Equal (uLCorner, rune);
-					} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-						&& r == frame.Y + sumThickness.Top) {
-						Assert.Equal (uRCorner, rune);
-					} else if (c == frame.X + sumThickness.Left
-						&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-						Assert.Equal (lLCorner, rune);
-					} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-						&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-						Assert.Equal (lRCorner, rune);
-					} else if (c > frame.X + sumThickness.Left
-						&& (r == frame.Y + sumThickness.Top
-						|| r == frame.Bottom - drawMarginFrame - sumThickness.Bottom)) {
-						Assert.Equal (hLine, rune);
-					} else if ((c == frame.X + sumThickness.Left
-						|| c == frame.Right - drawMarginFrame - sumThickness.Right)
-						&& r >= frame.Y + drawMarginFrame + sumThickness.Top) {
-						Assert.Equal (vLine, rune);
-					} else {
-						text += rune.ToString ();
-					}
-				}
-			}
-			Assert.Equal ("This is a test", text.Trim ());
-
-			// Check the upper Effect3D
-			for (int r = frame.Y + effect3DOffset.Y;
-				r < frame.Y; r++) {
-				for (int c = frame.X + effect3DOffset.X;
-					c < frame.Right + effect3DOffset.X; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.DarkGray, color.Background);
-				}
-			}
-
-			// Check the left Effect3D
-			for (int r = frame.Y + effect3DOffset.Y;
-				r < frame.Bottom + effect3DOffset.Y; r++) {
-				for (int c = frame.X + effect3DOffset.X;
-					c < frame.X; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.DarkGray, color.Background);
-				}
-			}
-
-			// Check the right Effect3D
-			for (int r = frame.Y + effect3DOffset.Y;
-				r < frame.Bottom + effect3DOffset.Y; r++) {
-				for (int c = frame.Right;
-					c < frame.Right + effect3DOffset.X; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.DarkGray, color.Background);
-				}
-			}
-
-			// Check the lower Effect3D
-			for (int r = frame.Bottom;
-				r < frame.Bottom + effect3DOffset.Y; r++) {
-				for (int c = frame.X + effect3DOffset.X;
-					c < frame.Right + effect3DOffset.X; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.DarkGray, color.Background);
-				}
-			}
-
-			// Check the Child frame
-			for (int r = frame.Y + drawMarginFrame + sumThickness.Top;
-				r < frame.Bottom - drawMarginFrame - sumThickness.Bottom; r++) {
-				for (int c = frame.X + drawMarginFrame + sumThickness.Left;
-					c < frame.Right - drawMarginFrame - sumThickness.Right; c++) {
-
-					var color = (Attribute)driver.Contents [r, c, 1];
-					Assert.Equal (Color.BrightGreen, color.Foreground);
-					Assert.Equal (Color.Black, color.Background);
-				}
-			}
+			// TODO: redo margin tests
+			
+			//var text = "";
+			//// Check the MarginFrame
+			//for (int r = frame.Y + sumThickness.Top;
+			//	r < frame.Bottom - sumThickness.Bottom; r++) {
+			//	for (int c = frame.X + sumThickness.Left;
+			//		c <= frame.Right - sumThickness.Right - 1; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		var rune = (Rune)driver.Contents [r, c, 0];
+			//		Assert.Equal (Color.Black, color.Background);
+			//		if (c == frame.X + sumThickness.Left && r == frame.Y + sumThickness.Top) {
+			//			Assert.Equal (uLCorner, rune);
+			//		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
+			//			&& r == frame.Y + sumThickness.Top) {
+			//			Assert.Equal (uRCorner, rune);
+			//		} else if (c == frame.X + sumThickness.Left
+			//			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
+			//			Assert.Equal (lLCorner, rune);
+			//		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
+			//			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
+			//			Assert.Equal (lRCorner, rune);
+			//		} else if (c > frame.X + sumThickness.Left
+			//			&& (r == frame.Y + sumThickness.Top
+			//			|| r == frame.Bottom - drawMarginFrame - sumThickness.Bottom)) {
+			//			Assert.Equal (hLine, rune);
+			//		} else if ((c == frame.X + sumThickness.Left
+			//			|| c == frame.Right - drawMarginFrame - sumThickness.Right)
+			//			&& r >= frame.Y + drawMarginFrame + sumThickness.Top) {
+			//			Assert.Equal (vLine, rune);
+			//		} else {
+			//			text += rune.ToString ();
+			//		}
+			//	}
+			//}
+			//Assert.Equal ("This is a test", text.Trim ());
+
+			// TODO: Re-enable 3deffect
+			
+			//// Check the upper Effect3D
+			//for (int r = frame.Y + effect3DOffset.Y;
+			//	r < frame.Y; r++) {
+			//	for (int c = frame.X + effect3DOffset.X;
+			//		c < frame.Right + effect3DOffset.X; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.DarkGray, color.Background);
+			//	}
+			//}
+
+			//// Check the left Effect3D
+			//for (int r = frame.Y + effect3DOffset.Y;
+			//	r < frame.Bottom + effect3DOffset.Y; r++) {
+			//	for (int c = frame.X + effect3DOffset.X;
+			//		c < frame.X; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.DarkGray, color.Background);
+			//	}
+			//}
+
+			//// Check the right Effect3D
+			//for (int r = frame.Y + effect3DOffset.Y;
+			//	r < frame.Bottom + effect3DOffset.Y; r++) {
+			//	for (int c = frame.Right;
+			//		c < frame.Right + effect3DOffset.X; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.DarkGray, color.Background);
+			//	}
+			//}
+
+			//// Check the lower Effect3D
+			//for (int r = frame.Bottom;
+			//	r < frame.Bottom + effect3DOffset.Y; r++) {
+			//	for (int c = frame.X + effect3DOffset.X;
+			//		c < frame.Right + effect3DOffset.X; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.DarkGray, color.Background);
+			//	}
+			//}
+
+			//// Check the Child frame
+			//for (int r = frame.Y + drawMarginFrame + sumThickness.Top;
+			//	r < frame.Bottom - drawMarginFrame - sumThickness.Bottom; r++) {
+			//	for (int c = frame.X + drawMarginFrame + sumThickness.Left;
+			//		c < frame.Right - drawMarginFrame - sumThickness.Right; c++) {
+
+			//		var color = (Attribute)driver.Contents [r, c, 1];
+			//		Assert.Equal (Color.BrightGreen, color.Foreground);
+			//		Assert.Equal (Color.Black, color.Background);
+			//	}
+			//}
 		}
 
 		[Fact, AutoInitShutdown]

+ 0 - 479
UnitTests/Views/PanelViewTests.cs

@@ -1,479 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Terminal.Gui.ViewTests {
-	public class PanelViewTests {
-		readonly ITestOutputHelper output;
-
-		public PanelViewTests (ITestOutputHelper output)
-		{
-			this.output = output;
-		}
-
-		[Fact]
-		public void Constructor_Defaults ()
-		{
-			var pv = new PanelView ();
-
-			Assert.False (pv.CanFocus);
-			Assert.False (pv.Visible);
-			Assert.False (pv.UsePanelFrame);
-			Assert.Null (pv.Child);
-
-			pv = new PanelView (new Label ("This is a test."));
-
-			Assert.False (pv.CanFocus);
-			Assert.True (pv.Visible);
-			Assert.False (pv.UsePanelFrame);
-			Assert.NotNull (pv.Child);
-			Assert.NotNull (pv.Border);
-			Assert.NotNull (pv.Child.Border);
-		}
-
-		[Fact]
-		public void Child_Sets_To_Null_Remove_From_Subviews_PanelView ()
-		{
-			var pv = new PanelView (new Label ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-
-			pv.Child = null;
-			Assert.Null (pv.Child);
-			Assert.Equal (0, pv.Subviews [0].Subviews.Count);
-		}
-
-		[Fact]
-		public void Add_View_Also_Sets_Child ()
-		{
-			var pv = new PanelView ();
-			Assert.Null (pv.Child);
-			Assert.Equal (0, pv.Subviews [0].Subviews.Count);
-
-			pv.Add (new Label ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-		}
-
-		[Fact]
-		public void Add_More_Views_Remove_Last_Child_Before__Only_One_Is_Allowed ()
-		{
-			var pv = new PanelView (new Label ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-			Assert.IsType<Label> (pv.Child);
-
-			pv.Add (new TextField ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-			Assert.IsNotType<Label> (pv.Child);
-			Assert.IsType<TextField> (pv.Child);
-		}
-
-		[Fact]
-		public void Remove_RemoveAll_View_Also_Sets_Child_To_Null ()
-		{
-			var pv = new PanelView (new Label ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-
-			pv.Remove (pv.Child);
-			Assert.Null (pv.Child);
-			Assert.Equal (0, pv.Subviews [0].Subviews.Count);
-
-			pv = new PanelView (new Label ("This is a test."));
-			Assert.NotNull (pv.Child);
-			Assert.Equal (1, pv.Subviews [0].Subviews.Count);
-
-			pv.RemoveAll ();
-			Assert.Null (pv.Child);
-			Assert.Equal (0, pv.Subviews [0].Subviews.Count);
-		}
-
-		[Fact]
-		[AutoInitShutdown]
-		public void AdjustContainer_Without_Border ()
-		{
-			var top = Application.Top;
-			var win = new Window ();
-			var pv = new PanelView (new Label ("This is a test."));
-			win.Add (pv);
-			top.Add (win);
-
-			Application.Begin (top);
-
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-		}
-
-		[Fact]
-		[AutoInitShutdown]
-		public void AdjustContainer_With_Border_Absolute_Values ()
-		{
-			var top = Application.Top;
-			var win = new Window ();
-			var pv = new PanelView (new Label ("This is a test.") {
-				Border = new Border () {
-					BorderStyle = BorderStyle.Double,
-					BorderThickness = new Thickness (1, 2, 3, 4),
-					Padding = new Thickness (1, 2, 3, 4)
-				}
-			});
-			win.Add (pv);
-			top.Add (win);
-
-			Application.Begin (top);
-
-			Assert.False (pv.Child.Border.Effect3D);
-			Assert.Equal (new Rect (0, 0, 25, 15), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-
-			pv.Child.Border.Effect3D = true;
-
-			Assert.True (pv.Child.Border.Effect3D);
-			Assert.Equal (new Rect (0, 0, 25, 15), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-
-			pv.Child.Border.Effect3DOffset = new Point (-1, -1);
-
-			Assert.Equal (new Point (-1, -1), pv.Child.Border.Effect3DOffset);
-			Assert.Equal (new Rect (0, 0, 25, 15), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-		}
-
-		[Fact]
-		[AutoInitShutdown]
-		public void AdjustContainer_With_Border_Computed_Values ()
-		{
-			var top = Application.Top;
-			var win = new Window ();
-			var pv = new PanelView (new TextView () {
-				Width = Dim.Fill (),
-				Height = Dim.Fill (),
-				Border = new Border () {
-					BorderStyle = BorderStyle.Double,
-					BorderThickness = new Thickness (1, 2, 3, 4),
-					Padding = new Thickness (1, 2, 3, 4)
-				}
-			});
-
-			var pv1 = new PanelView (new TextView () {
-				Width = Dim.Fill (1),
-				Height = Dim.Fill (1),
-				Border = new Border () {
-					BorderStyle = BorderStyle.Double,
-					BorderThickness = new Thickness (1, 2, 3, 4),
-					Padding = new Thickness (1, 2, 3, 4)
-				}
-			});
-
-			var pv2 = new PanelView (new TextView () {
-				Width = Dim.Fill (2),
-				Height = Dim.Fill (2),
-				Border = new Border () {
-					BorderStyle = BorderStyle.Double,
-					BorderThickness = new Thickness (1, 2, 3, 4),
-					Padding = new Thickness (1, 2, 3, 4)
-				}
-			});
-
-			win.Add (pv, pv1, pv2);
-			top.Add (win);
-
-			Application.Begin (top);
-
-			Assert.Equal (new Rect (0, 0, 78, 23), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 68, 9), pv.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 77, 22), pv1.Frame);
-			Assert.Equal (new Rect (0, 0, 65, 6), pv1.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 76, 21), pv2.Frame);
-			Assert.Equal (new Rect (0, 0, 62, 3), pv2.Child.Frame);
-
-			pv.Child.Border.Effect3D = pv1.Child.Border.Effect3D = pv2.Child.Border.Effect3D = true;
-
-			Assert.True (pv.Child.Border.Effect3D);
-			Assert.Equal (new Rect (0, 0, 78, 23), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 68, 9), pv.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 77, 22), pv1.Frame);
-			Assert.Equal (new Rect (0, 0, 65, 6), pv1.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 76, 21), pv2.Frame);
-			Assert.Equal (new Rect (0, 0, 62, 3), pv2.Child.Frame);
-
-			pv.Child.Border.Effect3DOffset = pv1.Child.Border.Effect3DOffset = pv2.Child.Border.Effect3DOffset = new Point (-1, -1);
-
-			Assert.Equal (new Point (-1, -1), pv.Child.Border.Effect3DOffset);
-			Assert.Equal (new Rect (0, 0, 78, 23), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 68, 9), pv.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 77, 22), pv1.Frame);
-			Assert.Equal (new Rect (0, 0, 65, 6), pv1.Child.Frame);
-			Assert.Equal (new Rect (0, 0, 76, 21), pv2.Frame);
-			Assert.Equal (new Rect (0, 0, 62, 3), pv2.Child.Frame);
-		}
-
-		[Fact]
-		[AutoInitShutdown]
-		public void UsePanelFrame_False_PanelView_Always_Respect_The_PanelView_Upper_Left_Corner_Position_And_The_Child_Size ()
-		{
-			var top = Application.Top;
-			var win = new Window ();
-			var pv = new PanelView (new Label ("This is a test.")) {
-				X = 2,
-				Y = 4,
-				Width = 20,
-				Height = 10
-			};
-			var pv1 = new PanelView (new TextField (3, 4, 15, "This is a test.")) {
-				X = 2,
-				Y = 4,
-				Width = 20,
-				Height = 10
-			};
-			var pv2 = new PanelView (new TextView () {
-				X = 5,
-				Y = 6,
-				Width = Dim.Fill (),
-				Height = Dim.Fill ()
-			}) {
-				X = 2,
-				Y = 4,
-				Width = 20,
-				Height = 10
-			};
-
-			win.Add (pv, pv1, pv2);
-			top.Add (win);
-
-			Application.Begin (top);
-
-			Assert.False (pv.UsePanelFrame);
-			Assert.False (pv.Border.Effect3D);
-			Assert.Equal (pv.Child.Border, pv.Border);
-			Assert.False (pv1.UsePanelFrame);
-			Assert.False (pv1.Border.Effect3D);
-			Assert.Equal (pv1.Child.Border, pv1.Border);
-			Assert.False (pv2.UsePanelFrame);
-			Assert.False (pv2.Border.Effect3D);
-			Assert.Equal (pv2.Child.Border, pv2.Border);
-			Assert.Equal (new Rect (2, 4, 15, 1), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 18, 5), pv1.Frame);
-			Assert.Equal (new Rect (3, 4, 15, 1), pv1.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 76, 19), pv2.Frame);
-			Assert.Equal (new Rect (5, 6, 71, 13), pv2.Child.Frame);
-
-			pv.Border.Effect3D = pv1.Border.Effect3D = pv2.Border.Effect3D = true;
-
-			Assert.Equal (new Rect (2, 4, 15, 1), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 18, 5), pv1.Frame);
-			Assert.Equal (new Rect (3, 4, 15, 1), pv1.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 76, 19), pv2.Frame);
-			Assert.Equal (new Rect (5, 6, 71, 13), pv2.Child.Frame);
-
-			pv.Border.Effect3DOffset = pv1.Border.Effect3DOffset = pv2.Border.Effect3DOffset = new Point (-1, -1);
-
-			Assert.Equal (new Rect (2, 4, 15, 1), pv.Frame);
-			Assert.Equal (new Rect (0, 0, 15, 1), pv.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 18, 5), pv1.Frame);
-			Assert.Equal (new Rect (3, 4, 15, 1), pv1.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 76, 19), pv2.Frame);
-			Assert.Equal (new Rect (5, 6, 71, 13), pv2.Child.Frame);
-		}
-
-		[Fact]
-		[AutoInitShutdown]
-		public void UsePanelFrame_True_PanelView_Position_And_Size_Are_Used_Depending_On_Effect3DOffset ()
-		{
-			var top = Application.Top;
-			var win = new Window ();
-			var pv = new PanelView (new TextView () {
-				X = 2,
-				Y = 4,
-				Width = 20,
-				Height = 10
-			}) {
-				X = 5,
-				Y = 6,
-				Width = Dim.Fill (),
-				Height = Dim.Fill (),
-				UsePanelFrame = true
-			};
-			var pv1 = new PanelView (new TextView () {
-				X = 5,
-				Y = 6,
-				Width = Dim.Fill (),
-				Height = Dim.Fill ()
-			}) {
-				X = 2,
-				Y = 4,
-				Width = 20,
-				Height = 10,
-				UsePanelFrame = true
-			};
-
-			win.Add (pv, pv1);
-			top.Add (win);
-
-			Application.Begin (top);
-
-			Assert.Equal (new Rect (5, 6, 73, 17), pv.Frame);
-			Assert.Equal (new Rect (2, 4, 20, 10), pv.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 20, 10), pv1.Frame);
-			Assert.Equal (new Rect (5, 6, 15, 4), pv1.Child.Frame);
-
-			pv.Border.Effect3D = pv1.Border.Effect3D = true;
-
-			Assert.Equal (new Rect (5, 6, 73, 17), pv.Frame);
-			Assert.Equal (new Rect (2, 4, 20, 10), pv.Child.Frame);
-			Assert.Equal (new Rect (2, 4, 20, 10), pv1.Frame);
-			Assert.Equal (new Rect (5, 6, 15, 4), pv1.Child.Frame);
-
-			pv.Border.Effect3DOffset = pv1.Border.Effect3DOffset = new Point (-1, -1);
-
-			Assert.Equal (new Rect (6, 7, 73, 17), pv.Frame);
-			Assert.Equal (new Rect (2, 4, 20, 10), pv.Child.Frame);
-			Assert.Equal (new Rect (3, 5, 20, 10), pv1.Frame);
-			Assert.Equal (new Rect (5, 6, 15, 4), pv1.Child.Frame);
-		}
-
-//		[Fact, AutoInitShutdown]
-//		public void Setting_Child_Size_Disable_AutoSize ()
-//		{
-//			var top = Application.Top;
-//			var win = new Window ();
-//			var label = new Label () {
-//				ColorScheme = Colors.TopLevel,
-//				Text = "This is a test\nwith a \nPanelView",
-//				TextAlignment = TextAlignment.Centered,
-//				Width = 24,
-//				Height = 13,
-//				AutoSize = false
-//			};
-//			var pv = new PanelView (label) {
-//				Width = 24,
-//				Height = 13,
-//				Border = new Border () {
-//					BorderStyle = BorderStyle.Single,
-//					DrawMarginFrame = true,
-//					BorderThickness = new Thickness (2),
-//					BorderBrush = Color.Red,
-//					Padding = new Thickness (2),
-//					Background = Color.BrightGreen,
-//					Effect3D = true
-//				},
-//			};
-//			win.Add (pv);
-//			top.Add (win);
-
-//			Application.Begin (top);
-
-//			Assert.False (label.AutoSize);
-//			Assert.Equal (new Rect (0, 0, 24, 13), label.Frame);
-//			Assert.Equal (new Rect (0, 0, 34, 23), pv.Frame);
-//			Assert.Equal (new Rect (0, 0, 80, 25), win.Frame);
-//			Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame);
-
-//			var expected = @"
-//┌──────────────────────────────────────────────────────────────────────────────┐
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│    ┌────────────────────────┐                                                │
-//│    │     This is a test     │                                                │
-//│    │        with a          │                                                │
-//│    │       PanelView        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    │                        │                                                │
-//│    └────────────────────────┘                                                │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//└──────────────────────────────────────────────────────────────────────────────┘
-//";
-
-//			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-//			Assert.Equal (new Rect (0, 0, 80, 25), pos);
-//		}
-
-//		[Fact, AutoInitShutdown]
-//		public void Not_Setting_Child_Size_Default_AutoSize_True ()
-//		{
-//			var top = Application.Top;
-//			var win = new Window ();
-//			var label = new Label () {
-//				ColorScheme = Colors.TopLevel,
-//				Text = "This is a test\nwith a \nPanelView",
-//				TextAlignment = TextAlignment.Centered
-//			};
-//			var pv = new PanelView (label) {
-//				Width = 24,
-//				Height = 13,
-//				Border = new Border () {
-//					BorderStyle = BorderStyle.Single,
-//					DrawMarginFrame = true,
-//					BorderThickness = new Thickness (2),
-//					BorderBrush = Color.Red,
-//					Padding = new Thickness (2),
-//					Background = Color.BrightGreen,
-//					Effect3D = true
-//				},
-//			};
-//			win.Add (pv);
-//			top.Add (win);
-
-//			Application.Begin (top);
-
-//			Assert.True (label.AutoSize);
-//			Assert.False (pv.UsePanelFrame);
-//			Assert.Equal (new Rect (0, 0, 14, 3), label.Frame);
-//			Assert.Equal (new Rect (0, 0, 24, 13), pv.Frame);
-//			Assert.Equal (new Rect (0, 0, 80, 25), win.Frame);
-//			Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame);
-
-//			var expected = @"
-//┌──────────────────────────────────────────────────────────────────────────────┐
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│    ┌──────────────┐                                                          │
-//│    │This is a test│                                                          │
-//│    │   with a     │                                                          │
-//│    │  PanelView   │                                                          │
-//│    └──────────────┘                                                          │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//│                                                                              │
-//└──────────────────────────────────────────────────────────────────────────────┘
-//";
-
-//			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-//			Assert.Equal (new Rect (0, 0, 80, 25), pos);
-//		}
-	}
-}