mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* PoC * PoC progress * progress * Fixed #522 - updated sample * reverted untested PR * reverted untested PR * backed out more PRs that weren't ready
This commit is contained in:
@@ -110,8 +110,9 @@ namespace Terminal.Gui {
|
||||
/// <example>
|
||||
/// This sample shows how align a <see cref="Button"/> to the bottom-right of a <see cref="View"/>.
|
||||
/// <code>
|
||||
/// // See Issue #502
|
||||
/// anchorButton.X = Pos.AnchorEnd () - (Pos.Right (anchorButton) - Pos.Left (anchorButton));
|
||||
/// anchorButton.Y = Pos.AnchorEnd () - 1;
|
||||
/// anchorButton.Y = Pos.AnchorEnd (1);
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static Pos AnchorEnd (int margin = 0)
|
||||
|
||||
@@ -75,8 +75,8 @@ namespace Terminal.Gui {
|
||||
contentView = new ContentView () {
|
||||
X = 1,
|
||||
Y = 1,
|
||||
Width = Dim.Fill (2),
|
||||
Height = Dim.Fill (2)
|
||||
Width = Dim.Fill (1),
|
||||
Height = Dim.Fill (1)
|
||||
};
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@ namespace UICatalog {
|
||||
ColorScheme = Colors.Error
|
||||
};
|
||||
|
||||
Application.Resized += (sender, a) => {
|
||||
horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
|
||||
};
|
||||
|
||||
Win.Add (horizontalRuler);
|
||||
|
||||
// Demonstrate using Dim to create a vertical ruler that always measures the parent window's height
|
||||
@@ -47,6 +43,7 @@ namespace UICatalog {
|
||||
};
|
||||
|
||||
Application.Resized += (sender, a) => {
|
||||
horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
|
||||
verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height*2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height*2)];
|
||||
};
|
||||
|
||||
@@ -77,11 +74,27 @@ namespace UICatalog {
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
|
||||
subWin.Add (labelList.ToArray ());
|
||||
|
||||
// #522 repro?
|
||||
var frameView = new FrameView ($"Centered FrameView with {margin} character margin") {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Bottom(subWin),
|
||||
Width = Dim.Fill (margin),
|
||||
Height = 7
|
||||
};
|
||||
Win.Add (frameView);
|
||||
i = 1;
|
||||
labelList = new List<Label> ();
|
||||
labelList.Add (new Label ($"The lines below show different TextAlignments"));
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog });
|
||||
frameView.Add (labelList.ToArray ());
|
||||
|
||||
// Demonstrate Dim & Pos using percentages - a TextField that is 30% height and 80% wide
|
||||
var textView= new TextView () {
|
||||
var textView = new TextView () {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Percent (50),
|
||||
Width = Dim.Percent (80),
|
||||
@@ -169,7 +182,6 @@ namespace UICatalog {
|
||||
Win.Add (leftButton);
|
||||
Win.Add (centerButton);
|
||||
Win.Add (rightButton);
|
||||
|
||||
}
|
||||
|
||||
public override void Run ()
|
||||
|
||||
@@ -5,6 +5,7 @@ using Terminal.Gui;
|
||||
namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "Editor", Description: "A Terminal.Gui Text Editor via TextView")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
[ScenarioCategory ("Dialogs")]
|
||||
[ScenarioCategory ("Text")]
|
||||
[ScenarioCategory ("Dialogs")]
|
||||
[ScenarioCategory ("TopLevel")]
|
||||
|
||||
@@ -6,6 +6,7 @@ using Terminal.Gui;
|
||||
namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "HexEditor", Description: "A Terminal.Gui binary (hex) editor via HexView")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
[ScenarioCategory ("Dialogs")]
|
||||
[ScenarioCategory ("Text")]
|
||||
[ScenarioCategory ("Dialogs")]
|
||||
[ScenarioCategory ("TopLevel")]
|
||||
@@ -17,8 +18,8 @@ namespace UICatalog {
|
||||
public override void Setup ()
|
||||
{
|
||||
Win.Title = this.GetName() + "-" + _fileName ?? "Untitled";
|
||||
Win.Y = 1;
|
||||
Win.Height = Dim.Fill (1);
|
||||
Win.Y = 1; // menu
|
||||
Win.Height = Dim.Fill (1); // status bar
|
||||
Top.LayoutSubviews ();
|
||||
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "Windows & FrameViews", Description: "Shows Windows, sub-Windows, FrameViews, and how TAB doesn't work right (#434, #522)")]
|
||||
[ScenarioCategory ("Views")]
|
||||
[ScenarioCategory ("Layout")]
|
||||
class WindowExperiment : Scenario {
|
||||
[ScenarioCategory ("Bug Repro")]
|
||||
class WindowsAndFrameViews : Scenario {
|
||||
public override void Init (Toplevel top)
|
||||
{
|
||||
Application.Init ();
|
||||
@@ -37,28 +38,33 @@ namespace UICatalog {
|
||||
X = Pos.Center (),
|
||||
Y = 1,
|
||||
Width = Dim.Fill (10),
|
||||
Height = Dim.Percent (20),
|
||||
Height = Dim.Percent (15),
|
||||
};
|
||||
Win.ColorScheme = Colors.Dialog;
|
||||
Win.Add (new Button ("Press me!") {
|
||||
Win.Add (new Button ("Press me! (Y = 0)") {
|
||||
X = Pos.Center (),
|
||||
Y = 0,
|
||||
ColorScheme = Colors.Error,
|
||||
Clicked = () => MessageBox.ErrorQuery (30, 10, Win.Title.ToString (), "Neat?", "Yes", "No")
|
||||
});
|
||||
Win.Add (new Button ("Press ME! (Y = Pos.AnchorEnd(1))") {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.AnchorEnd(1),
|
||||
ColorScheme = Colors.Error
|
||||
});
|
||||
Top.Add (Win);
|
||||
listWin.Add (Win);
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
Window win = null;
|
||||
win = new Window ($"{listWin.Count} - Scenario: {GetName ()}", padding) {
|
||||
win = new Window ($"{listWin.Count} - Loop {i}", padding) {
|
||||
X = margin,
|
||||
Y = Pos.Bottom (listWin.Last ()) + (margin),
|
||||
Width = Dim.Fill (margin),
|
||||
Height = height,
|
||||
};
|
||||
win.ColorScheme = Colors.Dialog;
|
||||
win.Add (new Button ("Press me!") {
|
||||
win.Add (new Button ("Press me! (Y = 0)") {
|
||||
X = Pos.Center (),
|
||||
Y = 0,
|
||||
ColorScheme = Colors.Error,
|
||||
@@ -66,7 +72,7 @@ namespace UICatalog {
|
||||
});
|
||||
var subWin = new Window ("Sub Window") {
|
||||
X = Pos.Percent (0),
|
||||
Y = Pos.AnchorEnd () - 5,
|
||||
Y = 1,
|
||||
Width = Dim.Percent (50),
|
||||
Height = 5,
|
||||
ColorScheme = Colors.Base,
|
||||
@@ -77,7 +83,7 @@ namespace UICatalog {
|
||||
win.Add (subWin);
|
||||
var frameView = new FrameView ("This is a Sub-FrameView") {
|
||||
X = Pos.Percent (50),
|
||||
Y = Pos.AnchorEnd () - 5,
|
||||
Y = 1,
|
||||
Width = Dim.Percent (100),
|
||||
Height = 5,
|
||||
ColorScheme = Colors.Base,
|
||||
@@ -98,47 +104,52 @@ namespace UICatalog {
|
||||
Height = height,
|
||||
};
|
||||
frame.ColorScheme = Colors.Dialog;
|
||||
frame.Add (new Button ("Press me!") {
|
||||
frame.Add (new Button ("Press me! (Y = 0)") {
|
||||
X = Pos.Center (),
|
||||
Y = 0,
|
||||
ColorScheme = Colors.Error,
|
||||
Clicked = () => MessageBox.ErrorQuery (30, 10, frame.Title.ToString (), "Neat?", "Yes", "No")
|
||||
});
|
||||
var subWinFV = new Window ("this is a Sub-Window") {
|
||||
var subWinofFV = new Window ("this is a Sub-Window") {
|
||||
X = Pos.Percent (0),
|
||||
Y = Pos.AnchorEnd () - (height - 4),
|
||||
Y = 1,
|
||||
Width = Dim.Percent (50),
|
||||
Height = Dim.Fill () - 1,
|
||||
ColorScheme = Colors.Base,
|
||||
};
|
||||
subWinFV.Add (new TextField (frame.Title.ToString ()) {
|
||||
subWinofFV.Add (new TextField ("Edit Me") {
|
||||
ColorScheme = Colors.Error
|
||||
});
|
||||
frame.Add (subWinFV);
|
||||
var frameViewFV = new FrameView ("this is a Sub-FrameView") {
|
||||
|
||||
subWinofFV.Add (new CheckBox (0, 1, "Check me"));
|
||||
subWinofFV.Add (new CheckBox (0, 2, "Or, Check me"));
|
||||
|
||||
frame.Add (subWinofFV);
|
||||
var subFrameViewofFV = new FrameView ("this is a Sub-FrameView") {
|
||||
X = Pos.Percent (50),
|
||||
Y = Pos.AnchorEnd () - (height - 4),
|
||||
Y = 1,
|
||||
Width = Dim.Percent (100),
|
||||
Height = Dim.Fill () - 1,
|
||||
ColorScheme = Colors.Base,
|
||||
};
|
||||
frameViewFV.Add (new TextField ("Edit Me"));
|
||||
subFrameViewofFV.Add (new TextField ("Edit Me"));
|
||||
|
||||
frameViewFV.Add (new CheckBox (0, 1, "Check me"));
|
||||
subFrameViewofFV.Add (new CheckBox (0, 1, "Check me"));
|
||||
// BUGBUG: This checkbox is not shown even though frameViewFV has 3 rows in
|
||||
// it's client area. #522
|
||||
frameViewFV.Add (new CheckBox (0, 2, "Or, Check me"));
|
||||
// its client area. #522
|
||||
subFrameViewofFV.Add (new CheckBox (0, 2, "Or, Check me"));
|
||||
|
||||
frame.Add (new CheckBox ("No, Check me!") {
|
||||
frame.Add (new CheckBox ("Btn1 (Y = Pos.AnchorEnd (1))") {
|
||||
X = 0,
|
||||
Y = Pos.AnchorEnd () - 1, // BUGBUG: #522 If I don't do the -1 it doesn't draw, but it should!
|
||||
});
|
||||
frame.Add (new CheckBox ("Really, Check me!") {
|
||||
X = Pos.Percent (50),
|
||||
Y = Pos.AnchorEnd () - 1, // BUGBUG: #522 If I don't do the -1 it doesn't draw, but it should!
|
||||
Y = Pos.AnchorEnd (1),
|
||||
});
|
||||
CheckBox c = new CheckBox ("Btn2 (Y = Pos.AnchorEnd (1))") {
|
||||
Y = Pos.AnchorEnd (1),
|
||||
};
|
||||
c.X = Pos.AnchorEnd () - (Pos.Right (c) - Pos.Left (c));
|
||||
frame.Add (c);
|
||||
|
||||
frame.Add (frameViewFV);
|
||||
frame.Add (subFrameViewofFV);
|
||||
|
||||
Top.Add (frame);
|
||||
listWin.Add (frame);
|
||||
Reference in New Issue
Block a user