mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
Updated BordersComparison partially
This commit is contained in:
@@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoke the <see cref="BorderChanged"/> event.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user