diff --git a/Terminal.Gui/Core/Border.cs b/Terminal.Gui/Core/Border.cs index 84faab1c3..bff8c13c1 100644 --- a/Terminal.Gui/Core/Border.cs +++ b/Terminal.Gui/Core/Border.cs @@ -90,7 +90,7 @@ namespace Terminal.Gui { public bool Effect3D { get; set; } public Thickness BorderThickness { get; set; } public object Effect3DBrush { get; set; } - public Thickness Padding { get; set; } + public Thickness PaddingThickness { get; set; } /// /// Invoke the event. diff --git a/Terminal.Gui/Core/Window.cs b/Terminal.Gui/Core/Window.cs index 2747e1021..9ee9190f5 100644 --- a/Terminal.Gui/Core/Window.cs +++ b/Terminal.Gui/Core/Window.cs @@ -109,7 +109,7 @@ namespace Terminal.Gui { // TODO: v2 this is a hack until Border gets refactored Border = new Border () { BorderStyle = DefaultBorderStyle, - Padding = new Thickness (padding), + PaddingThickness = new Thickness (padding), }; } else { Border = border; @@ -124,7 +124,8 @@ namespace Terminal.Gui { BorderFrame.ColorScheme = ColorScheme; BorderFrame.Data = "BorderFrame"; - Padding.Thickness = Border.Padding; + // TODO: Hack until Border is refactored + Padding.Thickness = Border.PaddingThickness ?? Padding.Thickness; } /// diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs index d31bca75b..12df7780a 100644 --- a/Terminal.Gui/Views/FrameView.cs +++ b/Terminal.Gui/Views/FrameView.cs @@ -102,7 +102,7 @@ namespace Terminal.Gui { public override void BeginInit () { base.BeginInit (); - BorderFrame.Thickness = new Thickness (2); + BorderFrame.Thickness = new Thickness (1); BorderFrame.BorderStyle = Border.BorderStyle; BorderFrame.ColorScheme = ColorScheme; BorderFrame.Data = "BorderFrame"; diff --git a/Terminal.Gui/Windows/Wizard.cs b/Terminal.Gui/Windows/Wizard.cs index e82093e62..fe716a2af 100644 --- a/Terminal.Gui/Windows/Wizard.cs +++ b/Terminal.Gui/Windows/Wizard.cs @@ -356,7 +356,7 @@ namespace Terminal.Gui { // the left and right edge ButtonAlignment = ButtonAlignments.Justify; this.Border.BorderStyle = BorderStyle.Double; - this.Border.Padding = new Thickness (0); + this.Border.PaddingThickness = new Thickness (0); //// Add a horiz separator //var separator = new LineView (Graphs.Orientation.Horizontal) { diff --git a/UICatalog/Scenarios/BordersComparisons.cs b/UICatalog/Scenarios/BordersComparisons.cs index abfbca118..f12cc7777 100644 --- a/UICatalog/Scenarios/BordersComparisons.cs +++ b/UICatalog/Scenarios/BordersComparisons.cs @@ -10,25 +10,17 @@ namespace UICatalog.Scenarios { Application.Init (); var borderStyle = BorderStyle.Double; - var drawMarginFrame = false; var borderThickness = new Thickness (1, 2, 3, 4); - var borderBrush = Color.BrightMagenta; + var padding = 1; - var padding = new Thickness (1, 2, 3, 4); - var background = Color.Cyan; - var effect3D = true; + Application.Top.Text = $"Border Thickness: {borderThickness}\nPadding: {padding}"; - var win = new Window (new Rect (5, 5, 40, 20), "Test", 8, - new Border () { + var win = new Window (new Rect (5, 5, 40, 20), "Window", + padding: padding, + border: new Border () { BorderStyle = borderStyle, - DrawMarginFrame = drawMarginFrame, - BorderThickness = borderThickness, - ForgroundColor = borderBrush, - Padding = padding, - BackgroundColor = background, - Effect3D = effect3D - }) { - }; + BorderThickness = borderThickness + }); var tf1 = new TextField ("1234567890") { Width = 10 }; @@ -55,19 +47,10 @@ namespace UICatalog.Scenarios { win.Add (tf1, button, label, tv, tf2); Application.Top.Add (win); - var top2 = new Window (new Rect (50, 5, 40, 20), "Test2", 0, - new Border () { - BorderStyle = borderStyle, - DrawMarginFrame = drawMarginFrame, - BorderThickness = borderThickness, - ForgroundColor = borderBrush, - Padding = padding, - BackgroundColor = background, - Effect3D = effect3D, - //Title = "Test2" - }) { - ColorScheme = Colors.Base, - }; + var topLevel = new Toplevel (new Rect (50, 5, 40, 20)); + //topLevel.BorderFrame.Thickness = borderThickness; + //topLevel.BorderFrame.BorderStyle = borderStyle; + //topLevel.Padding.Thickness = paddingThickness; var tf3 = new TextField ("1234567890") { Width = 10 }; @@ -91,19 +74,18 @@ namespace UICatalog.Scenarios { Y = Pos.AnchorEnd (1), Width = 10 }; - top2.Add (tf3, button2, label2, tv2, tf4); - Application.Top.Add (top2); + topLevel.Add (tf3, button2, label2, tv2, tf4); + Application.Top.Add (topLevel); - var frm = new FrameView (new Rect (95, 5, 40, 20), "Test3", null, - new Border () { + var frameView = new FrameView (new Rect (95, 5, 40, 20), "FrameView", null, + border: new Border () { BorderStyle = borderStyle, - DrawMarginFrame = drawMarginFrame, - BorderThickness = borderThickness, - ForgroundColor = borderBrush, - Padding = padding, - BackgroundColor = background, - Effect3D = effect3D - }) { ColorScheme = Colors.Base }; + BorderThickness = borderThickness + } + ); + //frameView.BorderFrame.Thickness = borderThickness; + //frameView.BorderFrame.BorderStyle = borderStyle; + //frameView.Padding.Thickness = paddingThickness; var tf5 = new TextField ("1234567890") { Width = 10 }; @@ -127,8 +109,8 @@ namespace UICatalog.Scenarios { Y = Pos.AnchorEnd (1), Width = 10 }; - frm.Add (tf5, button3, label3, tv3, tf6); - Application.Top.Add (frm); + frameView.Add (tf5, button3, label3, tv3, tf6); + Application.Top.Add (frameView); Application.Run (); } diff --git a/UICatalog/Scenarios/BordersOnContainers.cs b/UICatalog/Scenarios/BordersOnContainers.cs index b828e70e2..0e73c5d4a 100644 --- a/UICatalog/Scenarios/BordersOnContainers.cs +++ b/UICatalog/Scenarios/BordersOnContainers.cs @@ -24,7 +24,7 @@ namespace UICatalog.Scenarios { DrawMarginFrame = drawMarginFrame, BorderThickness = borderThickness, ForgroundColor = borderBrush, - Padding = padding, + PaddingThickness = padding, BackgroundColor = background, Effect3D = effect3D, //Title = typeName @@ -66,16 +66,16 @@ namespace UICatalog.Scenarios { }; paddingTopEdit.TextChanging += (e) => { try { - smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left, - int.Parse (e.NewText.ToString ()), smartView.Border.Padding.Right, - smartView.Border.Padding.Bottom); + smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left, + int.Parse (e.NewText.ToString ()), smartView.Border.PaddingThickness.Right, + smartView.Border.PaddingThickness.Bottom); } catch { if (!e.NewText.IsEmpty) { e.Cancel = true; } } }; - paddingTopEdit.Text = $"{smartView.Border.Padding.Top}"; + paddingTopEdit.Text = $"{smartView.Border.PaddingThickness.Top}"; Add (paddingTopEdit); @@ -86,16 +86,16 @@ namespace UICatalog.Scenarios { }; paddingLeftEdit.TextChanging += (e) => { try { - smartView.Border.Padding = new Thickness (int.Parse (e.NewText.ToString ()), - smartView.Border.Padding.Top, smartView.Border.Padding.Right, - smartView.Border.Padding.Bottom); + smartView.Border.PaddingThickness = new Thickness (int.Parse (e.NewText.ToString ()), + smartView.Border.PaddingThickness.Top, smartView.Border.PaddingThickness.Right, + smartView.Border.PaddingThickness.Bottom); } catch { if (!e.NewText.IsEmpty) { e.Cancel = true; } } }; - paddingLeftEdit.Text = $"{smartView.Border.Padding.Left}"; + paddingLeftEdit.Text = $"{smartView.Border.PaddingThickness.Left}"; Add (paddingLeftEdit); var paddingRightEdit = new TextField ("") { @@ -105,16 +105,16 @@ namespace UICatalog.Scenarios { }; paddingRightEdit.TextChanging += (e) => { try { - smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left, - smartView.Border.Padding.Top, int.Parse (e.NewText.ToString ()), - smartView.Border.Padding.Bottom); + smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left, + smartView.Border.PaddingThickness.Top, int.Parse (e.NewText.ToString ()), + smartView.Border.PaddingThickness.Bottom); } catch { if (!e.NewText.IsEmpty) { e.Cancel = true; } } }; - paddingRightEdit.Text = $"{smartView.Border.Padding.Right}"; + paddingRightEdit.Text = $"{smartView.Border.PaddingThickness.Right}"; Add (paddingRightEdit); var paddingBottomEdit = new TextField ("") { @@ -124,8 +124,8 @@ namespace UICatalog.Scenarios { }; paddingBottomEdit.TextChanging += (e) => { try { - smartView.Border.Padding = new Thickness (smartView.Border.Padding.Left, - smartView.Border.Padding.Top, smartView.Border.Padding.Right, + smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left, + smartView.Border.PaddingThickness.Top, smartView.Border.PaddingThickness.Right, int.Parse (e.NewText.ToString ())); } catch { if (!e.NewText.IsEmpty) { @@ -133,7 +133,7 @@ namespace UICatalog.Scenarios { } } }; - paddingBottomEdit.Text = $"{smartView.Border.Padding.Bottom}"; + paddingBottomEdit.Text = $"{smartView.Border.PaddingThickness.Bottom}"; Add (paddingBottomEdit); var replacePadding = new Button ("Replace all based on top") { @@ -141,7 +141,7 @@ namespace UICatalog.Scenarios { Y = 5 }; replacePadding.Clicked += () => { - smartView.Border.Padding = new Thickness (smartView.Border.Padding.Top); + smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Top); if (paddingTopEdit.Text.IsEmpty) { paddingTopEdit.Text = "0"; } diff --git a/UICatalog/Scenarios/TileViewExperiment.cs b/UICatalog/Scenarios/TileViewExperiment.cs index bdac9a226..6182e1e70 100644 --- a/UICatalog/Scenarios/TileViewExperiment.cs +++ b/UICatalog/Scenarios/TileViewExperiment.cs @@ -67,7 +67,7 @@ namespace UICatalog.Scenarios { BorderStyle = BorderStyle.Single, BorderThickness = new Thickness (1), DrawMarginFrame = true, - Padding = new Thickness(1), + PaddingThickness = new Thickness(1), ForgroundColor = Color.BrightMagenta, } }; diff --git a/UnitTests/Core/BorderTests.cs b/UnitTests/Core/BorderTests.cs index c42b5792b..0693af065 100644 --- a/UnitTests/Core/BorderTests.cs +++ b/UnitTests/Core/BorderTests.cs @@ -22,7 +22,7 @@ namespace Terminal.Gui.CoreTests { Assert.Equal (Thickness.Empty, b.BorderThickness); Assert.Equal (Color.Black, b.ForgroundColor); Assert.Equal (Color.Black, b.BackgroundColor); - Assert.Equal (Thickness.Empty, b.Padding); + Assert.Equal (Thickness.Empty, b.PaddingThickness); Assert.False (b.Effect3D); Assert.Equal (new Point (1, 1), b.Effect3DOffset); Assert.Null (b.Effect3DBrush); @@ -570,7 +570,7 @@ namespace Terminal.Gui.CoreTests { Border = new Border () { BorderStyle = BorderStyle.Single, DrawMarginFrame = true, - Padding = new Thickness (1), + PaddingThickness = new Thickness (1), ForgroundColor = Color.White } };