mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
merged from develop after accident
This commit is contained in:
@@ -52,7 +52,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Pos.PosFunc({function ()})";
|
||||
return $"PosFunc({function ()})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => function.GetHashCode ();
|
||||
@@ -85,7 +85,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Pos.Factor({factor})";
|
||||
return $"Factor({factor})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => factor.GetHashCode ();
|
||||
@@ -135,7 +135,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Pos.AnchorEnd(margin={n})";
|
||||
return $"AnchorEnd({n})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return "Pos.Center";
|
||||
return "Center";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Pos.Absolute({n})";
|
||||
return $"Absolute({n})";
|
||||
}
|
||||
|
||||
internal override int Anchor (int width)
|
||||
@@ -244,7 +244,7 @@ namespace Terminal.Gui {
|
||||
|
||||
internal class PosCombine : Pos {
|
||||
internal Pos left, right;
|
||||
bool add;
|
||||
internal bool add;
|
||||
public PosCombine (bool add, Pos left, Pos right)
|
||||
{
|
||||
this.left = left;
|
||||
@@ -264,7 +264,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Pos.Combine({left.ToString ()}{(add ? '+' : '-')}{right.ToString ()})";
|
||||
return $"Combine({left}{(add ? '+' : '-')}{right})";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -345,7 +345,7 @@ namespace Terminal.Gui {
|
||||
case 3: tside = "bottom"; break;
|
||||
default: tside = "unknown"; break;
|
||||
}
|
||||
return $"Pos.View(side={tside}, target={Target.ToString ()})";
|
||||
return $"View({tside},{Target})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => Target.GetHashCode ();
|
||||
@@ -442,7 +442,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Dim.DimFunc({function ()})";
|
||||
return $"DimFunc({function ()})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => function.GetHashCode ();
|
||||
@@ -482,7 +482,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Dim.Factor(factor={factor}, remaining={remaining})";
|
||||
return $"Factor({factor},{remaining})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => factor.GetHashCode ();
|
||||
@@ -522,7 +522,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Dim.Absolute({n})";
|
||||
return $"Absolute({n})";
|
||||
}
|
||||
|
||||
internal override int Anchor (int width)
|
||||
@@ -541,7 +541,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Dim.Fill(margin={margin})";
|
||||
return $"Fill({margin})";
|
||||
}
|
||||
|
||||
internal override int Anchor (int width)
|
||||
@@ -613,7 +613,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Dim.Combine({left.ToString ()}{(add ? '+' : '-')}{right.ToString ()})";
|
||||
return $"Combine({left}{(add ? '+' : '-')}{right})";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -691,7 +691,7 @@ namespace Terminal.Gui {
|
||||
case 1: tside = "Width"; break;
|
||||
default: tside = "unknown"; break;
|
||||
}
|
||||
return $"DimView(side={tside}, target={Target.ToString ()})";
|
||||
return $"DimView({tside},{Target})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => Target.GetHashCode ();
|
||||
|
||||
@@ -1532,14 +1532,15 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
if (!ustring.IsNullOrEmpty (TextFormatter.Text)) {
|
||||
Clear ();
|
||||
Rect containerBounds = GetContainerBounds ();
|
||||
Clear (ViewToScreen (GetNeedDisplay (containerBounds)));
|
||||
SetChildNeedsDisplay ();
|
||||
// Draw any Text
|
||||
if (TextFormatter != null) {
|
||||
TextFormatter.NeedsFormat = true;
|
||||
}
|
||||
TextFormatter?.Draw (ViewToScreen (Bounds), HasFocus ? GetFocusColor () : GetNormalColor (),
|
||||
HasFocus ? ColorScheme.HotFocus : GetHotNormalColor (),
|
||||
TextFormatter?.Draw (ViewToScreen (boundsAdjustedForBorder), HasFocus ? ColorScheme.Focus : GetNormalColor (),
|
||||
HasFocus ? ColorScheme.HotFocus : Enabled ? ColorScheme.HotNormal : ColorScheme.Disabled,
|
||||
containerBounds);
|
||||
}
|
||||
|
||||
@@ -2193,7 +2194,7 @@ namespace Terminal.Gui {
|
||||
// the current Pos (View.X or View.Y)
|
||||
// the current Dim (View.Width or View.Height)
|
||||
(int newLocation, int newDimension) GetNewLocationAndDimension (int superviewLocation, int superviewDimension, Pos pos, Dim dim, int autosizeDimension)
|
||||
{
|
||||
{
|
||||
int newDimension, newLocation;
|
||||
|
||||
switch (pos) {
|
||||
@@ -2207,9 +2208,21 @@ namespace Terminal.Gui {
|
||||
newLocation = pos.Anchor (superviewDimension - newDimension);
|
||||
break;
|
||||
|
||||
case Pos.PosCombine:
|
||||
var combine = pos as Pos.PosCombine;
|
||||
int left, right;
|
||||
(left, newDimension) = GetNewLocationAndDimension (superviewLocation, superviewDimension, combine.left, dim, autosizeDimension);
|
||||
(right, newDimension) = GetNewLocationAndDimension (superviewLocation, superviewDimension, combine.right, dim, autosizeDimension);
|
||||
if (combine.add) {
|
||||
newLocation = left + right;
|
||||
} else {
|
||||
newLocation = left - right;
|
||||
}
|
||||
newDimension = Math.Max (CalculateNewDimension (dim, newLocation, superviewDimension, autosizeDimension), 0);
|
||||
break;
|
||||
|
||||
case Pos.PosAbsolute:
|
||||
case Pos.PosAnchorEnd:
|
||||
case Pos.PosCombine:
|
||||
case Pos.PosFactor:
|
||||
case Pos.PosFunc:
|
||||
case Pos.PosView:
|
||||
@@ -2232,19 +2245,22 @@ namespace Terminal.Gui {
|
||||
newDimension = AutoSize ? autosize : dimension;
|
||||
break;
|
||||
case Dim.DimCombine combine:
|
||||
int leftActW = CalculateNewDimension (combine.left, location, dimension, autosize);
|
||||
int rightActW = CalculateNewDimension (combine.right, dimension, location, autosize);
|
||||
int leftNewDim = CalculateNewDimension (combine.left, location, dimension, autosize);
|
||||
int rightNewDim = CalculateNewDimension (combine.right, location, dimension, autosize);
|
||||
if (combine.add) {
|
||||
newDimension = leftActW + rightActW;
|
||||
newDimension = leftNewDim + rightNewDim;
|
||||
} else {
|
||||
newDimension = leftActW - rightActW;
|
||||
newDimension = leftNewDim - rightNewDim;
|
||||
}
|
||||
newDimension = AutoSize && autosize > newDimension ? autosize : newDimension;
|
||||
break;
|
||||
|
||||
case Dim.DimFactor factor when !factor.IsFromRemaining ():
|
||||
newDimension = d.Anchor (dimension);
|
||||
newDimension = AutoSize && autosize > newDimension ? autosize : newDimension;
|
||||
break;
|
||||
|
||||
case Dim.DimFill:
|
||||
default:
|
||||
newDimension = Math.Max (d.Anchor (dimension - location), 0);
|
||||
newDimension = AutoSize && autosize > newDimension ? autosize : newDimension;
|
||||
@@ -2442,7 +2458,7 @@ namespace Terminal.Gui {
|
||||
// return L (a topologically sorted order)
|
||||
return result;
|
||||
} // TopologicalSort
|
||||
|
||||
|
||||
var ordered = TopologicalSort (nodes, edges);
|
||||
|
||||
foreach (var v in ordered) {
|
||||
|
||||
@@ -186,8 +186,8 @@ namespace UICatalog {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the <see cref="Scenario"/>. Override to start the <see cref="Scenario"/> using a <see cref="Toplevel"/> different than `Top`.
|
||||
///
|
||||
/// Runs the <see cref="Scenario"/>. Override to start the <see cref="Scenario"/>
|
||||
/// using a <see cref="Toplevel"/> different than `Top`.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Overrides that do not call the base.<see cref="Run"/>, must call <see cref="Application.Shutdown"/> before returning.
|
||||
|
||||
@@ -17,28 +17,31 @@ namespace UICatalog.Scenarios {
|
||||
[ScenarioCategory ("Layout")]
|
||||
public class ComputedLayout : Scenario {
|
||||
|
||||
public override void Init (ColorScheme colorScheme)
|
||||
{
|
||||
Application.Init ();
|
||||
Application.Top.ColorScheme = colorScheme;
|
||||
}
|
||||
|
||||
public override void Setup ()
|
||||
{
|
||||
var statusBar = new StatusBar (new StatusItem [] {
|
||||
new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
|
||||
});
|
||||
Application.Top.Add (statusBar);
|
||||
|
||||
// Demonstrate using Dim to create a horizontal ruler that always measures the parent window's width
|
||||
const string rule = "|123456789";
|
||||
var horizontalRuler = new Label ("") {
|
||||
AutoSize = false,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Width = Dim.Fill (),
|
||||
ColorScheme = Colors.Error
|
||||
};
|
||||
|
||||
Win.Add (horizontalRuler);
|
||||
Application.Top.Add (horizontalRuler);
|
||||
|
||||
// Demonstrate using Dim to create a vertical ruler that always measures the parent window's height
|
||||
const string vrule = "|\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
|
||||
|
||||
var verticalRuler = new Label ("") {
|
||||
AutoSize = false,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Width = 1,
|
||||
@@ -46,36 +49,37 @@ namespace UICatalog.Scenarios {
|
||||
ColorScheme = Colors.Error
|
||||
};
|
||||
|
||||
Win.LayoutComplete += (a) => {
|
||||
Application.Top.LayoutComplete += (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)];
|
||||
verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height * 2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height*2)];
|
||||
};
|
||||
|
||||
Win.Add (verticalRuler);
|
||||
Application.Top.Add (verticalRuler);
|
||||
|
||||
// Demonstrate At - Using Pos.At to locate a view in an absolute location
|
||||
var atButton = new Button ("At(2,1)") {
|
||||
X = Pos.At (2),
|
||||
Y = Pos.At (1)
|
||||
};
|
||||
Win.Add (atButton);
|
||||
Application.Top.Add (atButton);
|
||||
|
||||
// Throw in a literal absolute - Should funciton identically to above
|
||||
var absoluteButton = new Button ("X = 30, Y = 1") {
|
||||
X = 30,
|
||||
Y = 1
|
||||
};
|
||||
Win.Add (absoluteButton);
|
||||
Application.Top.Add (absoluteButton);
|
||||
|
||||
// Demonstrate using Dim to create a window that fills the parent with a margin
|
||||
int margin = 10;
|
||||
var subWin = new Window ($"Centered Window with {margin} character margin") {
|
||||
var subWin = new Window () {
|
||||
X = Pos.Center (),
|
||||
Y = 2,
|
||||
Width = Dim.Fill (margin),
|
||||
Height = 7
|
||||
};
|
||||
Win.Add (subWin);
|
||||
subWin.Title = $"{subWin.GetType().Name} {{X={subWin.X},Y={subWin.Y},Width={subWin.Width},Height={subWin.Height}}}";
|
||||
Application.Top.Add (subWin);
|
||||
|
||||
int i = 1;
|
||||
string txt = "Resize the terminal to see computed layout in action.";
|
||||
@@ -88,13 +92,13 @@ namespace UICatalog.Scenarios {
|
||||
subWin.Add (labelList.ToArray ());
|
||||
|
||||
// #522 repro?
|
||||
var frameView = new FrameView ($"Centered FrameView with {margin} character margin") {
|
||||
X = Pos.Center (),
|
||||
var frameView = new FrameView () {
|
||||
X = 2, //Pos.Center (),
|
||||
Y = Pos.Bottom (subWin),
|
||||
Width = Dim.Fill (margin),
|
||||
Width = 30,
|
||||
Height = 7
|
||||
};
|
||||
Win.Add (frameView);
|
||||
frameView.Title = $"{frameView.GetType ().Name} {{X={frameView.X},Y={frameView.Y},Width={frameView.Width},Height={frameView.Height}}}";
|
||||
i = 1;
|
||||
labelList = new List<Label> ();
|
||||
labelList.Add (new Label ($"The lines below show different TextAlignments"));
|
||||
@@ -103,6 +107,16 @@ namespace UICatalog.Scenarios {
|
||||
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 ());
|
||||
Application.Top.Add (frameView);
|
||||
|
||||
frameView = new FrameView () {
|
||||
X = Pos.Right(frameView),
|
||||
Y = Pos.Top (frameView),
|
||||
Width = Dim.Fill(),
|
||||
Height = 7,
|
||||
};
|
||||
frameView.Title = $"{frameView.GetType ().Name} {{X={frameView.X},Y={frameView.Y},Width={frameView.Width},Height={frameView.Height}}}";
|
||||
Application.Top.Add (frameView);
|
||||
|
||||
// Demonstrate Dim & Pos using percentages - a TextField that is 30% height and 80% wide
|
||||
var textView = new TextView () {
|
||||
@@ -113,13 +127,13 @@ namespace UICatalog.Scenarios {
|
||||
ColorScheme = Colors.TopLevel,
|
||||
};
|
||||
textView.Text = $"This TextView should horizontally & vertically centered and \n10% of the screeen height, and 80% of its width.";
|
||||
Win.Add (textView);
|
||||
Application.Top.Add (textView);
|
||||
|
||||
var oddballButton = new Button ("The Buttons below should be centered") {
|
||||
var oddballButton = new Button ("These buttons demo convoluted PosCombine scenarios") {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Bottom (textView) + 1
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
#region Issue2358
|
||||
// Demonstrate odd-ball Combine scenarios
|
||||
@@ -129,13 +143,25 @@ namespace UICatalog.Scenarios {
|
||||
X = Pos.Center () + 0,
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
oddballButton = new Button ("Center + 1") {
|
||||
X = Pos.Center () + 1,
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
oddballButton = new Button ("0 + Center") {
|
||||
X = 0 + Pos.Center (),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
oddballButton = new Button ("1 + Center") {
|
||||
X = 1 + Pos.Center (),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
// This demonstrates nonsense: it the same as using Pos.AnchorEnd (100/2=50 + 100/2=50 = 100 - 50)
|
||||
// The `- Pos.Percent(5)` is there so at least something is visible
|
||||
@@ -143,7 +169,7 @@ namespace UICatalog.Scenarios {
|
||||
X = Pos.Center () + Pos.Center () - Pos.Percent(50),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
// This demonstrates nonsense: it the same as using Pos.AnchorEnd (100/2=50 + 100/2=50 = 100 - 50)
|
||||
// The `- Pos.Percent(5)` is there so at least something is visible
|
||||
@@ -151,7 +177,7 @@ namespace UICatalog.Scenarios {
|
||||
X = Pos.Percent (50) + Pos.Center () - Pos.Percent (50),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
// This demonstrates nonsense: it the same as using Pos.AnchorEnd (100/2=50 + 100/2=50 = 100 - 50)
|
||||
// The `- Pos.Percent(5)` is there so at least something is visible
|
||||
@@ -159,7 +185,7 @@ namespace UICatalog.Scenarios {
|
||||
X = Pos.Center () + Pos.Percent (50) - Pos.Percent (50),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
#endregion
|
||||
// This demonstrates nonsense: Same as At(0)
|
||||
@@ -167,14 +193,14 @@ namespace UICatalog.Scenarios {
|
||||
X = Pos.Center () + Pos.Center () - Pos.Percent (50),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
// This demonstrates combining Percents)
|
||||
oddballButton = new Button ("Percent(40) + Percent(10)") {
|
||||
X = Pos.Percent (40) + Pos.Percent(10),
|
||||
Y = Pos.Bottom (oddballButton)
|
||||
};
|
||||
Win.Add (oddballButton);
|
||||
Application.Top.Add (oddballButton);
|
||||
|
||||
// Demonstrate AnchorEnd - Button is anchored to bottom/right
|
||||
var anchorButton = new Button ("Button using AnchorEnd") {
|
||||
@@ -184,34 +210,34 @@ namespace UICatalog.Scenarios {
|
||||
anchorButton.Clicked += () => {
|
||||
// Ths demonstrates how to have a dynamically sized button
|
||||
// Each time the button is clicked the button's text gets longer
|
||||
// The call to Win.LayoutSubviews causes the Computed layout to
|
||||
// The call to Application.Top.LayoutSubviews causes the Computed layout to
|
||||
// get updated.
|
||||
anchorButton.Text += "!";
|
||||
Win.LayoutSubviews ();
|
||||
Application.Top.LayoutSubviews ();
|
||||
};
|
||||
Win.Add (anchorButton);
|
||||
Application.Top.Add (anchorButton);
|
||||
|
||||
// Demonstrate AnchorEnd(n)
|
||||
// This is intentionally convoluted to illustrate potential bugs.
|
||||
var anchorEndLabel1 = new Label ("This Button should be the 2nd to last line (AnchorEnd (2)).") {
|
||||
var anchorEndLabel1 = new Label ("This Label should be the 2nd to last line (AnchorEnd (2)).") {
|
||||
TextAlignment = Terminal.Gui.TextAlignment.Centered,
|
||||
ColorScheme = Colors.Menu,
|
||||
Width = Dim.Fill (1),
|
||||
X = 1,
|
||||
Width = Dim.Fill (5),
|
||||
X = 5,
|
||||
Y = Pos.AnchorEnd (2)
|
||||
};
|
||||
Win.Add (anchorEndLabel1);
|
||||
Application.Top.Add (anchorEndLabel1);
|
||||
|
||||
// Demonstrate DimCombine (via AnchorEnd(n) - 1)
|
||||
// This is intentionally convoluted to illustrate potential bugs.
|
||||
var anchorEndLabel2 = new Label ("This Button should be the 3rd to last line (AnchorEnd (2) - 1).") {
|
||||
TextAlignment = Terminal.Gui.TextAlignment.Centered,
|
||||
var anchorEndLabel2 = new TextField ("This TextField should be the 3rd to last line (AnchorEnd (2) - 1).") {
|
||||
TextAlignment = Terminal.Gui.TextAlignment.Left,
|
||||
ColorScheme = Colors.Menu,
|
||||
Width = Dim.Fill (1),
|
||||
X = 1,
|
||||
Width = Dim.Fill (5),
|
||||
X = 5,
|
||||
Y = Pos.AnchorEnd (2) - 1 // Pos.Combine
|
||||
};
|
||||
Win.Add (anchorEndLabel2);
|
||||
Application.Top.Add (anchorEndLabel2);
|
||||
|
||||
// Show positioning vertically using Pos.AnchorEnd via Pos.Combine
|
||||
var leftButton = new Button ("Left") {
|
||||
@@ -220,10 +246,10 @@ namespace UICatalog.Scenarios {
|
||||
leftButton.Clicked += () => {
|
||||
// Ths demonstrates how to have a dynamically sized button
|
||||
// Each time the button is clicked the button's text gets longer
|
||||
// The call to Win.LayoutSubviews causes the Computed layout to
|
||||
// The call to Application.Top.LayoutSubviews causes the Computed layout to
|
||||
// get updated.
|
||||
leftButton.Text += "!";
|
||||
Win.LayoutSubviews ();
|
||||
Application.Top.LayoutSubviews ();
|
||||
};
|
||||
|
||||
|
||||
@@ -235,10 +261,10 @@ namespace UICatalog.Scenarios {
|
||||
centerButton.Clicked += () => {
|
||||
// Ths demonstrates how to have a dynamically sized button
|
||||
// Each time the button is clicked the button's text gets longer
|
||||
// The call to Win.LayoutSubviews causes the Computed layout to
|
||||
// The call to Application.Top.LayoutSubviews causes the Computed layout to
|
||||
// get updated.
|
||||
centerButton.Text += "!";
|
||||
Win.LayoutSubviews ();
|
||||
Application.Top.LayoutSubviews ();
|
||||
};
|
||||
|
||||
// show positioning vertically using another window and Pos.Bottom
|
||||
@@ -248,19 +274,19 @@ namespace UICatalog.Scenarios {
|
||||
rightButton.Clicked += () => {
|
||||
// Ths demonstrates how to have a dynamically sized button
|
||||
// Each time the button is clicked the button's text gets longer
|
||||
// The call to Win.LayoutSubviews causes the Computed layout to
|
||||
// The call to Application.Top.LayoutSubviews causes the Computed layout to
|
||||
// get updated.
|
||||
rightButton.Text += "!";
|
||||
Win.LayoutSubviews ();
|
||||
Application.Top.LayoutSubviews ();
|
||||
};
|
||||
|
||||
// Center three buttons with 5 spaces between them
|
||||
leftButton.X = Pos.Left (centerButton) - (Pos.Right (leftButton) - Pos.Left (leftButton)) - 5;
|
||||
rightButton.X = Pos.Right (centerButton) + 5;
|
||||
|
||||
Win.Add (leftButton);
|
||||
Win.Add (centerButton);
|
||||
Win.Add (rightButton);
|
||||
Application.Top.Add (leftButton);
|
||||
Application.Top.Add (centerButton);
|
||||
Application.Top.Add (rightButton);
|
||||
}
|
||||
|
||||
public override void Run ()
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
using Terminal.Gui;
|
||||
using System.Data;
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace UICatalog.Scenarios {
|
||||
[ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
public class MyScenario : Scenario {
|
||||
public override void Init (ColorScheme colorScheme)
|
||||
{
|
||||
// The base `Scenario.Init` implementation:
|
||||
// - Calls `Application.Init ()`
|
||||
// - Adds a full-screen Window to Application.Top with a title
|
||||
// that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
|
||||
// - Sets the ColorScheme property of `this.Win` to `colorScheme`.
|
||||
// To overrride this, implement an override of `Init`.
|
||||
base.Init (colorScheme);
|
||||
|
||||
// A common, alternate, implementation where `this.Win` is not used:
|
||||
// Application.Init ();
|
||||
// Application.Top.ColorScheme = colorScheme;
|
||||
}
|
||||
|
||||
public override void Setup ()
|
||||
{
|
||||
// Put your scenario code here, e.g.
|
||||
|
||||
1413
UnitTests/Core/LayoutTests.cs
Normal file
1413
UnitTests/Core/LayoutTests.cs
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
var top = new Toplevel ();
|
||||
|
||||
Assert.Equal (Colors.TopLevel, top.ColorScheme);
|
||||
Assert.Equal ("Dim.Fill(margin=0)", top.Width.ToString ());
|
||||
Assert.Equal ("Dim.Fill(margin=0)", top.Height.ToString ());
|
||||
Assert.Equal ("Fill(0)", top.Width.ToString ());
|
||||
Assert.Equal ("Fill(0)", top.Height.ToString ());
|
||||
Assert.False (top.Running);
|
||||
Assert.False (top.Modal);
|
||||
Assert.Null (top.MenuBar);
|
||||
|
||||
@@ -37,15 +37,15 @@ namespace Terminal.Gui.TypeTests {
|
||||
public void Sized_SetsValue ()
|
||||
{
|
||||
var dim = Dim.Sized (0);
|
||||
Assert.Equal ("Dim.Absolute(0)", dim.ToString ());
|
||||
Assert.Equal ("Absolute(0)", dim.ToString ());
|
||||
|
||||
int testVal = 5;
|
||||
dim = Dim.Sized (testVal);
|
||||
Assert.Equal ($"Dim.Absolute({testVal})", dim.ToString ());
|
||||
Assert.Equal ($"Absolute({testVal})", dim.ToString ());
|
||||
|
||||
testVal = -1;
|
||||
dim = Dim.Sized (testVal);
|
||||
Assert.Equal ($"Dim.Absolute({testVal})", dim.ToString ());
|
||||
Assert.Equal ($"Absolute({testVal})", dim.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -83,11 +83,11 @@ namespace Terminal.Gui.TypeTests {
|
||||
var testVal = Rect.Empty;
|
||||
testVal = Rect.Empty;
|
||||
dim = Dim.Width (new View (testVal));
|
||||
Assert.Equal ($"DimView(side=Width, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
Assert.Equal ($"DimView(Width,View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
|
||||
testVal = new Rect (1, 2, 3, 4);
|
||||
dim = Dim.Width (new View (testVal));
|
||||
Assert.Equal ($"DimView(side=Width, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
Assert.Equal ($"DimView(Width,View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -141,11 +141,11 @@ namespace Terminal.Gui.TypeTests {
|
||||
var testVal = Rect.Empty;
|
||||
testVal = Rect.Empty;
|
||||
dim = Dim.Height (new View (testVal));
|
||||
Assert.Equal ($"DimView(side=Height, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
Assert.Equal ($"DimView(Height,View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
|
||||
testVal = new Rect (1, 2, 3, 4);
|
||||
dim = Dim.Height (new View (testVal));
|
||||
Assert.Equal ($"DimView(side=Height, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
Assert.Equal ($"DimView(Height,View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
|
||||
}
|
||||
|
||||
// TODO: Other Dim.Height tests (e.g. Equal?)
|
||||
@@ -155,15 +155,15 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
var testMargin = 0;
|
||||
var dim = Dim.Fill ();
|
||||
Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString ());
|
||||
Assert.Equal ($"Fill({testMargin})", dim.ToString ());
|
||||
|
||||
testMargin = 0;
|
||||
dim = Dim.Fill (testMargin);
|
||||
Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString ());
|
||||
Assert.Equal ($"Fill({testMargin})", dim.ToString ());
|
||||
|
||||
testMargin = 5;
|
||||
dim = Dim.Fill (testMargin);
|
||||
Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString ());
|
||||
Assert.Equal ($"Fill({testMargin})", dim.ToString ());
|
||||
}
|
||||
|
||||
|
||||
@@ -182,13 +182,13 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
float f = 0;
|
||||
var dim = Dim.Percent (f);
|
||||
Assert.Equal ($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###},{false})", dim.ToString ());
|
||||
f = 0.5F;
|
||||
dim = Dim.Percent (f);
|
||||
Assert.Equal ($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###},{false})", dim.ToString ());
|
||||
f = 100;
|
||||
dim = Dim.Percent (f);
|
||||
Assert.Equal ($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###},{false})", dim.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -420,112 +420,111 @@ namespace Terminal.Gui.TypeTests {
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
Assert.Equal ("Dim.Absolute(100)", w.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(100)", w.Height.ToString ());
|
||||
Assert.Equal ("Absolute(100)", w.Width.ToString ());
|
||||
Assert.Equal ("Absolute(100)", w.Height.ToString ());
|
||||
Assert.Equal (100, w.Frame.Width);
|
||||
Assert.Equal (100, w.Frame.Height);
|
||||
|
||||
Assert.Equal ("Dim.Factor(factor=0.5, remaining=False)", f1.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(5)", f1.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.5,False)", f1.Width.ToString ());
|
||||
Assert.Equal ("Absolute(5)", f1.Height.ToString ());
|
||||
Assert.Equal (49, f1.Frame.Width); // 50-1=49
|
||||
Assert.Equal (5, f1.Frame.Height);
|
||||
|
||||
Assert.Equal ("Dim.Fill(margin=0)", f2.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(5)", f2.Height.ToString ());
|
||||
Assert.Equal ("Fill(0)", f2.Width.ToString ());
|
||||
Assert.Equal ("Absolute(5)", f2.Height.ToString ());
|
||||
Assert.Equal (49, f2.Frame.Width); // 50-1=49
|
||||
Assert.Equal (5, f2.Frame.Height);
|
||||
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=FrameView()({X=0,Y=0,Width=49,Height=5}))-Dim.Absolute(2))", v1.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(Dim.Fill(margin=0)-Dim.Absolute(2))", v1.Height.ToString ());
|
||||
|
||||
Assert.Equal ("Combine(DimView(Width,FrameView()({X=0,Y=0,Width=49,Height=5}))-Absolute(2))", v1.Width.ToString ());
|
||||
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
|
||||
Assert.Equal (47, v1.Frame.Width); // 49-2=47
|
||||
Assert.Equal (89, v1.Frame.Height); // 98-5-2-2=89
|
||||
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=FrameView()({X=49,Y=0,Width=49,Height=5}))-Dim.Absolute(2))", v2.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(Dim.Fill(margin=0)-Dim.Absolute(2))", v2.Height.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Width,FrameView()({X=49,Y=0,Width=49,Height=5}))-Absolute(2))", v2.Width.ToString ());
|
||||
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
|
||||
Assert.Equal (47, v2.Frame.Width); // 49-2=47
|
||||
Assert.Equal (89, v2.Frame.Height); // 98-5-2-2=89
|
||||
|
||||
Assert.Equal ("Dim.Factor(factor=0.1, remaining=False)", v3.Width.ToString ());
|
||||
Assert.Equal ("Dim.Factor(factor=0.1, remaining=False)", v3.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.1,False)", v3.Width.ToString ());
|
||||
Assert.Equal ("Factor(0.1,False)", v3.Height.ToString ());
|
||||
Assert.Equal (9, v3.Frame.Width); // 98*10%=9
|
||||
Assert.Equal (9, v3.Frame.Height); // 98*10%=9
|
||||
|
||||
Assert.Equal ("Dim.Absolute(50)", v4.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(50)", v4.Height.ToString ());
|
||||
Assert.Equal ("Absolute(50)", v4.Width.ToString ());
|
||||
Assert.Equal ("Absolute(50)", v4.Height.ToString ());
|
||||
Assert.Equal (50, v4.Frame.Width);
|
||||
Assert.Equal (50, v4.Frame.Height);
|
||||
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=Button()({X=2,Y=7,Width=47,Height=89}))-DimView(side=Width, target=Button()({X=0,Y=0,Width=9,Height=9})))", v5.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=Button()({X=2,Y=7,Width=47,Height=89}))-DimView(side=Height, target=Button()({X=0,Y=0,Width=9,Height=9})))", v5.Height.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Width,Button()({X=2,Y=7,Width=47,Height=89}))-DimView(Width,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Width.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Height,Button()({X=2,Y=7,Width=47,Height=89}))-DimView(Height,Button()({X=0,Y=0,Width=9,Height=9})))", v5.Height.ToString ());
|
||||
Assert.Equal (38, v5.Frame.Width); // 47-9=38
|
||||
Assert.Equal (80, v5.Frame.Height); // 89-9=80
|
||||
|
||||
Assert.Equal ("Dim.Factor(factor=0.2, remaining=True)", v6.Width.ToString ());
|
||||
Assert.Equal ("Dim.Factor(factor=0.2, remaining=True)", v6.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.2,True)", v6.Width.ToString ());
|
||||
Assert.Equal ("Factor(0.2,True)", v6.Height.ToString ());
|
||||
Assert.Equal (9, v6.Frame.Width); // 47*20%=9
|
||||
Assert.Equal (18, v6.Frame.Height); // 89*20%=18
|
||||
|
||||
|
||||
w.Width = 200;
|
||||
w.Height = 200;
|
||||
t.LayoutSubviews ();
|
||||
|
||||
Assert.Equal ("Dim.Absolute(200)", w.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(200)", w.Height.ToString ());
|
||||
Assert.Equal ("Absolute(200)", w.Width.ToString ());
|
||||
Assert.Equal ("Absolute(200)", w.Height.ToString ());
|
||||
Assert.Equal (200, w.Frame.Width);
|
||||
Assert.Equal (200, w.Frame.Height);
|
||||
|
||||
f1.Text = "Frame1";
|
||||
Assert.Equal ("Dim.Factor(factor=0.5, remaining=False)", f1.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(5)", f1.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.5,False)", f1.Width.ToString ());
|
||||
Assert.Equal ("Absolute(5)", f1.Height.ToString ());
|
||||
Assert.Equal (99, f1.Frame.Width); // 100-1=99
|
||||
Assert.Equal (5, f1.Frame.Height);
|
||||
|
||||
f2.Text = "Frame2";
|
||||
Assert.Equal ("Dim.Fill(margin=0)", f2.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(5)", f2.Height.ToString ());
|
||||
Assert.Equal ("Fill(0)", f2.Width.ToString ());
|
||||
Assert.Equal ("Absolute(5)", f2.Height.ToString ());
|
||||
Assert.Equal (99, f2.Frame.Width); // 100-1=99
|
||||
Assert.Equal (5, f2.Frame.Height);
|
||||
|
||||
v1.Text = "Button1";
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=FrameView()({X=0,Y=0,Width=99,Height=5}))-Dim.Absolute(2))", v1.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(Dim.Fill(margin=0)-Dim.Absolute(2))", v1.Height.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Width,FrameView()({X=0,Y=0,Width=99,Height=5}))-Absolute(2))", v1.Width.ToString ());
|
||||
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
|
||||
Assert.Equal (97, v1.Frame.Width); // 99-2=97
|
||||
Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
|
||||
|
||||
v2.Text = "Button2";
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=FrameView()({X=99,Y=0,Width=99,Height=5}))-Dim.Absolute(2))", v2.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(Dim.Fill(margin=0)-Dim.Absolute(2))", v2.Height.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Width,FrameView()({X=99,Y=0,Width=99,Height=5}))-Absolute(2))", v2.Width.ToString ());
|
||||
Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
|
||||
Assert.Equal (97, v2.Frame.Width); // 99-2=97
|
||||
Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
|
||||
|
||||
v3.Text = "Button3";
|
||||
Assert.Equal ("Dim.Factor(factor=0.1, remaining=False)", v3.Width.ToString ());
|
||||
Assert.Equal ("Dim.Factor(factor=0.1, remaining=False)", v3.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.1,False)", v3.Width.ToString ());
|
||||
Assert.Equal ("Factor(0.1,False)", v3.Height.ToString ());
|
||||
Assert.Equal (19, v3.Frame.Width); // 198*10%=19 * Percent is related to the super-view if it isn't null otherwise the view width
|
||||
Assert.Equal (19, v3.Frame.Height); // 199*10%=19
|
||||
|
||||
v4.Text = "Button4";
|
||||
v4.AutoSize = false;
|
||||
Assert.Equal ("Dim.Absolute(50)", v4.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(50)", v4.Height.ToString ());
|
||||
Assert.Equal ("Absolute(50)", v4.Width.ToString ());
|
||||
Assert.Equal ("Absolute(50)", v4.Height.ToString ());
|
||||
Assert.Equal (50, v4.Frame.Width);
|
||||
Assert.Equal (50, v4.Frame.Height);
|
||||
v4.AutoSize = true;
|
||||
Assert.Equal ("Dim.Absolute(11)", v4.Width.ToString ());
|
||||
Assert.Equal ("Dim.Absolute(1)", v4.Height.ToString ());
|
||||
Assert.Equal ("Absolute(11)", v4.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", v4.Height.ToString ());
|
||||
Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is Dim.DimAbsolute
|
||||
Assert.Equal (1, v4.Frame.Height); // 1 because is Dim.DimAbsolute
|
||||
|
||||
v5.Text = "Button5";
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=Button()({X=2,Y=7,Width=97,Height=189}))-DimView(side=Width, target=Button()({X=0,Y=0,Width=19,Height=19})))", v5.Width.ToString ());
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=Button()({X=2,Y=7,Width=97,Height=189}))-DimView(side=Height, target=Button()({X=0,Y=0,Width=19,Height=19})))", v5.Height.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Width,Button()({X=2,Y=7,Width=97,Height=189}))-DimView(Width,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Width.ToString ());
|
||||
Assert.Equal ("Combine(DimView(Height,Button()({X=2,Y=7,Width=97,Height=189}))-DimView(Height,Button()({X=0,Y=0,Width=19,Height=19})))", v5.Height.ToString ());
|
||||
Assert.Equal (78, v5.Frame.Width); // 97-19=78
|
||||
Assert.Equal (170, v5.Frame.Height); // 189-19=170
|
||||
|
||||
v6.Text = "Button6";
|
||||
Assert.Equal ("Dim.Factor(factor=0.2, remaining=True)", v6.Width.ToString ());
|
||||
Assert.Equal ("Dim.Factor(factor=0.2, remaining=True)", v6.Height.ToString ());
|
||||
Assert.Equal ("Factor(0.2,True)", v6.Width.ToString ());
|
||||
Assert.Equal ("Factor(0.2,True)", v6.Height.ToString ());
|
||||
Assert.Equal (19, v6.Frame.Width); // 99*20%=19
|
||||
Assert.Equal (38, v6.Frame.Height); // 198-7*20=38
|
||||
};
|
||||
@@ -635,12 +634,12 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = view.Bounds.Height, Width = 20 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {count}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({count})", label.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", label.Y.ToString ());
|
||||
|
||||
Assert.Equal ($"Dim.Absolute({count})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", view.Height.ToString ());
|
||||
view.Height += 1;
|
||||
count++;
|
||||
Assert.Equal ($"Dim.Absolute({count})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", view.Height.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1007,18 +1006,18 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = view.Bounds.Height, Width = 10 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {count}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({count + 1})", label.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count + 1})", label.Y.ToString ());
|
||||
listLabels.Add (label);
|
||||
if (count == 0) {
|
||||
Assert.Equal ($"Dim.Absolute({count})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", view.Height.ToString ());
|
||||
view.Height += 2;
|
||||
} else {
|
||||
Assert.Equal ($"Dim.Absolute({count + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
|
||||
view.Height += 1;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
Assert.Equal ($"Dim.Absolute({count + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1067,12 +1066,12 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = view.Bounds.Height, Width = 20 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {i}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({i})", label.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({i})", label.Y.ToString ());
|
||||
listLabels.Add (label);
|
||||
|
||||
Assert.Equal ($"Dim.Absolute({i})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i})", view.Height.ToString ());
|
||||
view.Height += 1;
|
||||
Assert.Equal ($"Dim.Absolute({i + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 1})", view.Height.ToString ());
|
||||
}
|
||||
|
||||
field.KeyDown += (k) => {
|
||||
@@ -1080,10 +1079,10 @@ namespace Terminal.Gui.TypeTests {
|
||||
Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
|
||||
view.Remove (listLabels [count - 1]);
|
||||
|
||||
Assert.Equal ($"Dim.Absolute({count})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", view.Height.ToString ());
|
||||
view.Height -= 1;
|
||||
count--;
|
||||
Assert.Equal ($"Dim.Absolute({count})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", view.Height.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1126,17 +1125,17 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = view.Bounds.Height, Width = 10 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {i}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({i + 1})", label.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 1})", label.Y.ToString ());
|
||||
listLabels.Add (label);
|
||||
|
||||
if (i == 0) {
|
||||
Assert.Equal ($"Dim.Absolute({i})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i})", view.Height.ToString ());
|
||||
view.Height += 2;
|
||||
Assert.Equal ($"Dim.Absolute({i + 2})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 2})", view.Height.ToString ());
|
||||
} else {
|
||||
Assert.Equal ($"Dim.Absolute({i + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 1})", view.Height.ToString ());
|
||||
view.Height += 1;
|
||||
Assert.Equal ($"Dim.Absolute({i + 2})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 2})", view.Height.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1150,7 +1149,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
|
||||
view.Remove (listLabels [count - 1]);
|
||||
listLabels.RemoveAt (count - 1);
|
||||
Assert.Equal ($"Dim.Absolute({count + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
|
||||
view.Height -= 1;
|
||||
count--;
|
||||
if (listLabels.Count > 0)
|
||||
@@ -1158,7 +1157,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
else
|
||||
field.Text = NStack.ustring.Empty;
|
||||
}
|
||||
Assert.Equal ($"Dim.Absolute({count + 1})", view.Height.ToString ());
|
||||
Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1218,13 +1217,13 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
var text = "Test";
|
||||
var dim = Dim.Function (() => text.Length);
|
||||
Assert.Equal ("Dim.DimFunc(4)", dim.ToString ());
|
||||
Assert.Equal ("DimFunc(4)", dim.ToString ());
|
||||
|
||||
text = "New Test";
|
||||
Assert.Equal ("Dim.DimFunc(8)", dim.ToString ());
|
||||
Assert.Equal ("DimFunc(8)", dim.ToString ());
|
||||
|
||||
text = "";
|
||||
Assert.Equal ("Dim.DimFunc(0)", dim.ToString ());
|
||||
Assert.Equal ("DimFunc(0)", dim.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
var n = 0;
|
||||
var pos = Pos.AnchorEnd ();
|
||||
Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
|
||||
Assert.Equal ($"AnchorEnd({n})", pos.ToString ());
|
||||
|
||||
n = 5;
|
||||
pos = Pos.AnchorEnd (n);
|
||||
Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
|
||||
Assert.Equal ($"AnchorEnd({n})", pos.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -351,13 +351,13 @@ namespace Terminal.Gui.TypeTests {
|
||||
public void At_SetsValue ()
|
||||
{
|
||||
var pos = Pos.At (0);
|
||||
Assert.Equal ("Pos.Absolute(0)", pos.ToString ());
|
||||
Assert.Equal ("Absolute(0)", pos.ToString ());
|
||||
|
||||
pos = Pos.At (5);
|
||||
Assert.Equal ("Pos.Absolute(5)", pos.ToString ());
|
||||
Assert.Equal ("Absolute(5)", pos.ToString ());
|
||||
|
||||
pos = Pos.At (-1);
|
||||
Assert.Equal ("Pos.Absolute(-1)", pos.ToString ());
|
||||
Assert.Equal ("Absolute(-1)", pos.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -411,140 +411,140 @@ namespace Terminal.Gui.TypeTests {
|
||||
testInt = 0;
|
||||
testRect = Rect.Empty;
|
||||
pos = Pos.Left (new View ());
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
pos = Pos.Left (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testRect = new Rect (1, 2, 3, 4);
|
||||
pos = Pos.Left (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Left(win) + 0
|
||||
pos = Pos.Left (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = 1;
|
||||
// Pos.Left(win) +1
|
||||
pos = Pos.Left (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = -1;
|
||||
// Pos.Left(win) -1
|
||||
pos = Pos.Left (new View (testRect)) - testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.X
|
||||
side = "x";
|
||||
testInt = 0;
|
||||
testRect = Rect.Empty;
|
||||
pos = Pos.X (new View ());
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
pos = Pos.X (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testRect = new Rect (1, 2, 3, 4);
|
||||
pos = Pos.X (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.X(win) + 0
|
||||
pos = Pos.X (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = 1;
|
||||
// Pos.X(win) +1
|
||||
pos = Pos.X (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = -1;
|
||||
// Pos.X(win) -1
|
||||
pos = Pos.X (new View (testRect)) - testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Top
|
||||
side = "y";
|
||||
testInt = 0;
|
||||
testRect = Rect.Empty;
|
||||
pos = Pos.Top (new View ());
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
pos = Pos.Top (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testRect = new Rect (1, 2, 3, 4);
|
||||
pos = Pos.Top (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Top(win) + 0
|
||||
pos = Pos.Top (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = 1;
|
||||
// Pos.Top(win) +1
|
||||
pos = Pos.Top (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = -1;
|
||||
// Pos.Top(win) -1
|
||||
pos = Pos.Top (new View (testRect)) - testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Y
|
||||
side = "y";
|
||||
testInt = 0;
|
||||
testRect = Rect.Empty;
|
||||
pos = Pos.Y (new View ());
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
pos = Pos.Y (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testRect = new Rect (1, 2, 3, 4);
|
||||
pos = Pos.Y (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Y(win) + 0
|
||||
pos = Pos.Y (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = 1;
|
||||
// Pos.Y(win) +1
|
||||
pos = Pos.Y (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = -1;
|
||||
// Pos.Y(win) -1
|
||||
pos = Pos.Y (new View (testRect)) - testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Bottom
|
||||
side = "bottom";
|
||||
testRect = Rect.Empty;
|
||||
testInt = 0;
|
||||
pos = Pos.Bottom (new View ());
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
pos = Pos.Bottom (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testRect = new Rect (1, 2, 3, 4);
|
||||
pos = Pos.Bottom (new View (testRect));
|
||||
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
// Pos.Bottom(win) + 0
|
||||
pos = Pos.Bottom (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = 1;
|
||||
// Pos.Bottom(win) +1
|
||||
pos = Pos.Bottom (new View (testRect)) + testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
|
||||
testInt = -1;
|
||||
// Pos.Bottom(win) -1
|
||||
pos = Pos.Bottom (new View (testRect)) - testInt;
|
||||
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
Assert.Equal ($"Combine(Pos.Combine(Pos.View({side},View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
|
||||
}
|
||||
|
||||
// See: https://github.com/gui-cs/Terminal.Gui/issues/504
|
||||
@@ -632,7 +632,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
public void Center_SetsValue ()
|
||||
{
|
||||
var pos = Pos.Center ();
|
||||
Assert.Equal ("Pos.Center", pos.ToString ());
|
||||
Assert.Equal ("Center", pos.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -640,13 +640,13 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
float f = 0;
|
||||
var pos = Pos.Percent (f);
|
||||
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###})", pos.ToString ());
|
||||
f = 0.5F;
|
||||
pos = Pos.Percent (f);
|
||||
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###})", pos.ToString ());
|
||||
f = 100;
|
||||
pos = Pos.Percent (f);
|
||||
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
|
||||
Assert.Equal ($"Factor({f / 100:0.###})", pos.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -881,12 +881,12 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = field.Y, Width = 20 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {count}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({count})", label.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", label.Y.ToString ());
|
||||
|
||||
Assert.Equal ($"Pos.Absolute({count})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", field.Y.ToString ());
|
||||
field.Y += 1;
|
||||
count++;
|
||||
Assert.Equal ($"Pos.Absolute({count})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", field.Y.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -930,12 +930,12 @@ namespace Terminal.Gui.TypeTests {
|
||||
var label = new Label (field.Text) { X = 0, Y = field.Y, Width = 20 };
|
||||
view.Add (label);
|
||||
Assert.Equal ($"Label {i}", label.Text);
|
||||
Assert.Equal ($"Pos.Absolute({i})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({i})", field.Y.ToString ());
|
||||
listLabels.Add (label);
|
||||
|
||||
Assert.Equal ($"Pos.Absolute({i})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({i})", field.Y.ToString ());
|
||||
field.Y += 1;
|
||||
Assert.Equal ($"Pos.Absolute({i + 1})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({i + 1})", field.Y.ToString ());
|
||||
}
|
||||
|
||||
field.KeyDown += (k) => {
|
||||
@@ -943,10 +943,10 @@ namespace Terminal.Gui.TypeTests {
|
||||
Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
|
||||
view.Remove (listLabels [count - 1]);
|
||||
|
||||
Assert.Equal ($"Pos.Absolute({count})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", field.Y.ToString ());
|
||||
field.Y -= 1;
|
||||
count--;
|
||||
Assert.Equal ($"Pos.Absolute({count})", field.Y.ToString ());
|
||||
Assert.Equal ($"Absolute({count})", field.Y.ToString ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -992,6 +992,11 @@ namespace Terminal.Gui.TypeTests {
|
||||
Assert.Equal (posCombine.right, posAbsolute);
|
||||
Assert.Equal (20, posCombine.Anchor (100));
|
||||
|
||||
posCombine = new Pos.PosCombine (true, posAbsolute, posFactor);
|
||||
Assert.Equal (posCombine.left, posAbsolute);
|
||||
Assert.Equal (posCombine.right, posFactor);
|
||||
Assert.Equal (20, posCombine.Anchor (100));
|
||||
|
||||
var view = new View (new Rect (20, 10, 20, 1));
|
||||
var posViewX = new Pos.PosView (view, 0);
|
||||
Assert.Equal (20, posViewX.Anchor (0));
|
||||
@@ -1008,13 +1013,13 @@ namespace Terminal.Gui.TypeTests {
|
||||
{
|
||||
var text = "Test";
|
||||
var pos = Pos.Function (() => text.Length);
|
||||
Assert.Equal ("Pos.PosFunc(4)", pos.ToString ());
|
||||
Assert.Equal ("PosFunc(4)", pos.ToString ());
|
||||
|
||||
text = "New Test";
|
||||
Assert.Equal ("Pos.PosFunc(8)", pos.ToString ());
|
||||
Assert.Equal ("PosFunc(8)", pos.ToString ());
|
||||
|
||||
text = "";
|
||||
Assert.Equal ("Pos.PosFunc(0)", pos.ToString ());
|
||||
Assert.Equal ("PosFunc(0)", pos.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -362,85 +362,85 @@ namespace Terminal.Gui.ViewTests {
|
||||
_hostView.Redraw (_hostView.Bounds);
|
||||
Assert.True (_scrollBar.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.Visible);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal (1, _scrollBar.Bounds.Width);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Height,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.Height.ToString ());
|
||||
Assert.Equal (24, _scrollBar.Bounds.Height);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.Visible);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Width,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.OtherScrollBarView.Width.ToString ());
|
||||
Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
|
||||
|
||||
_hostView.Lines = 10;
|
||||
_hostView.Redraw (_hostView.Bounds);
|
||||
Assert.False (_scrollBar.ShowScrollIndicator);
|
||||
Assert.False (_scrollBar.Visible);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal (1, _scrollBar.Bounds.Width);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Height,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.Height.ToString ());
|
||||
Assert.Equal (24, _scrollBar.Bounds.Height);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.Visible);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(0))",
|
||||
Assert.Equal ("Combine(DimView(Width,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(0))",
|
||||
_scrollBar.OtherScrollBarView.Width.ToString ());
|
||||
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
|
||||
|
||||
_hostView.Cols = 60;
|
||||
_hostView.Redraw (_hostView.Bounds);
|
||||
Assert.False (_scrollBar.ShowScrollIndicator);
|
||||
Assert.False (_scrollBar.Visible);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal (1, _scrollBar.Bounds.Width);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Height,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.Height.ToString ());
|
||||
Assert.Equal (24, _scrollBar.Bounds.Height);
|
||||
Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
|
||||
Assert.False (_scrollBar.OtherScrollBarView.Visible);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(0))",
|
||||
Assert.Equal ("Combine(DimView(Width,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(0))",
|
||||
_scrollBar.OtherScrollBarView.Width.ToString ());
|
||||
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
|
||||
|
||||
_hostView.Lines = 40;
|
||||
_hostView.Redraw (_hostView.Bounds);
|
||||
Assert.True (_scrollBar.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.Visible);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal (1, _scrollBar.Bounds.Width);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(0))",
|
||||
Assert.Equal ("Combine(DimView(Height,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(0))",
|
||||
_scrollBar.Height.ToString ());
|
||||
Assert.Equal (25, _scrollBar.Bounds.Height);
|
||||
Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
|
||||
Assert.False (_scrollBar.OtherScrollBarView.Visible);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(0))",
|
||||
Assert.Equal ("Combine(DimView(Width,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(0))",
|
||||
_scrollBar.OtherScrollBarView.Width.ToString ());
|
||||
Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
|
||||
|
||||
_hostView.Cols = 120;
|
||||
_hostView.Redraw (_hostView.Bounds);
|
||||
Assert.True (_scrollBar.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.Visible);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
|
||||
Assert.Equal (1, _scrollBar.Bounds.Width);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Height, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Height,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.Height.ToString ());
|
||||
Assert.Equal (24, _scrollBar.Bounds.Height);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
|
||||
Assert.True (_scrollBar.OtherScrollBarView.Visible);
|
||||
Assert.Equal ("Dim.Combine(DimView(side=Width, target=HostView()({X=0,Y=0,Width=80,Height=25}))-Dim.Absolute(1))",
|
||||
Assert.Equal ("Combine(DimView(Width,HostView()({X=0,Y=0,Width=80,Height=25}))-Absolute(1))",
|
||||
_scrollBar.OtherScrollBarView.Width.ToString ());
|
||||
Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width);
|
||||
Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
|
||||
Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.False (sb.CanFocus);
|
||||
Assert.Equal (Colors.Menu, sb.ColorScheme);
|
||||
Assert.Equal (0, sb.X);
|
||||
Assert.Equal ("Pos.AnchorEnd(margin=1)", sb.Y.ToString ());
|
||||
Assert.Equal ("AnchorEnd(1)", sb.Y.ToString ());
|
||||
Assert.Equal (Dim.Fill (), sb.Width);
|
||||
Assert.Equal (1, sb.Height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user