Dim.Sized -> Dim.Absolute

This commit is contained in:
Tig
2024-05-14 20:58:27 -07:00
parent 08199f84c5
commit d2e24993fb
10 changed files with 62 additions and 59 deletions

View File

@@ -204,7 +204,7 @@ public class ScenarioTests : TestsAllViews
Title = "Size (Dim)"
};
radioItems = new [] { "Auto()", "Percent(width)", "Fill(width)", "Sized(width)" };
radioItems = new [] { "Auto()", "Percent(width)", "Fill(width)", "Absolute(width)" };
label = new () { X = 0, Y = 0, Text = "width:" };
_sizeFrame.Add (label);
_wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
@@ -212,7 +212,7 @@ public class ScenarioTests : TestsAllViews
_sizeFrame.Add (_wText);
_sizeFrame.Add (_wRadioGroup);
radioItems = new [] { "Auto()", "Percent(height)", "Fill(height)", "Sized(height)" };
radioItems = new [] { "Auto()", "Percent(height)", "Fill(height)", "Absolute(height)" };
label = new () { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "height:" };
_sizeFrame.Add (label);
_hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
@@ -408,7 +408,7 @@ public class ScenarioTests : TestsAllViews
break;
case 2:
view.Width = Dim.Sized (_wVal);
view.Width = Dim.Absolute (_wVal);
break;
}
@@ -424,7 +424,7 @@ public class ScenarioTests : TestsAllViews
break;
case 2:
view.Height = Dim.Sized (_hVal);
view.Height = Dim.Absolute (_hVal);
break;
}

View File

@@ -66,8 +66,8 @@ public class AbsoluteLayoutTests
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ());
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}
@@ -180,8 +180,8 @@ public class AbsoluteLayoutTests
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Sized (0), v.Width);
Assert.Equal (Dim.Sized (0), v.Height);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
frame = new Rectangle (1, 2, 3, 4);
@@ -195,8 +195,8 @@ public class AbsoluteLayoutTests
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new View { Frame = frame, Text = "v" };
@@ -209,8 +209,8 @@ public class AbsoluteLayoutTests
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new View { X = frame.X, Y = frame.Y, Text = "v" };
@@ -223,8 +223,8 @@ public class AbsoluteLayoutTests
Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (0), v.Width);
Assert.Equal (Dim.Sized (0), v.Height);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new View ();
@@ -233,8 +233,8 @@ public class AbsoluteLayoutTests
Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Sized (0), v.Width);
Assert.Equal (Dim.Sized (0), v.Height);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new View { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
@@ -243,8 +243,8 @@ public class AbsoluteLayoutTests
Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}

View File

@@ -1011,8 +1011,8 @@ public class DimAutoTests (ITestOutputHelper output)
{
X = subViewOffset,
Y = subViewOffset,
Width = Dim.Sized (dimAbsoluteSize),
Height = Dim.Sized (dimAbsoluteSize)
Width = Dim.Absolute (dimAbsoluteSize),
Height = Dim.Absolute (dimAbsoluteSize)
};
view.Add (subview);

View File

