|
@@ -168,7 +168,6 @@ namespace Terminal.Gui {
|
|
|
if (border == null) {
|
|
|
Border = new Border () {
|
|
|
BorderStyle = BorderStyle.Single,
|
|
|
- BorderBrush = ColorScheme.Normal.Background,
|
|
|
Title = (ustring)title
|
|
|
};
|
|
|
} else {
|
|
@@ -318,8 +317,8 @@ namespace Terminal.Gui {
|
|
|
private BorderStyle borderStyle;
|
|
|
private bool drawMarginFrame;
|
|
|
private Thickness borderThickness;
|
|
|
- private Color borderBrush;
|
|
|
- private Color background;
|
|
|
+ private Color? borderBrush;
|
|
|
+ private Color? background;
|
|
|
private Thickness padding;
|
|
|
private bool effect3D;
|
|
|
private Point effect3DOffset = new Point (1, 1);
|
|
@@ -374,7 +373,7 @@ namespace Terminal.Gui {
|
|
|
/// Gets or sets the <see cref="Color"/> that draws the outer border color.
|
|
|
/// </summary>
|
|
|
public Color BorderBrush {
|
|
|
- get => borderBrush;
|
|
|
+ get => borderBrush != null ? (Color)borderBrush : (Color)(-1);
|
|
|
set {
|
|
|
borderBrush = value;
|
|
|
OnBorderChanged ();
|
|
@@ -385,7 +384,7 @@ namespace Terminal.Gui {
|
|
|
/// Gets or sets the <see cref="Color"/> that fills the area between the bounds of a <see cref="Border"/>.
|
|
|
/// </summary>
|
|
|
public Color Background {
|
|
|
- get => background;
|
|
|
+ get => background != null ? (Color)background : (Color)(-1);
|
|
|
set {
|
|
|
background = value;
|
|
|
OnBorderChanged ();
|
|
@@ -439,7 +438,6 @@ namespace Terminal.Gui {
|
|
|
set {
|
|
|
child = value;
|
|
|
if (child != null && Parent != null) {
|
|
|
- Parent.Initialized += Parent_Initialized;
|
|
|
Parent.Removed += Parent_Removed;
|
|
|
}
|
|
|
}
|
|
@@ -452,30 +450,6 @@ namespace Terminal.Gui {
|
|
|
child.Removed -= Parent_Removed;
|
|
|
}
|
|
|
|
|
|
- private void Parent_Initialized (object s, EventArgs e)
|
|
|
- {
|
|
|
- SetMarginFrameTitleBrush ();
|
|
|
- child.Initialized -= Parent_Initialized;
|
|
|
- }
|
|
|
-
|
|
|
- private void SetMarginFrameTitleBrush ()
|
|
|
- {
|
|
|
- if (child != null) {
|
|
|
- var view = Parent?.Border != null ? Parent : child;
|
|
|
- if (view.ColorScheme != null) {
|
|
|
- if (borderBrush == default) {
|
|
|
- BorderBrush = view.GetNormalColor ().Foreground;
|
|
|
- }
|
|
|
- if (background == default) {
|
|
|
- Background = view.GetNormalColor ().Background;
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- BorderBrush = default;
|
|
|
- Background = default;
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Gets the parent <see cref="Child"/> parent if any.
|
|
|
/// </summary>
|
|
@@ -609,7 +583,8 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
// Draw border thickness
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush));
|
|
|
+ SetBorderBrush (driver);
|
|
|
+
|
|
|
Child.Clear (borderRect);
|
|
|
|
|
|
borderRect = new Rect () {
|
|
@@ -624,7 +599,7 @@ namespace Terminal.Gui {
|
|
|
Child.Clear (borderRect);
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
+ SetBorderBrushBackground (driver);
|
|
|
|
|
|
// Draw margin frame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -661,7 +636,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
var savedAttribute = driver.GetAttribute ();
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush));
|
|
|
+ SetBorderBrush (driver);
|
|
|
|
|
|
// Draw the upper BorderThickness
|
|
|
for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
|
|
@@ -703,7 +678,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (Background));
|
|
|
+ SetBackground (driver);
|
|
|
|
|
|
// Draw the upper Padding
|
|
|
for (int r = frame.Y - drawMarginFrame - padding.Top;
|
|
@@ -745,7 +720,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
+ SetBorderBrushBackground (driver);
|
|
|
|
|
|
// Draw the MarginFrame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -816,7 +791,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
var savedAttribute = driver.GetAttribute ();
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush));
|
|
|
+ SetBorderBrush (driver);
|
|
|
|
|
|
// Draw the upper BorderThickness
|
|
|
for (int r = frame.Y;
|
|
@@ -858,7 +833,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (Background));
|
|
|
+ SetBackground (driver);
|
|
|
|
|
|
// Draw the upper Padding
|
|
|
for (int r = frame.Y + borderThickness.Top;
|
|
@@ -900,7 +875,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
+ SetBorderBrushBackground (driver);
|
|
|
|
|
|
// Draw the MarginFrame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -962,6 +937,37 @@ namespace Terminal.Gui {
|
|
|
driver.SetAttribute (savedAttribute);
|
|
|
}
|
|
|
|
|
|
+ private void SetBorderBrushBackground (ConsoleDriver driver)
|
|
|
+ {
|
|
|
+ if (borderBrush != null && background != null) {
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
+ } else if (borderBrush != null && background == null) {
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Parent.ColorScheme.Normal.Background));
|
|
|
+ } else if (borderBrush == null && background != null) {
|
|
|
+ driver.SetAttribute (new Attribute (Parent.ColorScheme.Normal.Foreground, Background));
|
|
|
+ } else {
|
|
|
+ driver.SetAttribute (Parent.ColorScheme.Normal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetBackground (ConsoleDriver driver)
|
|
|
+ {
|
|
|
+ if (background != null) {
|
|
|
+ driver.SetAttribute (new Attribute (Background));
|
|
|
+ } else {
|
|
|
+ driver.SetAttribute (new Attribute (Parent.ColorScheme.Normal.Background));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetBorderBrush (ConsoleDriver driver)
|
|
|
+ {
|
|
|
+ if (borderBrush != null) {
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush));
|
|
|
+ } else {
|
|
|
+ driver.SetAttribute (new Attribute (Parent.ColorScheme.Normal.Foreground));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Attribute GetEffect3DBrush ()
|
|
|
{
|
|
|
return Effect3DBrush == null
|
|
@@ -989,9 +995,8 @@ namespace Terminal.Gui {
|
|
|
{
|
|
|
var driver = Application.Driver;
|
|
|
if (DrawMarginFrame) {
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
- if (view.HasFocus)
|
|
|
- driver.SetAttribute (new Attribute (Child.ColorScheme.HotNormal.Foreground, Background));
|
|
|
+ SetBorderBrushBackground (driver);
|
|
|
+ SetHotNormalBackground (view, driver);
|
|
|
var padding = view.Border.GetSumThickness ();
|
|
|
Rect scrRect;
|
|
|
if (view == Child) {
|
|
@@ -1007,6 +1012,17 @@ namespace Terminal.Gui {
|
|
|
driver.SetAttribute (Child.GetNormalColor ());
|
|
|
}
|
|
|
|
|
|
+ private void SetHotNormalBackground (View view, ConsoleDriver driver)
|
|
|
+ {
|
|
|
+ if (view.HasFocus) {
|
|
|
+ if (background != null) {
|
|
|
+ driver.SetAttribute (new Attribute (Child.ColorScheme.HotNormal.Foreground, Background));
|
|
|
+ } else {
|
|
|
+ driver.SetAttribute (Child.ColorScheme.HotNormal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Draws the <see cref="View.Text"/> to the screen.
|
|
|
/// </summary>
|
|
@@ -1016,10 +1032,8 @@ namespace Terminal.Gui {
|
|
|
{
|
|
|
var driver = Application.Driver;
|
|
|
if (DrawMarginFrame) {
|
|
|
- driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
- if (view.HasFocus) {
|
|
|
- driver.SetAttribute (new Attribute (view.ColorScheme.HotNormal.Foreground, Background));
|
|
|
- }
|
|
|
+ SetBorderBrushBackground (driver);
|
|
|
+ SetHotNormalBackground (view, driver);
|
|
|
var padding = Parent.Border.GetSumThickness ();
|
|
|
var scrRect = Parent.ViewToScreen (new Rect (0, 0, rect.Width, rect.Height));
|
|
|
driver.DrawWindowTitle (scrRect, view.Text,
|