|
@@ -331,6 +331,7 @@ namespace Terminal.Gui {
|
|
|
private Point effect3DOffset = new Point (1, 1);
|
|
|
private Attribute? effect3DBrush;
|
|
|
private ustring title = ustring.Empty;
|
|
|
+ private View child;
|
|
|
|
|
|
/// <summary>
|
|
|
/// Specifies the <see cref="Gui.BorderStyle"/> for a view.
|
|
@@ -447,8 +448,47 @@ namespace Terminal.Gui {
|
|
|
/// <summary>
|
|
|
/// Gets or sets the single child element of a <see cref="View"/>.
|
|
|
/// </summary>
|
|
|
- [JsonIgnore]
|
|
|
- public View Child { get; set; }
|
|
|
+ public View Child {
|
|
|
+ get => child;
|
|
|
+ set {
|
|
|
+ child = value;
|
|
|
+ if (child != null && Parent != null) {
|
|
|
+ Parent.Initialized += Parent_Initialized;
|
|
|
+ Parent.Removed += Parent_Removed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Parent_Removed (View obj)
|
|
|
+ {
|
|
|
+ BorderBrush = default;
|
|
|
+ Background = default;
|
|
|
+ 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.
|
|
@@ -611,7 +651,7 @@ namespace Terminal.Gui {
|
|
|
Child.Clear (borderRect);
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (savedAttribute);
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
|
|
|
// Draw margin frame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -635,6 +675,7 @@ namespace Terminal.Gui {
|
|
|
driver.DrawWindowFrame (borderRect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill: true, this);
|
|
|
}
|
|
|
}
|
|
|
+ driver.SetAttribute (savedAttribute);
|
|
|
}
|
|
|
|
|
|
private void DrawChildBorder (Rect frame, bool fill = true)
|
|
@@ -747,7 +788,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (savedAttribute);
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
|
|
|
// Draw the MarginFrame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -944,7 +985,7 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- driver.SetAttribute (savedAttribute);
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
|
|
|
// Draw the MarginFrame
|
|
|
if (DrawMarginFrame) {
|
|
@@ -1026,9 +1067,9 @@ namespace Terminal.Gui {
|
|
|
{
|
|
|
var driver = Application.Driver;
|
|
|
if (DrawMarginFrame) {
|
|
|
- driver.SetAttribute (Child.GetNormalColor ());
|
|
|
- if (Child.HasFocus)
|
|
|
- driver.SetAttribute (Child.ColorScheme.HotNormal);
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
+ if (view.HasFocus)
|
|
|
+ driver.SetAttribute (new Attribute (Child.ColorScheme.HotNormal.Foreground, Background));
|
|
|
var padding = view.Border.GetSumThickness ();
|
|
|
Rect scrRect;
|
|
|
if (view == Child) {
|
|
@@ -1037,7 +1078,7 @@ namespace Terminal.Gui {
|
|
|
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,
|
|
|
+ driver.DrawWindowTitle (scrRect, Parent.Border.Title,
|
|
|
padding.Left, padding.Top, padding.Right, padding.Bottom);
|
|
|
}
|
|
|
}
|
|
@@ -1053,9 +1094,9 @@ namespace Terminal.Gui {
|
|
|
{
|
|
|
var driver = Application.Driver;
|
|
|
if (DrawMarginFrame) {
|
|
|
- driver.SetAttribute (view.GetNormalColor ());
|
|
|
+ driver.SetAttribute (new Attribute (BorderBrush, Background));
|
|
|
if (view.HasFocus) {
|
|
|
- driver.SetAttribute (view.ColorScheme.HotNormal);
|
|
|
+ driver.SetAttribute (new Attribute (view.ColorScheme.HotNormal.Foreground, Background));
|
|
|
}
|
|
|
var padding = Parent.Border.GetSumThickness ();
|
|
|
var scrRect = Parent.ViewToScreen (new Rect (0, 0, rect.Width, rect.Height));
|