diff --git a/Terminal.Gui/Core/Border.cs b/Terminal.Gui/Core/Border.cs
index 0abe6aabe..9f17835db 100644
--- a/Terminal.Gui/Core/Border.cs
+++ b/Terminal.Gui/Core/Border.cs
@@ -103,6 +103,59 @@ namespace Terminal.Gui {
return new Rect (new Point (rect.X + Left, rect.Y + Top), size);
}
+
+ ///
+ /// Draws the thickness rectangle with an optional diagnostics label.
+ ///
+ /// The location and size of the rectangle that bounds the thickness rectangle, in
+ /// screen coordinates.
+ /// The diagnostics label to draw on the bottom of the .
+ /// The inner rectangle remaining to be drawn.
+ public Rect Draw (Rect rect, string label = null)
+ {
+ // Draw the Top side
+ for (var r = rect.Y; r < Math.Min (rect.Y + rect.Height, rect.Y + Top); r++) {
+ for (var c = rect.X; c < rect.X + rect.Width; c++) {
+ Application.Driver.Move (c, r);
+ Application.Driver.AddRune (' ');
+ }
+ }
+
+ // Draw the Left side
+ for (var r = rect.Y; r < rect.Y + rect.Height; r++) {
+ for (var c = rect.X; c < Math.Min (rect.X + rect.Width, rect.X + Left); c++) {
+ Application.Driver.Move (c, r);
+ Application.Driver.AddRune (' ');
+ }
+ }
+
+ // Draw the Right side
+ for (var r = rect.Y; r < rect.Y + rect.Height; r++) {
+ for (var c = rect.X + Math.Max (0, rect.Width - Right); c < rect.X + rect.Width; c++) {
+ Application.Driver.Move (c, r);
+ Application.Driver.AddRune (' ');
+ }
+ }
+
+ // Draw the Bottom side
+ for (var r = rect.Y + Math.Max (0, rect.Height - Bottom); r < rect.Y + rect.Height; r++) {
+ for (var c = rect.X; c < rect.X + rect.Width; c++) {
+ Application.Driver.Move (c, r);
+ Application.Driver.AddRune (' ');
+ }
+ }
+
+ // Draw the diagnostics label on the bottom
+ var tf = new TextFormatter () {
+ Text = label == null ? string.Empty : $"{label} {this}",
+ Alignment = TextAlignment.Centered,
+ VerticalAlignment = VerticalTextAlignment.Bottom
+ };
+ tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute);
+
+ return GetInnerRect (rect);
+
+ }
// TODO: add operator overloads
///
/// Gets an empty thickness.
diff --git a/Terminal.Gui/Core/Container.cs b/Terminal.Gui/Core/Container.cs
index aec05fa69..71e08e390 100644
--- a/Terminal.Gui/Core/Container.cs
+++ b/Terminal.Gui/Core/Container.cs
@@ -7,32 +7,33 @@ using Terminal.Gui.Graphs;
namespace Terminal.Gui {
- public class Container : View {
- public Container ()
+ public class Frame : View {
+
+ public Frame ()
{
IgnoreBorderPropertyOnRedraw = true;
}
public virtual void OnDrawSubViews (Rect clipRect)
{
- if (Subviews == null) {
- return;
- }
+ // if (Subviews == null) {
+ // return;
+ // }
- foreach (var view in Subviews) {
- // BUGBUG: v2 - shouldn't this be !view.LayoutNeeded? Why draw if layout is going to happen and we'll just draw again?
- if (view.LayoutNeeded) {
- view.LayoutSubviews ();
- }
- if ((view.Visible && !view.NeedDisplay.IsEmpty && view.Frame.Width > 0 && view.Frame.Height > 0) || view.ChildNeedsDisplay) {
- view.Redraw (view.Bounds);
+ // foreach (var view in Subviews) {
+ // // BUGBUG: v2 - shouldn't this be !view.LayoutNeeded? Why draw if layout is going to happen and we'll just draw again?
+ // if (view.LayoutNeeded) {
+ // view.LayoutSubviews ();
+ // }
+ // if ((view.Visible && !view.NeedDisplay.IsEmpty && view.Frame.Width > 0 && view.Frame.Height > 0) || view.ChildNeedsDisplay) {
+ // view.Redraw (view.Bounds);
- view.NeedDisplay = Rect.Empty;
- // BUGBUG - v2 why does this need to be set to false?
- // Shouldn't it be set when the subviews draw?
- view.ChildNeedsDisplay = false;
- }
- }
+ // view.NeedDisplay = Rect.Empty;
+ // // BUGBUG - v2 why does this need to be set to false?
+ // // Shouldn't it be set when the subviews draw?
+ // view.ChildNeedsDisplay = false;
+ // }
+ // }
}
@@ -54,25 +55,40 @@ namespace Terminal.Gui {
public override void Redraw (Rect bounds)
{
- if (!CanBeVisible (this)) {
- return;
- }
+
+ //OnDrawContent (bounds);
+ //OnDrawSubViews (bounds);
+ //OnDrawContentComplete (bounds);
if (ColorScheme != null) {
- Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
+ Driver.SetAttribute (ColorScheme.Normal);
}
- OnDrawContent (bounds);
- OnDrawSubViews (bounds);
- OnDrawContentComplete (bounds);
+ Thickness.Draw (Frame, (string)Data);
+
+ //OnDrawContent (bounds);
+
+ //if (Text != null) {
+ // Thickness?.Draw (Frame, $"{Text} {DiagnosticsLabel?.Text}");
+ //}
+ if (BorderStyle != BorderStyle.None) {
+ var lc = new LineCanvas ();
+ lc.AddLine (Frame.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+ lc.AddLine (Frame.Location, Frame.Height - 1, Orientation.Vertical, BorderStyle);
+
+ lc.AddLine (new Point (Frame.X, Frame.Y + Frame.Height - 1), Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+ lc.AddLine (new Point (Frame.X + Frame.Width - 1, Frame.Y), Frame.Height - 1, Orientation.Vertical, BorderStyle);
+ foreach (var p in lc.GenerateImage (Frame)) {
+ Driver.Move (p.Key.X, p.Key.Y);
+ Driver.AddRune (p.Value);
+ }
+
+ if (!ustring.IsNullOrEmpty (Title)) {
+ Driver.DrawWindowTitle (Frame, Title, 0, 0, 0, 0);
+ }
+ }
}
- }
-
- ///
- /// A used for the rectangles that compose the outer frames of a .
- ///
- public class Frame : Container {
//public Label DiagnosticsLabel { get; set; }
// TODO: v2 = This is teporary; need to also enable (or not) simple way of setting
// other border properties
@@ -100,39 +116,40 @@ namespace Terminal.Gui {
}
}
- public override void OnDrawContent (Rect viewport)
- {
- // do nothing
- }
+ //public override void OnDrawContent (Rect viewport)
+ //{
+ // // do nothing
+ //}
- public override void Redraw (Rect bounds)
- {
- if (ColorScheme != null) {
- Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
- }
+ //public override void Redraw (Rect bounds)
+ //{
- //if (Text != null) {
- // Thickness?.Draw (Frame, $"{Text} {DiagnosticsLabel?.Text}");
- //}
- if (BorderStyle != BorderStyle.None) {
- var lc = new LineCanvas ();
- lc.AddLine (Frame.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
- lc.AddLine (Frame.Location, Frame.Height - 1, Orientation.Vertical, BorderStyle);
+ // if (ColorScheme != null) {
+ // Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
+ // }
- lc.AddLine (new Point (Frame.X, Frame.Y + Frame.Height - 1), Frame.Width - 1, Orientation.Horizontal, BorderStyle);
- lc.AddLine (new Point (Frame.X + Frame.Width - 1, Frame.Y), Frame.Height - 1, Orientation.Vertical, BorderStyle);
- foreach (var p in lc.GenerateImage (Frame)) {
- Driver.Move (p.Key.X, p.Key.Y);
- Driver.AddRune (p.Value);
- }
+ // //if (Text != null) {
+ // // Thickness?.Draw (Frame, $"{Text} {DiagnosticsLabel?.Text}");
+ // //}
+ // if (BorderStyle != BorderStyle.None) {
+ // var lc = new LineCanvas ();
+ // lc.AddLine (Frame.Location, Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+ // lc.AddLine (Frame.Location, Frame.Height - 1, Orientation.Vertical, BorderStyle);
- if (!ustring.IsNullOrEmpty (Title)) {
- Driver.DrawWindowTitle (Frame, Title, 0, 0, 0, 0);
- }
- }
+ // lc.AddLine (new Point (Frame.X, Frame.Y + Frame.Height - 1), Frame.Width - 1, Orientation.Horizontal, BorderStyle);
+ // lc.AddLine (new Point (Frame.X + Frame.Width - 1, Frame.Y), Frame.Height - 1, Orientation.Vertical, BorderStyle);
+ // foreach (var p in lc.GenerateImage (Frame)) {
+ // Driver.Move (p.Key.X, p.Key.Y);
+ // Driver.AddRune (p.Value);
+ // }
- base.Redraw (bounds);
- }
+ // if (!ustring.IsNullOrEmpty (Title)) {
+ // Driver.DrawWindowTitle (Frame, Title, 0, 0, 0, 0);
+ // }
+ // }
+
+ // base.Redraw (bounds);
+ //}
}
}
diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index 7efaa0c48..6e209d5da 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -467,15 +467,13 @@ namespace Terminal.Gui {
IgnoreBorderPropertyOnRedraw = true;
Margin?.Dispose ();
Margin = new Frame () {
- Data = "Margin",
Thickness = new Thickness (0),
- ColorScheme = Colors.ColorSchemes ["Error"]
+ ColorScheme = SuperView?.ColorScheme ?? ColorScheme
};
//Margin.DiagnosticsLabel.Text = "Margin";
BorderFrame?.Dispose ();
BorderFrame = new Frame () {
- Data = "BorderFrame",
BorderStyle = BorderStyle.Single,
Thickness = new Thickness (0),
ColorScheme = ColorScheme
@@ -483,9 +481,8 @@ namespace Terminal.Gui {
Padding?.Dispose ();
Padding = new Frame () {
- Data = "Padding",
Thickness = new Thickness (0),
- ColorScheme = Colors.ColorSchemes ["Toplevel"]
+ ColorScheme = ColorScheme
};
}
diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs
index eee8791a8..b568e9b75 100644
--- a/UICatalog/Scenarios/Dialogs.cs
+++ b/UICatalog/Scenarios/Dialogs.cs
@@ -10,14 +10,21 @@ namespace UICatalog.Scenarios {
[ScenarioCategory ("Dialogs")]
public class Dialogs : Scenario {
static int CODE_POINT = '你'; // We know this is a wide char
+ public override void Init (ColorScheme colorScheme)
+ {
+ Application.Init ();
+ Application.Top.ColorScheme = colorScheme;
+ }
+
public override void Setup ()
{
var frame = new FrameView ("Dialog Options") {
X = Pos.Center (),
Y = 0,
- Width = Dim.Percent (75)
+ Width = Dim.Percent (75),
+ Height = 12
};
- Win.Add (frame);
+ Application.Top.Add (frame);
var label = new Label ("width:") {
X = 0,
@@ -27,7 +34,7 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
frame.Add (label);
-
+
var widthEdit = new TextField ("0") {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
@@ -44,7 +51,7 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
frame.Add (label);
-
+
var heightEdit = new TextField ("0") {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
@@ -70,7 +77,7 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
frame.Add (label);
-
+
var titleEdit = new TextField ("Title") {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
@@ -87,7 +94,7 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
frame.Add (label);
-
+
var numButtonsEdit = new TextField ("3") {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
@@ -109,7 +116,7 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right
};
frame.Add (label);
-
+
var styleRadioGroup = new RadioGroup (new ustring [] { "Center", "Justify", "Left", "Right" }) {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
@@ -118,8 +125,9 @@ namespace UICatalog.Scenarios {
void Top_Loaded ()
{
- frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
- + Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height (glyphsNotWords) + 2;
+ // BUGBUG: This breaks with v2 ; causes TopologicalSort issue. Not sure why
+ //frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
+ // + Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height (glyphsNotWords) + 2;
Application.Top.Loaded -= Top_Loaded;
}
Application.Top.Loaded += Top_Loaded;
@@ -130,7 +138,7 @@ namespace UICatalog.Scenarios {
Height = 1,
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
- Win.Add (label);
+ Application.Top.Add (label);
var buttonPressedLabel = new Label (" ") {
X = Pos.Center (),
@@ -242,9 +250,9 @@ namespace UICatalog.Scenarios {
buttonPressedLabel.Text = "Invalid Options";
}
};
- Win.Add (showDialogButton);
+ Application.Top.Add (showDialogButton);
- Win.Add (buttonPressedLabel);
+ Application.Top.Add (buttonPressedLabel);
}
}
}
diff --git a/UICatalog/Scenarios/View2Experiment.cs b/UICatalog/Scenarios/View2Experiment.cs
index e21fb06e6..7b31e7b92 100644
--- a/UICatalog/Scenarios/View2Experiment.cs
+++ b/UICatalog/Scenarios/View2Experiment.cs
@@ -7,8 +7,7 @@ namespace UICatalog.Scenarios {
public override void Init (ColorScheme colorScheme)
{
Application.Init ();
-
- Application.Top.ColorScheme = Colors.Base;
+ Application.Top.ColorScheme = colorScheme;
}
public override void Setup ()
@@ -27,11 +26,20 @@ namespace UICatalog.Scenarios {
Width = Dim.Fill (2),
Title = "View2"
};
+ Application.Top.Add (view2);
+
view2.EnableFrames ();
view2.Margin.Thickness = new Thickness (2);
+ view2.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
+ view2.Margin.Data = "Margin";
view2.BorderFrame.Thickness = new Thickness (2);
view2.BorderFrame.BorderStyle = BorderStyle.Single;
+ //view2.BorderFrame.ColorScheme = view2.ColorScheme;
+ view2.BorderFrame.Data = "BorderFrame";
view2.Padding.Thickness = new Thickness (2);
+ view2.Padding.ColorScheme = Colors.ColorSchemes ["Error"];
+ view2.Padding.Data = "Padding";
+
containerLabel.LayoutComplete += (a) => {
containerLabel.Text = $"Container.Frame: {Application.Top.Frame} .Bounds: {Application.Top.Bounds}\nView2.Frame: {view2.Frame} .Bounds: {view2.Bounds}";
@@ -110,9 +118,6 @@ namespace UICatalog.Scenarios {
};
edit.X = 0;
view2.Add (edit);
-
- Application.Top.Add (view2);
-
}
}
}
\ No newline at end of file