@@ -215,7 +215,7 @@ public class DimTests
{
var t = new View { Width = 80, Height = 25, Text = "top" };
var w = new Window { Width = Dim.Fill (), Height = Dim.Sized (10) };
var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
w.Add (v);
@@ -292,7 +292,7 @@ public class DimTests
{
var t = new View { Width = 80, Height = 25, Text = "top" };
var w = new Window { Width = Dim.Fill (), Height = Dim.Sized (10) };
var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
w.Add (v);
@@ -434,8 +434,8 @@ public class DimTests
var v4 = new Button
{
Width = Dim.Sized (50),
Height = Dim.Sized (50),
Width = Dim.Absolute (50),
Height = Dim.Absolute (50),
ValidatePosDim = true,
Text = "v4"
};
@@ -641,39 +641,39 @@ public class DimTests
{
var n1 = 0;
var n2 = 0;
Dim dim1 = Dim.Sized (n1);
Dim dim2 = Dim.Sized (n2);
Dim dim1 = Dim.Absolute (n1);
Dim dim2 = Dim.Absolute (n2);
Assert.Equal (dim1, dim2);
n1 = n2 = 1;
dim1 = Dim.Sized (n1);
dim2 = Dim.Sized (n2);
dim1 = Dim.Absolute (n1);
dim2 = Dim.Absolute (n2);
Assert.Equal (dim1, dim2);
n1 = n2 = -1;
dim1 = Dim.Sized (n1);
dim2 = Dim.Sized (n2);
dim1 = Dim.Absolute (n1);
dim2 = Dim.Absolute (n2);
Assert.Equal (dim1, dim2);
n1 = 0;
n2 = 1;
dim1 = Dim.Sized (n1);
dim2 = Dim.Sized (n2);
dim1 = Dim.Absolute (n1);
dim2 = Dim.Absolute (n2);
Assert.NotEqual (dim1, dim2);
}
[Fact]
public void DimSized_SetsValue ()
{
Dim dim = Dim.Sized (0);
Dim dim = Dim.Absolute (0);
Assert.Equal ("Absolute(0)", dim.ToString ());
var testVal = 5;
dim = Dim.Sized (testVal);
dim = Dim.Absolute (testVal);
Assert.Equal ($"Absolute({testVal})", dim.ToString ());
testVal = -1;
dim = Dim.Sized (testVal);
dim = Dim.Absolute (testVal);
Assert.Equal ($"Absolute({testVal})", dim.ToString ());
}

View File

@@ -56,8 +56,8 @@ public class FrameTests (ITestOutputHelper output)
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (30), v.Width);
Assert.Equal (Dim.Sized (40), v.Height);
Assert.Equal (Dim.Absolute (30), v.Width);
Assert.Equal (Dim.Absolute (40), v.Height);
v.Dispose ();
v = new View { X = frame.X, Y = frame.Y, Text = "v" };
@@ -71,8 +71,8 @@ public class FrameTests (ITestOutputHelper output)
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (30), v.Width);
Assert.Equal (Dim.Sized (40), v.Height);
Assert.Equal (Dim.Absolute (30), v.Width);
Assert.Equal (Dim.Absolute (40), v.Height);
v.Dispose ();
newFrame = new Rectangle (10, 20, 30, 40);
@@ -87,8 +87,8 @@ public class FrameTests (ITestOutputHelper output)
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (10), v.X);
Assert.Equal (Pos.Absolute (20), v.Y);
Assert.Equal (Dim.Sized (30), v.Width);
Assert.Equal (Dim.Sized (40), v.Height);
Assert.Equal (Dim.Absolute (30), v.Width);
Assert.Equal (Dim.Absolute (40), v.Height);
v.Dispose ();
v = new View { X = frame.X, Y = frame.Y, Text = "v" };
@@ -102,8 +102,8 @@ public class FrameTests (ITestOutputHelper output)
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (10), v.X);
Assert.Equal (Pos.Absolute (20), v.Y);
Assert.Equal (Dim.Sized (30), v.Width);
Assert.Equal (Dim.Sized (40), v.Height);
Assert.Equal (Dim.Absolute (30), v.Width);
Assert.Equal (Dim.Absolute (40), v.Height);
v.Dispose ();
}
}

View File

@@ -190,8 +190,8 @@ public class ViewportTests (ITestOutputHelper output)
Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (30), v.Width);
Assert.Equal (Dim.Sized (40), v.Height);
Assert.Equal (Dim.Absolute (30), v.Width);
Assert.Equal (Dim.Absolute (40), v.Height);
newViewport = new Rectangle (0, 0, 3, 4);
v.Viewport = newViewport;
@@ -200,8 +200,8 @@ public class ViewportTests (ITestOutputHelper output)
Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.BorderStyle = LineStyle.Single;
@@ -212,8 +212,8 @@ public class ViewportTests (ITestOutputHelper output)
Assert.Equal (new Rectangle (1, 2, 3, 4), v.Frame);
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (3), v.Width);
Assert.Equal (Dim.Sized (4), v.Height);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
// Now set bounds bigger as before
newViewport = new Rectangle (0, 0, 3, 4);
@@ -225,8 +225,8 @@ public class ViewportTests (ITestOutputHelper output)
Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Sized (5), v.Width);
Assert.Equal (Dim.Sized (6), v.Height);
Assert.Equal (Dim.Absolute (5), v.Width);
Assert.Equal (Dim.Absolute (6), v.Height);
}
[Theory]