mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
post merge tweaks
This commit is contained in:
@@ -20,10 +20,17 @@ namespace Terminal.Gui {
|
||||
/// Frames are a special form of <see cref="View"/> that act as adornments; they appear outside of the <see cref="View.Bounds"/>
|
||||
/// enabling borders, menus, etc...
|
||||
/// </summary>
|
||||
public Frame ()
|
||||
//public Frame ()
|
||||
//{
|
||||
//}
|
||||
|
||||
|
||||
internal override void CreateFrames ()
|
||||
{
|
||||
// Do nothing - Frame
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The Parent of this Frame.
|
||||
/// </summary>
|
||||
|
||||
@@ -513,9 +513,10 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Temporary API to support the new v2 API
|
||||
/// Creates the view's <see cref="Frame"/> objects. This internal method is overridden by Frame to do nothing
|
||||
/// to prevent recursion during View construction.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lays out the views <see cref="Frame"/>s objects (<see cref="Margin"/>, <see cref="BorderFrame"/>, and <see cref="Padding"/>
|
||||
/// as needed. Causes each Frame to Layout it's subviews.
|
||||
/// </summary>
|
||||
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 <see cref="LayoutStyle"/> of <see cref="Terminal.Gui.LayoutStyle.Absolute"/>.
|
||||
/// Use <see cref="View"/> to initialize a View with <see cref="LayoutStyle"/> of <see cref="Terminal.Gui.LayoutStyle.Computed"/>
|
||||
/// </remarks>
|
||||
public View (Rect frame)
|
||||
{
|
||||
SetInitialProperties (ustring.Empty, frame, LayoutStyle.Absolute, TextDirection.LeftRight_TopBottom);
|
||||
}
|
||||
public View (Rect frame) : this (frame, null, null) {}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="View"/> using <see cref="Terminal.Gui.LayoutStyle.Computed"/> layout.
|
||||
@@ -938,6 +942,8 @@ namespace Terminal.Gui {
|
||||
var r = rect.IsEmpty ? TextFormatter.CalcRect (0, 0, text, direction) : rect;
|
||||
Frame = r;
|
||||
OnResizeNeeded ();
|
||||
|
||||
CreateFrames ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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.");
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Terminal.Gui {
|
||||
//[Configuration.ConfigProperty]
|
||||
//internal static FrameViewConfig Config { get; set; } = new FrameViewConfig ();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,41 +20,41 @@ namespace Terminal.Gui {
|
||||
/// <inheritdoc/>
|
||||
public Label ()
|
||||
{
|
||||
Initialize ();
|
||||
SetInitialProperties ();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Label (Rect frame, bool autosize = false) : base (frame)
|
||||
{
|
||||
Initialize (autosize);
|
||||
SetInitialProperties (autosize);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Label (ustring text, bool autosize = true) : base (text)
|
||||
{
|
||||
Initialize (autosize);
|
||||
SetInitialProperties (autosize);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Label (Rect rect, ustring text, bool autosize = false) : base (rect, text)
|
||||
{
|
||||
Initialize (autosize);
|
||||
SetInitialProperties (autosize);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Label (int x, int y, ustring text, bool autosize = true) : base (x, y, text)
|
||||
{
|
||||
Initialize (autosize);
|
||||
SetInitialProperties (autosize);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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 {
|
||||
/// </remarks>
|
||||
public event Action Clicked;
|
||||
|
||||
///// <inheritdoc/>
|
||||
//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 ();
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Method invoked when a mouse event is generated
|
||||
/// </summary>
|
||||
|
||||
@@ -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}";
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user