Progress on removing AutoSize.

This commit is contained in:
Tig
2024-05-03 13:13:12 -06:00
parent 44f75c5fd5
commit be8f7fadc6
9 changed files with 35 additions and 57 deletions

View File

@@ -28,7 +28,6 @@ public class BasicColors : Scenario
var vl = new Label
{
AutoSize = false,
X = vx,
Y = 0,
Width = 1,
@@ -42,7 +41,6 @@ public class BasicColors : Scenario
var hl = new Label
{
AutoSize = false,
X = 15,
Y = y,
Width = 13,

View File

@@ -260,7 +260,6 @@ public class Buttons : Scenario
{
X = 2,
Y = Pos.Bottom (radioGroup) + 1,
AutoSize = false,
Height = 1,
Width = Dim.Width (computedFrame) - 2,
ColorScheme = Colors.ColorSchemes ["TopLevel"],
@@ -275,7 +274,6 @@ public class Buttons : Scenario
{
X = Pos.Left (absoluteFrame) + 1,
Y = Pos.Bottom (radioGroup) + 1,
AutoSize = false,
Height = 1,
Width = Dim.Width (absoluteFrame) - 2, // BUGBUG: Not always the width isn't calculated correctly.
ColorScheme = Colors.ColorSchemes ["TopLevel"],
@@ -426,7 +424,6 @@ public class Buttons : Scenario
_down = new ()
{
AutoSize = false,
Height = 1,
Width = 1,
NoPadding = true,
@@ -439,7 +436,6 @@ public class Buttons : Scenario
_number = new ()
{
Text = Value.ToString (),
AutoSize = false,
X = Pos.Right (_down),
Y = Pos.Top (_down),
Width = Dim.Function (() => Digits),
@@ -450,7 +446,6 @@ public class Buttons : Scenario
_up = new ()
{
AutoSize = false,
X = Pos.AnchorEnd (),
Y = Pos.Top (_number),
Height = 1,

View File

@@ -472,7 +472,6 @@ internal class CharMap : View
var up = new Button
{
AutoSize = false,
X = Pos.AnchorEnd (1),
Y = 0,
Height = 1,
@@ -487,7 +486,6 @@ internal class CharMap : View
var down = new Button
{
AutoSize = false,
X = Pos.AnchorEnd (1),
Y = Pos.AnchorEnd (2),
Height = 1,
@@ -502,7 +500,6 @@ internal class CharMap : View
var left = new Button
{
AutoSize = false,
X = 0,
Y = Pos.AnchorEnd (1),
Height = 1,
@@ -517,7 +514,6 @@ internal class CharMap : View
var right = new Button
{
AutoSize = false,
X = Pos.AnchorEnd (2),
Y = Pos.AnchorEnd (1),
Height = 1,

View File

@@ -145,7 +145,6 @@ public class CollectionNavigatorTester : Scenario
TextAlignment = TextAlignment.Centered,
X = 0,
Y = 1, // for menu
AutoSize = false,
Width = Dim.Percent (50),
Height = 1
};
@@ -175,7 +174,6 @@ public class CollectionNavigatorTester : Scenario
TextAlignment = TextAlignment.Centered,
X = Pos.Right (_listView) + 2,
Y = 1, // for menu
AutoSize = false,
Width = Dim.Percent (50),
Height = 1
};

View File

@@ -12,7 +12,7 @@ public class ComboBoxIteration : Scenario
{
List<string> items = new () { "one", "two", "three" };
var lbListView = new Label { AutoSize = false, Width = 10, Height = 1 };
var lbListView = new Label { Width = 10, Height = 1 };
Win.Add (lbListView);
var listview = new ListView
@@ -25,7 +25,6 @@ public class ComboBoxIteration : Scenario
{
ColorScheme = Colors.ColorSchemes ["TopLevel"],
X = Pos.Right (lbListView) + 1,
AutoSize = false,
Width = Dim.Percent (40)
};

View File

@@ -27,7 +27,6 @@ public class ComputedLayout : Scenario
var horizontalRuler = new Label
{
AutoSize = false,
X = 0,
Y = 0,
Width = Dim.Fill (),
@@ -43,7 +42,6 @@ public class ComputedLayout : Scenario
var verticalRuler = new Label
{
AutoSize = false,
X = 0,
Y = 0,
Width = 1,
@@ -93,7 +91,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Left,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -106,7 +103,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Right,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -119,7 +115,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Centered,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -132,7 +127,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Justified,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -159,7 +153,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Left,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -172,7 +165,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Right,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -185,7 +177,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Centered,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -198,7 +189,6 @@ public class ComputedLayout : Scenario
new Label
{
TextAlignment = TextAlignment.Justified,
AutoSize = false,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -335,7 +325,6 @@ public class ComputedLayout : Scenario
Text = "This Label should be the 2nd to last line (AnchorEnd (2)).",
TextAlignment = TextAlignment.Centered,
ColorScheme = Colors.ColorSchemes ["Menu"],
AutoSize = false,
Width = Dim.Fill (5),
X = 5,
Y = Pos.AnchorEnd (2)
@@ -350,7 +339,6 @@ public class ComputedLayout : Scenario
"This TextField should be the 3rd to last line (AnchorEnd (2) - 1).",
TextAlignment = TextAlignment.Left,
ColorScheme = Colors.ColorSchemes ["Menu"],
AutoSize = false,
Width = Dim.Fill (5),
X = 5,
Y = Pos.AnchorEnd (2) - 1 // Pos.Combine

View File

@@ -46,7 +46,7 @@ public class ContentScrolling : Scenario
// Add a status label to the border that shows Viewport and ContentSize values. Bit of a hack.
// TODO: Move to Padding with controls
Border.Add (new Label { AutoSize = false, X = 20 });
Border.Add (new Label { X = 20 });
LayoutComplete += VirtualDemoView_LayoutComplete;
MouseEvent += VirtualDemoView_MouseEvent;

View File

@@ -59,10 +59,10 @@ public class SendKeys : Scenario
}
};
var lblShippedKeys = new Label { X = Pos.Center (), Y = Pos.Center () + 3, AutoSize = true };
var lblShippedKeys = new Label { X = Pos.Center (), Y = Pos.Center () + 3 };
Win.Add (lblShippedKeys);
var lblShippedControlKeys = new Label { X = Pos.Center (), Y = Pos.Center () + 5, AutoSize = true };
var lblShippedControlKeys = new Label { X = Pos.Center (), Y = Pos.Center () + 5 };
Win.Add (lblShippedControlKeys);
var button = new Button { X = Pos.Center (), Y = Pos.Center () + 7, IsDefault = true, Text = "Process keys" };

View File

@@ -14,7 +14,7 @@ public class ScenarioTests : TestsAllViews
#endif
_output = output;
}
public static IEnumerable<object []> AllScenarioTypes =>
typeof (Scenario).Assembly
.GetTypes ()
@@ -129,9 +129,9 @@ public class ScenarioTests : TestsAllViews
var top = new Toplevel ();
_viewClasses = TestHelpers.GetAllViewClasses ().ToDictionary(t => t.Name);
_viewClasses = TestHelpers.GetAllViewClasses ().ToDictionary (t => t.Name);
_leftPane = new()
_leftPane = new ()
{
Title = "Classes",
X = 0,
@@ -142,7 +142,7 @@ public class ScenarioTests : TestsAllViews
ColorScheme = Colors.ColorSchemes ["TopLevel"]
};
_classListView = new()
_classListView = new ()
{
X = 0,
Y = 0,
@@ -154,7 +154,7 @@ public class ScenarioTests : TestsAllViews
};
_leftPane.Add (_classListView);
_settingsPane = new()
_settingsPane = new ()
{
X = Pos.Right (_leftPane),
Y = 0, // for menu
@@ -164,12 +164,12 @@ public class ScenarioTests : TestsAllViews
ColorScheme = Colors.ColorSchemes ["TopLevel"],
Title = "Settings"
};
_computedCheckBox = new() { X = 0, Y = 0, Text = "Computed Layout", Checked = true };
_computedCheckBox = new () { X = 0, Y = 0, Text = "Computed Layout", Checked = true };
_settingsPane.Add (_computedCheckBox);
var radioItems = new [] { "Percent(x)", "AnchorEnd(x)", "Center", "At(x)" };
_locationFrame = new()
_locationFrame = new ()
{
X = Pos.Left (_computedCheckBox),
Y = Pos.Bottom (_computedCheckBox),
@@ -181,21 +181,21 @@ public class ScenarioTests : TestsAllViews
var label = new Label { X = 0, Y = 0, Text = "x:" };
_locationFrame.Add (label);
_xRadioGroup = new() { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_xText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
_xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
_locationFrame.Add (_xText);
_locationFrame.Add (_xRadioGroup);
radioItems = new [] { "Percent(y)", "AnchorEnd(y)", "Center", "At(y)" };
label = new() { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "y:" };
label = new () { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "y:" };
_locationFrame.Add (label);
_yText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
_yText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
_locationFrame.Add (_yText);
_yRadioGroup = new() { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_locationFrame.Add (_yRadioGroup);
_sizeFrame = new()
_sizeFrame = new ()
{
X = Pos.Right (_locationFrame),
Y = Pos.Y (_locationFrame),
@@ -205,25 +205,25 @@ public class ScenarioTests : TestsAllViews
};
radioItems = new [] { "Auto()", "Percent(width)", "Fill(width)", "Sized(width)" };
label = new() { X = 0, Y = 0, Text = "width:" };
label = new () { X = 0, Y = 0, Text = "width:" };
_sizeFrame.Add (label);
_wRadioGroup = new() { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_wText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
_wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
_sizeFrame.Add (_wText);
_sizeFrame.Add (_wRadioGroup);
radioItems = new [] { "Auto()", "Percent(height)", "Fill(height)", "Sized(height)" };
label = new() { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "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}" };
_hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
_sizeFrame.Add (_hText);
_hRadioGroup = new() { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_sizeFrame.Add (_hRadioGroup);
_settingsPane.Add (_sizeFrame);
_hostPane = new()
_hostPane = new ()
{
X = Pos.Right (_leftPane),
Y = Pos.Bottom (_settingsPane),
@@ -477,19 +477,23 @@ public class ScenarioTests : TestsAllViews
// Instantiate view
var view = (View)Activator.CreateInstance (type);
//_curView.X = Pos.Center ();
//_curView.Y = Pos.Center ();
if (!view.AutoSize)
if (view is null)
{
return null;
}
if (view.Width is not Dim.DimAuto)
{
view.Width = Dim.Percent (75);
}
if (view.Height is not Dim.DimAuto)
{
view.Height = Dim.Percent (75);
}
// Set the colorscheme to make it stand out if is null by default
if (view.ColorScheme == null)
{
view.ColorScheme = Colors.ColorSchemes ["Base"];
}
view.ColorScheme ??= Colors.ColorSchemes ["Base"];
// If the view supports a Text property, set it so we have something to look at
if (view.GetType ().GetProperty ("Text") != null)