mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
This commit is contained in:
@@ -165,7 +165,6 @@ namespace Terminal.Gui {
|
||||
{
|
||||
ColorScheme = Colors.TopLevel;
|
||||
Text = title ?? "";
|
||||
Frame = frame;
|
||||
if (border == null) {
|
||||
Border = new Border () {
|
||||
BorderStyle = BorderStyle.Single,
|
||||
@@ -174,26 +173,30 @@ namespace Terminal.Gui {
|
||||
} else {
|
||||
Border = border;
|
||||
}
|
||||
AdjustContentView (frame);
|
||||
}
|
||||
|
||||
void AdjustContentView (Rect frame)
|
||||
{
|
||||
var borderLength = Border.DrawMarginFrame ? 1 : 0;
|
||||
var sumPadding = Border.GetSumThickness ();
|
||||
var wp = new Point ();
|
||||
var wb = new Size ();
|
||||
if (frame == Rect.Empty) {
|
||||
wp.X = borderLength + sumPadding.Left;
|
||||
wp.Y = borderLength + sumPadding.Top;
|
||||
wb.Width = borderLength + sumPadding.Right;
|
||||
wb.Height = borderLength + sumPadding.Bottom;
|
||||
if (Border.Child == null) {
|
||||
Border.Child = new ChildContentView (this) {
|
||||
X = borderLength + sumPadding.Left,
|
||||
Y = borderLength + sumPadding.Top,
|
||||
X = wp.X,
|
||||
Y = wp.Y,
|
||||
Width = Dim.Fill (wb.Width),
|
||||
Height = Dim.Fill (wb.Height)
|
||||
};
|
||||
} else {
|
||||
Border.Child.X = borderLength + sumPadding.Left;
|
||||
Border.Child.Y = borderLength + sumPadding.Top;
|
||||
Border.Child.X = wp.X;
|
||||
Border.Child.Y = wp.Y;
|
||||
Border.Child.Width = Dim.Fill (wb.Width);
|
||||
Border.Child.Height = Dim.Fill (wb.Height);
|
||||
}
|
||||
@@ -207,7 +210,8 @@ namespace Terminal.Gui {
|
||||
Border.Child.Frame = cFrame;
|
||||
}
|
||||
}
|
||||
base.Add (Border.Child);
|
||||
if (Subviews?.Count == 0)
|
||||
base.Add (Border.Child);
|
||||
Border.ChildContainer = this;
|
||||
}
|
||||
|
||||
@@ -249,7 +253,7 @@ namespace Terminal.Gui {
|
||||
{
|
||||
if (!NeedDisplay.IsEmpty) {
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
Border.DrawContent ();
|
||||
Clear ();
|
||||
}
|
||||
var savedClip = Border.Child.ClipToBounds ();
|
||||
Border.Child.Redraw (Border.Child.Bounds);
|
||||
@@ -258,10 +262,13 @@ namespace Terminal.Gui {
|
||||
ClearLayoutNeeded ();
|
||||
ClearNeedsDisplay ();
|
||||
|
||||
if (Border.BorderStyle != BorderStyle.None) {
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
Border.DrawTitle (this, this.Frame);
|
||||
}
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
Border.DrawContent (this, false);
|
||||
if (HasFocus)
|
||||
Driver.SetAttribute (ColorScheme.HotNormal);
|
||||
if (Border.DrawMarginFrame)
|
||||
Border.DrawTitle (this, Frame);
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
|
||||
// Checks if there are any SuperView view which intersect with this window.
|
||||
if (SuperView != null) {
|
||||
@@ -541,24 +548,26 @@ namespace Terminal.Gui {
|
||||
driver.SetAttribute (savedAttribute);
|
||||
|
||||
// Draw margin frame
|
||||
if (Parent?.Border != null) {
|
||||
var sumPadding = GetSumThickness ();
|
||||
borderRect = new Rect () {
|
||||
X = scrRect.X + sumPadding.Left,
|
||||
Y = scrRect.Y + sumPadding.Top,
|
||||
Width = Math.Max (scrRect.Width - sumPadding.Right - sumPadding.Left, 0),
|
||||
Height = Math.Max (scrRect.Height - sumPadding.Bottom - sumPadding.Top, 0)
|
||||
};
|
||||
} else {
|
||||
borderRect = new Rect () {
|
||||
X = borderRect.X + padding.Left,
|
||||
Y = borderRect.Y + padding.Top,
|
||||
Width = Math.Max (borderRect.Width - padding.Right - padding.Left, 0),
|
||||
Height = Math.Max (borderRect.Height - padding.Bottom - padding.Top, 0)
|
||||
};
|
||||
}
|
||||
if (borderRect.Width > 0 && borderRect.Height > 0) {
|
||||
driver.DrawWindowFrame (borderRect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill: true, this);
|
||||
if (DrawMarginFrame) {
|
||||
if (Parent?.Border != null) {
|
||||
var sumPadding = GetSumThickness ();
|
||||
borderRect = new Rect () {
|
||||
X = scrRect.X + sumPadding.Left,
|
||||
Y = scrRect.Y + sumPadding.Top,
|
||||
Width = Math.Max (scrRect.Width - sumPadding.Right - sumPadding.Left, 0),
|
||||
Height = Math.Max (scrRect.Height - sumPadding.Bottom - sumPadding.Top, 0)
|
||||
};
|
||||
} else {
|
||||
borderRect = new Rect () {
|
||||
X = borderRect.X + padding.Left,
|
||||
Y = borderRect.Y + padding.Top,
|
||||
Width = Math.Max (borderRect.Width - padding.Right - padding.Left, 0),
|
||||
Height = Math.Max (borderRect.Height - padding.Bottom - padding.Top, 0)
|
||||
};
|
||||
}
|
||||
if (borderRect.Width > 0 && borderRect.Height > 0) {
|
||||
driver.DrawWindowFrame (borderRect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill: true, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,14 +668,16 @@ namespace Terminal.Gui {
|
||||
driver.SetAttribute (savedAttribute);
|
||||
|
||||
// Draw the MarginFrame
|
||||
var rect = new Rect () {
|
||||
X = frame.X - drawMarginFrame,
|
||||
Y = frame.Y - drawMarginFrame,
|
||||
Width = frame.Width + (2 * drawMarginFrame),
|
||||
Height = frame.Height + (2 * drawMarginFrame)
|
||||
};
|
||||
if (rect.Width > 0 && rect.Height > 0) {
|
||||
driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
|
||||
if (DrawMarginFrame) {
|
||||
var rect = new Rect () {
|
||||
X = frame.X - drawMarginFrame,
|
||||
Y = frame.Y - drawMarginFrame,
|
||||
Width = frame.Width + (2 * drawMarginFrame),
|
||||
Height = frame.Height + (2 * drawMarginFrame)
|
||||
};
|
||||
if (rect.Width > 0 && rect.Height > 0) {
|
||||
driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (Effect3D) {
|
||||
@@ -811,14 +822,16 @@ namespace Terminal.Gui {
|
||||
driver.SetAttribute (savedAttribute);
|
||||
|
||||
// Draw the MarginFrame
|
||||
var rect = new Rect () {
|
||||
X = frame.X + sumThickness.Left,
|
||||
Y = frame.Y + sumThickness.Top,
|
||||
Width = Math.Max (frame.Width - sumThickness.Right - sumThickness.Left, 0),
|
||||
Height = Math.Max (frame.Height - sumThickness.Bottom - sumThickness.Top, 0)
|
||||
};
|
||||
if (rect.Width > 0 && rect.Height > 0) {
|
||||
driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
|
||||
if (DrawMarginFrame) {
|
||||
var rect = new Rect () {
|
||||
X = frame.X + sumThickness.Left,
|
||||
Y = frame.Y + sumThickness.Top,
|
||||
Width = Math.Max (frame.Width - sumThickness.Right - sumThickness.Left, 0),
|
||||
Height = Math.Max (frame.Height - sumThickness.Bottom - sumThickness.Top, 0)
|
||||
};
|
||||
if (rect.Width > 0 && rect.Height > 0) {
|
||||
driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (Effect3D) {
|
||||
|
||||
@@ -75,7 +75,6 @@ namespace Terminal.Gui {
|
||||
AdjustContentView (frame);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ContentView is an internal implementation detail of Window. It is used to host Views added with <see cref="Add(View)"/>.
|
||||
/// Its ONLY reason for being is to provide a simple way for Window to expose to those SubViews that the Window's Bounds
|
||||
@@ -186,26 +185,30 @@ namespace Terminal.Gui {
|
||||
} else {
|
||||
Border = border;
|
||||
}
|
||||
AdjustContentView (frame);
|
||||
}
|
||||
|
||||
void AdjustContentView (Rect frame)
|
||||
{
|
||||
var borderLength = Border.DrawMarginFrame ? 1 : 0;
|
||||
var sumPadding = Border.GetSumThickness ();
|
||||
var wp = new Point ();
|
||||
var wb = new Size ();
|
||||
if (frame == Rect.Empty) {
|
||||
wp.X = borderLength + sumPadding.Left;
|
||||
wp.Y = borderLength + sumPadding.Top;
|
||||
wb.Width = borderLength + sumPadding.Right;
|
||||
wb.Height = borderLength + sumPadding.Bottom;
|
||||
if (contentView == null) {
|
||||
contentView = new ContentView (this) {
|
||||
X = borderLength + sumPadding.Left,
|
||||
Y = borderLength + sumPadding.Top,
|
||||
X = wp.X,
|
||||
Y = wp.Y,
|
||||
Width = Dim.Fill (wb.Width),
|
||||
Height = Dim.Fill (wb.Height)
|
||||
};
|
||||
} else {
|
||||
contentView.X = borderLength + sumPadding.Left;
|
||||
contentView.Y = borderLength + sumPadding.Top;
|
||||
contentView.X = wp.X;
|
||||
contentView.Y = wp.Y;
|
||||
contentView.Width = Dim.Fill (wb.Width);
|
||||
contentView.Height = Dim.Fill (wb.Height);
|
||||
}
|
||||
@@ -219,7 +222,8 @@ namespace Terminal.Gui {
|
||||
contentView.Frame = cFrame;
|
||||
}
|
||||
}
|
||||
base.Add (contentView);
|
||||
if (Subviews?.Count == 0)
|
||||
base.Add (contentView);
|
||||
Border.Child = contentView;
|
||||
}
|
||||
|
||||
@@ -289,15 +293,15 @@ namespace Terminal.Gui {
|
||||
|
||||
ClearLayoutNeeded ();
|
||||
ClearNeedsDisplay ();
|
||||
if (Border.BorderStyle != BorderStyle.None) {
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
//Driver.DrawWindowFrame (scrRect, padding.Left + borderLength, padding.Top + borderLength, padding.Right + borderLength, padding.Bottom + borderLength,
|
||||
// Border.BorderStyle != BorderStyle.None, fill: true, Border.BorderStyle);
|
||||
Border.DrawContent (this, false);
|
||||
if (HasFocus)
|
||||
Driver.SetAttribute (ColorScheme.HotNormal);
|
||||
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
//Driver.DrawWindowFrame (scrRect, padding.Left + borderLength, padding.Top + borderLength, padding.Right + borderLength, padding.Bottom + borderLength,
|
||||
// Border.BorderStyle != BorderStyle.None, fill: true, Border.BorderStyle);
|
||||
Border.DrawContent (this, false);
|
||||
if (HasFocus)
|
||||
Driver.SetAttribute (ColorScheme.HotNormal);
|
||||
if (Border.DrawMarginFrame)
|
||||
Driver.DrawWindowTitle (scrRect, Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
|
||||
}
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
|
||||
// Checks if there are any SuperView view which intersect with this window.
|
||||
|
||||
@@ -124,20 +124,23 @@ namespace Terminal.Gui {
|
||||
{
|
||||
var borderLength = Border.DrawMarginFrame ? 1 : 0;
|
||||
var sumPadding = Border.GetSumThickness ();
|
||||
var wp = new Point ();
|
||||
var wb = new Size ();
|
||||
if (frame == Rect.Empty) {
|
||||
wp.X = borderLength + sumPadding.Left;
|
||||
wp.Y = borderLength + sumPadding.Top;
|
||||
wb.Width = borderLength + sumPadding.Right;
|
||||
wb.Height = borderLength + sumPadding.Bottom;
|
||||
if (contentView == null) {
|
||||
contentView = new ContentView () {
|
||||
X = borderLength + sumPadding.Left,
|
||||
Y = borderLength + sumPadding.Top,
|
||||
X = wp.X,
|
||||
Y = wp.Y,
|
||||
Width = Dim.Fill (wb.Width),
|
||||
Height = Dim.Fill (wb.Height)
|
||||
};
|
||||
} else {
|
||||
contentView.X = borderLength + sumPadding.Left;
|
||||
contentView.Y = borderLength + sumPadding.Top;
|
||||
contentView.X = wp.X;
|
||||
contentView.Y = wp.Y;
|
||||
contentView.Width = Dim.Fill (wb.Width);
|
||||
contentView.Height = Dim.Fill (wb.Height);
|
||||
}
|
||||
@@ -225,15 +228,14 @@ namespace Terminal.Gui {
|
||||
Driver.Clip = savedClip;
|
||||
|
||||
ClearNeedsDisplay ();
|
||||
if (Border.BorderStyle != BorderStyle.None) {
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
//Driver.DrawWindowFrame (scrRect, padding + 1, padding + 1, padding + 1, padding + 1, border: true, fill: false);
|
||||
Border.DrawContent (this, false);
|
||||
if (HasFocus)
|
||||
Driver.SetAttribute (ColorScheme.HotNormal);
|
||||
//Driver.DrawWindowTitle (scrRect, Title, padding, padding, padding, padding);
|
||||
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
//Driver.DrawWindowFrame (scrRect, padding + 1, padding + 1, padding + 1, padding + 1, border: true, fill: false);
|
||||
Border.DrawContent (this, false);
|
||||
if (HasFocus)
|
||||
Driver.SetAttribute (ColorScheme.HotNormal);
|
||||
if (Border.DrawMarginFrame)
|
||||
Driver.DrawWindowTitle (scrRect, Title, padding.Left, padding.Top, padding.Right, padding.Bottom);
|
||||
}
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user