|
@@ -284,7 +284,7 @@ namespace Terminal.Gui {
|
|
|
/// <inheritdoc/>
|
|
|
public override void OnCanFocusChanged ()
|
|
|
{
|
|
|
- if (Border.Child != null) {
|
|
|
+ if (Border?.Child != null) {
|
|
|
Border.Child.CanFocus = CanFocus;
|
|
|
}
|
|
|
base.OnCanFocusChanged ();
|
|
@@ -375,8 +375,10 @@ namespace Terminal.Gui {
|
|
|
public Color BorderBrush {
|
|
|
get => borderBrush != null ? (Color)borderBrush : (Color)(-1);
|
|
|
set {
|
|
|
- borderBrush = value;
|
|
|
- OnBorderChanged ();
|
|
|
+ if (Enum.IsDefined (typeof (Color), value)) {
|
|
|
+ borderBrush = value;
|
|
|
+ OnBorderChanged ();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -386,8 +388,10 @@ namespace Terminal.Gui {
|
|
|
public Color Background {
|
|
|
get => background != null ? (Color)background : (Color)(-1);
|
|
|
set {
|
|
|
- background = value;
|
|
|
- OnBorderChanged ();
|
|
|
+ if (Enum.IsDefined (typeof (Color), value)) {
|
|
|
+ background = value;
|
|
|
+ OnBorderChanged ();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -445,12 +449,10 @@ namespace Terminal.Gui {
|
|
|
|
|
|
private void Parent_Removed (View obj)
|
|
|
{
|
|
|
- if (borderBrush != null)
|
|
|
- {
|
|
|
+ if (borderBrush != null) {
|
|
|
BorderBrush = default;
|
|
|
}
|
|
|
- if (background != null)
|
|
|
- {
|
|
|
+ if (background != null) {
|
|
|
Background = default;
|
|
|
}
|
|
|
child.Removed -= Parent_Removed;
|
|
@@ -800,7 +802,7 @@ namespace Terminal.Gui {
|
|
|
SetBorderBrush (driver);
|
|
|
|
|
|
// Draw the upper BorderThickness
|
|
|
- for (int r = frame.Y;
|
|
|
+ for (int r = Math.Max (frame.Y, 0);
|
|
|
r < Math.Min (frame.Y + borderThickness.Top, frame.Bottom); r++) {
|
|
|
for (int c = frame.X;
|
|
|
c < Math.Min (frame.Right, driver.Cols); c++) {
|
|
@@ -810,7 +812,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
// Draw the left BorderThickness
|
|
|
- for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
|
|
|
+ for (int r = Math.Max (Math.Min (frame.Y + borderThickness.Top, frame.Bottom), 0);
|
|
|
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++) {
|
|
@@ -820,7 +822,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
// Draw the right BorderThickness
|
|
|
- for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
|
|
|
+ for (int r = Math.Max (Math.Min (frame.Y + borderThickness.Top, frame.Bottom), 0);
|
|
|
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++) {
|
|
@@ -842,7 +844,7 @@ namespace Terminal.Gui {
|
|
|
SetBackground (driver);
|
|
|
|
|
|
// Draw the upper Padding
|
|
|
- for (int r = frame.Y + borderThickness.Top;
|
|
|
+ for (int r = Math.Max (frame.Y + borderThickness.Top, 0);
|
|
|
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++) {
|
|
@@ -852,7 +854,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
// Draw the left Padding
|
|
|
- for (int r = frame.Y + sumThickness.Top;
|
|
|
+ for (int r = Math.Max (frame.Y + sumThickness.Top, 0);
|
|
|
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++) {
|
|
@@ -862,7 +864,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
// Draw the right Padding
|
|
|
- for (int r = frame.Y + sumThickness.Top;
|
|
|
+ for (int r = Math.Max (frame.Y + sumThickness.Top, 0);
|
|
|
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++) {
|