diff --git a/Terminal.Gui/Core/Frame.cs b/Terminal.Gui/Core/Frame.cs
index 3ceb56768..35250212e 100644
--- a/Terminal.Gui/Core/Frame.cs
+++ b/Terminal.Gui/Core/Frame.cs
@@ -20,10 +20,17 @@ namespace Terminal.Gui {
/// Frames are a special form of that act as adornments; they appear outside of the
/// enabling borders, menus, etc...
///
- public Frame ()
+ //public Frame ()
+ //{
+ //}
+
+
+ internal override void CreateFrames ()
{
+ // Do nothing - Frame
}
+
///
/// The Parent of this Frame.
///
diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index e5ab71271..793fca5f8 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -513,9 +513,10 @@ namespace Terminal.Gui {
}
///
- /// Temporary API to support the new v2 API
+ /// Creates the view's objects. This internal method is overridden by Frame to do nothing
+ /// to prevent recursion during View construction.
///
- public void InitializeFrames ()
+ internal virtual void CreateFrames ()
{
Margin?.Dispose ();
Margin = new Frame () { Id = "Margin", Thickness = new Thickness (0) };
@@ -533,6 +534,10 @@ namespace Terminal.Gui {
Padding.Parent = this;
}
+ ///
+ /// Lays out the views s objects (, , and
+ /// as needed. Causes each Frame to Layout it's subviews.
+ ///
public void LayoutFrames ()
{
if (Margin != null) {
@@ -555,7 +560,9 @@ namespace Terminal.Gui {
BorderFrame.SetNeedsDisplay ();
}
if (Padding != null) {
- var padding = BorderFrame?.Thickness.GetInnerRect (BorderFrame?.Frame ?? (Margin?.Thickness.GetInnerRect (Margin.Frame) ?? Frame)) ?? Margin?.Thickness.GetInnerRect (Margin.Frame) ?? Frame;
+ var padding = BorderFrame?.Thickness.GetInnerRect (BorderFrame?.Frame ??
+ (Margin?.Thickness.GetInnerRect (Margin.Frame) ?? Frame)) ??
+ Margin?.Thickness.GetInnerRect (Margin.Frame) ?? Frame;
Padding.X = padding.Location.X;
Padding.Y = padding.Location.Y;
Padding.Width = padding.Size.Width;
@@ -825,10 +832,7 @@ namespace Terminal.Gui {
/// This constructor initialize a View with a of .
/// Use to initialize a View with of
///
- public View (Rect frame)
- {
- SetInitialProperties (ustring.Empty, frame, LayoutStyle.Absolute, TextDirection.LeftRight_TopBottom);
- }
+ public View (Rect frame) : this (frame, null, null) {}
///
/// Initializes a new instance of using layout.
@@ -938,6 +942,8 @@ namespace Terminal.Gui {
var r = rect.IsEmpty ? TextFormatter.CalcRect (0, 0, text, direction) : rect;
Frame = r;
OnResizeNeeded ();
+
+ CreateFrames ();
}
///
@@ -3261,7 +3267,7 @@ namespace Terminal.Gui {
// TODO: Figure out why ScrollView and other tests fail if this call is put here
// instead of the constructor.
// OnSizeChanged ();
- InitializeFrames ();
+ //InitializeFrames ();
} else {
//throw new InvalidOperationException ("The view is already initialized.");
diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs
index 357f3f46d..d31bca75b 100644
--- a/Terminal.Gui/Views/FrameView.cs
+++ b/Terminal.Gui/Views/FrameView.cs
@@ -43,7 +43,7 @@ namespace Terminal.Gui {
//[Configuration.ConfigProperty]
//internal static FrameViewConfig Config { get; set; } = new FrameViewConfig ();
-
+
diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs
index 0a1d795b3..fa1a4ee93 100644
--- a/Terminal.Gui/Views/Label.cs
+++ b/Terminal.Gui/Views/Label.cs
@@ -20,41 +20,41 @@ namespace Terminal.Gui {
///
public Label ()
{
- Initialize ();
+ SetInitialProperties ();
}
///
public Label (Rect frame, bool autosize = false) : base (frame)
{
- Initialize (autosize);
+ SetInitialProperties (autosize);
}
///
public Label (ustring text, bool autosize = true) : base (text)
{
- Initialize (autosize);
+ SetInitialProperties (autosize);
}
///
public Label (Rect rect, ustring text, bool autosize = false) : base (rect, text)
{
- Initialize (autosize);
+ SetInitialProperties (autosize);
}
///
public Label (int x, int y, ustring text, bool autosize = true) : base (x, y, text)
{
- Initialize (autosize);
+ SetInitialProperties (autosize);
}
///
public Label (ustring text, TextDirection direction, bool autosize = true)
: base (text, direction)
{
- Initialize (autosize);
+ SetInitialProperties (autosize);
}
- void Initialize (bool autosize = true)
+ void SetInitialProperties (bool autosize = true)
{
AutoSize = autosize;
}
@@ -70,21 +70,6 @@ namespace Terminal.Gui {
///
public event Action Clicked;
- /////
- //public new ustring Text {
- // get => base.Text;
- // set {
- // base.Text = value;
- // // This supports Label auto-sizing when Text changes (preserving backwards compat behavior)
- // if (Frame.Height == 1 && !ustring.IsNullOrEmpty (value)) {
- // int w = Text.RuneCount;
- // Width = w;
- // Frame = new Rect (Frame.Location, new Size (w, Frame.Height));
- // }
- // SetNeedsDisplay ();
- // }
- //}
-
///
/// Method invoked when a mouse event is generated
///
diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs
index 61a5752e4..0a41ad97d 100644
--- a/UICatalog/Scenarios/ViewExperiments.cs
+++ b/UICatalog/Scenarios/ViewExperiments.cs
@@ -1,4 +1,5 @@
using Terminal.Gui;
+using Terminal.Gui.Configuration;
namespace UICatalog.Scenarios {
[ScenarioMetadata (Name: "_ View Experiments", Description: "v2 View Experiments")]
@@ -8,32 +9,35 @@ namespace UICatalog.Scenarios {
{
Application.Init ();
//Application.Init ();
- //ConfigurationManager.Themes.Theme = Theme;
- //ConfigurationManager.Apply ();
- //Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
+ ConfigurationManager.Themes.Theme = Theme;
+ ConfigurationManager.Apply ();
+ Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
}
public override void Setup ()
{
- ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FramePadding;
+ //ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FramePadding;
var containerLabel = new Label () {
X = 0,
Y = 0,
Width = Dim.Fill (),
+ Height = 3,
};
Application.Top.Add (containerLabel);
var view = new View () {
X = 2,
- Y = 3,
+ Y = Pos.Bottom(containerLabel),
Height = Dim.Fill (2),
Width = Dim.Fill (2),
Title = "View with 2xMargin, 2xBorder, & 2xPadding",
ColorScheme = Colors.ColorSchemes ["Base"],
};
- view.InitializeFrames ();
+ Application.Top.Add (view);
+
+ //view.InitializeFrames ();
view.Margin.Thickness = new Thickness (2, 2, 2, 2);
view.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
view.Margin.Data = "Margin";
@@ -45,8 +49,6 @@ namespace UICatalog.Scenarios {
view.Padding.ColorScheme = Colors.ColorSchemes ["Error"];
view.Padding.Data = "Padding";
- Application.Top.Add (view);
-
var view2 = new View () {
X = 2,
Y = 3,
@@ -57,7 +59,7 @@ namespace UICatalog.Scenarios {
TextAlignment = TextAlignment.Centered
};
- view2.InitializeFrames ();
+ //view2.InitializeFrames ();
view2.Margin.Thickness = new Thickness (1);
view2.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
view2.Margin.Data = "Margin";
@@ -81,7 +83,7 @@ namespace UICatalog.Scenarios {
TextAlignment = TextAlignment.Centered
};
- view3.InitializeFrames ();
+ //view3.InitializeFrames ();
view3.Margin.Thickness = new Thickness (1, 1, 0, 0);
view3.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
view3.Margin.Data = "Margin";
@@ -105,7 +107,7 @@ namespace UICatalog.Scenarios {
TextAlignment = TextAlignment.Centered
};
- view4.InitializeFrames ();
+ //view4.InitializeFrames ();
view4.Margin.Thickness = new Thickness (0, 0, 1, 1);
view4.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
view4.Margin.Data = "Margin";
@@ -128,7 +130,7 @@ namespace UICatalog.Scenarios {
Text = "View #5 (Right(view4)+1 Fill",
TextAlignment = TextAlignment.Centered
};
- view5.InitializeFrames ();
+ //view5.InitializeFrames ();
view5.Margin.Thickness = new Thickness (0, 0, 0, 0);
view5.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
view5.Margin.Data = "Margin";
@@ -216,7 +218,6 @@ namespace UICatalog.Scenarios {
containerLabel.LayoutComplete += (a) => {
containerLabel.Text = $"Container.Frame: {Application.Top.Frame} .Bounds: {Application.Top.Bounds}\nView.Frame: {view.Frame} .Bounds: {view.Bounds}\nView.ContentArea: {view.ContentArea}";
-
};
}