Browse Source

AutoSize in comments i gone too.

Tig 1 year ago
parent
commit
3e1025897b

+ 0 - 1
Terminal.Gui/Views/Dialog.cs

@@ -146,7 +146,6 @@ public class Dialog : Window
             return;
         }
 
-        //button.AutoSize = false; // BUGBUG: v2 - Hack to get around autosize not accounting for Margin?
         _buttons.Add (button);
         Add (button);
 

+ 1 - 1
Terminal.Gui/Views/Slider.cs

@@ -615,7 +615,7 @@ public class Slider<T> : View
         // Last = '┤',
     }
 
-    /// <summary>Adjust the dimensions of the Slider to the best value if <see cref="AutoSize"/> is true.</summary>
+    /// <summary>Adjust the dimensions of the Slider to the best value.</summary>
     public void SetContentSizeBestFit ()
     {
         if (!IsInitialized || /*!(Height is Dim.DimAuto && Width is Dim.DimAuto) || */_options.Count == 0)

+ 1 - 1
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -32,7 +32,7 @@ namespace Terminal.Gui;
 /// var secondStep = new WizardStep ("Second Step");
 /// wizard.AddStep(secondStep);
 /// secondStep.HelpText = "This is the help text for the Second Step.";
-/// var lbl = new Label () { Text = "Name:",  AutoSize = true };
+/// var lbl = new Label () { Text = "Name:" };
 /// secondStep.Add(lbl);
 /// 
 /// var name = new TextField { X = Pos.Right (lbl) + 1, Width = Dim.Fill () - 1 };

+ 0 - 21
UICatalog/Scenarios/DimAutoDemo.cs

@@ -154,27 +154,6 @@ public class DimAutoDemo : Scenario
 
             //Height = Dim.Auto (min: Dim.Percent (50))
         };
-
-        //var ok = new Button ("Bye") { IsDefault = true };
-        //ok.Clicked += (s, _) => Application.RequestStop (dlg);
-        //dlg.AddButton (ok);
-
-        //var cancel = new Button ("Abort") { };
-        //cancel.Clicked += (s, _) => Application.RequestStop (dlg);
-        //dlg.AddButton (cancel);
-
-        //var label = new Label
-        //{
-        //    ValidatePosDim = true,
-        //    Text = "This is a label (AutoSize = false; Dim.Auto(3/20). Press Esc to close. Even more text.",
-        //    
-        //    X = Pos.Center (),
-        //    Y = 0,
-        //    Height = Auto (min: 3),
-        //    Width = Auto (min: 20),
-        //    ColorScheme = Colors.ColorSchemes ["Menu"]
-        //};
-
         var text = new TextField
         {
             ValidatePosDim = true,

+ 0 - 213
UnitTests/Views/ButtonTests.cs

@@ -32,219 +32,6 @@ public class ButtonTests (ITestOutputHelper output)
         view.Dispose ();
     }
 
-//    // BUGBUG: This test is NOT a unit test and needs to be broken apart into 
-//    //         more specific tests (e.g. it tests Checkbox as well as Button)
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_False_With_Fixed_Width ()
-//    {
-//        var tab = new View ();
-
-//        var lblWidth = 8;
-
-//        var view = new View
-//        {
-//            Y = 1,
-//            Width = lblWidth,
-//            Height = 1,
-//            TextAlignment = TextAlignment.Right,
-//            Text = "Find:"
-//        };
-//        tab.Add (view);
-
-//        var txtToFind = new TextField
-//        {
-//            X = Pos.Right (view) + 1, Y = Pos.Top (view), Width = 20, Text = "Testing buttons."
-//        };
-//        tab.Add (txtToFind);
-
-//        var btnFindNext = new Button
-//        {
-//            X = Pos.Right (txtToFind) + 1,
-//            Y = Pos.Top (view),
-//            Width = 20,
-//            Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-//            TextAlignment = TextAlignment.Centered,
-//            IsDefault = true,
-//            Text = "Find _Next"
-//        };
-//        tab.Add (btnFindNext);
-
-//        var btnFindPrevious = new Button
-//        {
-//            X = Pos.Right (txtToFind) + 1,
-//            Y = Pos.Top (btnFindNext) + 1,
-//            Width = 20,
-//            Enabled = !string.IsNullOrEmpty (txtToFind.Text),
-//            TextAlignment = TextAlignment.Centered,
-//            Text = "Find _Previous"
-//        };
-//        tab.Add (btnFindPrevious);
-
-//        var btnCancel = new Button
-//        {
-//            X = Pos.Right (txtToFind) + 1,
-//            Y = Pos.Top (btnFindPrevious) + 2,
-//            Width = 20,
-//            TextAlignment = TextAlignment.Centered,
-//            Text = "Cancel"
-//        };
-//        tab.Add (btnCancel);
-
-//        var ckbMatchCase = new CheckBox
-//        {
-//            X = 0,
-//            Y = Pos.Top (txtToFind) + 2,
-//            Checked = true, Text = "Match c_ase"
-//        };
-//        tab.Add (ckbMatchCase);
-//        Assert.Equal (new (0, 3, 10, 1), ckbMatchCase.Frame);
-
-//        var ckbMatchWholeWord = new CheckBox
-//        {
-//            X = 0,
-//            Y = Pos.Top (ckbMatchCase) + 1,
-//            Checked = false,
-//            Text = "Match _whole word"
-//        };
-//        tab.Add (ckbMatchWholeWord);
-
-//        var tabView = new TabView { Width = Dim.Fill (), Height = Dim.Fill () };
-//        tabView.AddTab (new () { DisplayText = "Find", View = tab }, true);
-
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
-
-//        tab.Width = view.Width + txtToFind.Width + btnFindNext.Width + 2;
-//        tab.Height = btnFindNext.Height + btnFindPrevious.Height + btnCancel.Height + 4;
-
-//        win.Add (tabView);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-//        Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (54, 11);
-
-//        Assert.Equal (new (0, 3, 10, 1), ckbMatchCase.Frame);
-
-//        Assert.Equal (new (0, 0, 54, 11), win.Frame);
-//        Assert.Equal (new (0, 0, 52, 9), tabView.Frame);
-//        Assert.Equal (new (0, 0, 50, 7), tab.Frame);
-//        Assert.Equal (new (0, 1, 8, 1), view.Frame);
-//        Assert.Equal (new (9, 1, 20, 1), txtToFind.Frame);
-
-//        Assert.Equal (0, txtToFind.ScrollOffset);
-//        Assert.Equal (16, txtToFind.CursorPosition);
-
-//        Assert.Equal (new (30, 1, 20, 1), btnFindNext.Frame);
-//        Assert.Equal (new (30, 2, 20, 1), btnFindPrevious.Frame);
-//        Assert.Equal (new (30, 4, 20, 1), btnCancel.Frame);
-
-//        //        Assert.Equal (new (0, 3, 12, 1), ckbMatchCase.Frame);
-//        //        Assert.Equal (new (0, 4, 18, 1), ckbMatchWholeWord.Frame);
-
-//        var btn1 =
-//            $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Find Next {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
-//        var btn2 = $"{CM.Glyphs.LeftBracket} Find Previous {CM.Glyphs.RightBracket}";
-//        var btn3 = $"{CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket}";
-
-//        var expected = @$"
-//┌────────────────────────────────────────────────────┐
-//│╭────╮                                              │
-//││Find│                                              │
-//││    ╰─────────────────────────────────────────────╮│
-//││                                                  ││
-//││   Find: Testing buttons.       {btn1}   ││
-//││                               {btn2}  ││
-//││{CM.Glyphs.Checked} Match case                                      ││
-//││{CM.Glyphs.UnChecked} Match whole word                 {btn3}     ││
-//│└──────────────────────────────────────────────────┘│
-//└────────────────────────────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-//        view.Dispose ();
-//    }
-
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_Stays_True_AnchorEnd ()
-//    {
-//        var btn = new Button { Y = Pos.Center (), Text = "Say Hello 你", AutoSize = true };
-//        var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
-
-//        btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
-//        btn.X = Pos.AnchorEnd (0) - Pos.Function (() => btn.TextFormatter.Text.GetColumns ());
-
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
-//        win.Add (btn);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-//        Assert.True (btn.AutoSize);
-
-//        Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
-
-//        var expected = @$"
-//┌────────────────────────────┐
-//│                            │
-//│            {btnTxt}│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-
-//        Assert.True (btn.AutoSize);
-//        btn.Text = "Say Hello 你 changed";
-//        btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
-//        Assert.True (btn.AutoSize);
-//        Application.Refresh ();
-
-//        expected = @$"
-//┌────────────────────────────┐
-//│                            │
-//│    {btnTxt}│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-//        top.Dispose ();
-//    }
-
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_Stays_True_With_EmptyText ()
-//    {
-//        var btn = new Button { X = Pos.Center (), Y = Pos.Center (), AutoSize = true };
-
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
-//        win.Add (btn);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-//        Assert.True (btn.AutoSize);
-
-//        btn.Text = "Say Hello 你";
-
-//        Assert.True (btn.AutoSize);
-
-//        Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
-
-//        var expected = @$"
-//┌────────────────────────────┐
-//│                            │
-//│      {CM.Glyphs.LeftBracket} Say Hello 你 {CM.Glyphs.RightBracket}      │
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-//        top.Dispose ();
-//    }
-
     [Theory]
     [InlineData ("01234", 0, 0, 0, 0)]
     [InlineData ("01234", 1, 0, 1, 0)]

+ 0 - 166
UnitTests/Views/CheckBoxTests.cs

@@ -132,172 +132,6 @@ public class CheckBoxTests
         Assert.False (checkBox.Checked);
     }
 
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier ()
-//    {
-//        var checkBox = new CheckBox { Y = Pos.Center (), Text = "C_heck this out 你" };
-
-//        checkBox.X = Pos.AnchorEnd (0) - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
-
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
-//        win.Add (checkBox);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-//        //Assert.True (checkBox.AutoSize);
-
-//        Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
-
-//        var expected = @$"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│         {CM.Glyphs.UnChecked} Check this out 你│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-
-//        //Assert.True (checkBox.AutoSize);
-//        checkBox.Text = "Check this out 你 changed";
-////        Assert.True (checkBox.AutoSize);
-//        Application.Refresh ();
-
-//        expected = @$"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│ {CM.Glyphs.UnChecked} Check this out 你 changed│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-//    }
-
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier ()
-//    {
-//        var checkBox = new CheckBox { Y = Pos.Center (), Text = "Check this out 你" };
-
-//        checkBox.X = Pos.AnchorEnd (0) - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
-
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
-//        win.Add (checkBox);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-////        Assert.True (checkBox.AutoSize);
-
-//        Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
-
-//        var expected = @$"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│         {CM.Glyphs.UnChecked} Check this out 你│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-
-// //       Assert.True (checkBox.AutoSize);
-//        checkBox.Text = "Check this out 你 changed";
-////        Assert.True (checkBox.AutoSize);
-//        Application.Refresh ();
-
-//        expected = @$"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│ {CM.Glyphs.UnChecked} Check this out 你 changed│
-//│                            │
-//└────────────────────────────┘
-//";
-
-//        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-//    }
-
-//    [Fact]
-//    [AutoInitShutdown]
-//    public void AutoSize_StaysVisible ()
-//    {
-//        var checkBox = new CheckBox { X = 1, Y = Pos.Center (), Text = "Check this out 你" };
-//        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
-//        win.Add (checkBox);
-//        var top = new Toplevel ();
-//        top.Add (win);
-
-//        Assert.False (checkBox.IsInitialized);
-
-//        RunState runstate = Application.Begin (top);
-//        ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
-
-//        Assert.True (checkBox.IsInitialized);
-//        Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
-//        Assert.Equal ("Check this out 你", checkBox.Text);
-//        Assert.Equal ($"{CM.Glyphs.UnChecked} Check this out 你", checkBox.TextFormatter.Text);
-//        Assert.True (checkBox.AutoSize);
-//        Assert.Equal (19, checkBox.Frame.Width);
-
-//        checkBox.Checked = true;
-//        Assert.Equal ($"{CM.Glyphs.Checked} Check this out 你", checkBox.TextFormatter.Text);
-
-//        checkBox.AutoSize = false;
-
-//        // It isn't auto-size so the height is guaranteed by the SetMinWidthHeight
-//        checkBox.Text = "Check this out 你 changed";
-//        var firstIteration = false;
-//        Application.RunIteration (ref runstate, ref firstIteration);
-
-//        // BUGBUG - v2 - Autosize is busted; disabling tests for now
-//        Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
-
-//        var expected = @"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│ ☑ Check this out 你        │
-//│                            │
-//└────────────────────────────┘";
-
-//        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-//        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
-
-//        checkBox.Width = 19;
-
-//        // It isn't auto-size so the height is guaranteed by the SetMinWidthHeight
-//        checkBox.Text = "Check this out 你 changed";
-//        Application.RunIteration (ref runstate, ref firstIteration);
-//        Assert.False (checkBox.AutoSize);
-//        Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
-
-//        expected = @"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│ ☑ Check this out 你        │
-//│                            │
-//└────────────────────────────┘";
-
-//        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-//        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
-
-//        checkBox.AutoSize = true;
-//        Application.RunIteration (ref runstate, ref firstIteration);
-//        Assert.Equal (new Rectangle (1, 1, 27, 1), checkBox.Frame);
-
-//        expected = @"
-//┌┤Test Demo 你├──────────────┐
-//│                            │
-//│ ☑ Check this out 你 changed│
-//│                            │
-//└────────────────────────────┘";
-
-//        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-//        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
-//    }
-
     [Fact]
     public void Constructors_Defaults ()
     {

+ 0 - 1
UnitTests/Views/GraphViewTests.cs

@@ -1521,7 +1521,6 @@ public class PathAnnotationTests
             mount.Add (view);
 
             //putting mount into Toplevel since changing size
-            //also change AutoSize to false
             top.Add (mount);
             Application.Begin (top);
 

+ 0 - 3
UnitTests/Views/LabelTests.cs

@@ -141,8 +141,6 @@ public class LabelTests
         var top = new Toplevel ();
         top.Add (win);
 
-        //Assert.True (label.AutoSize);
-
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
@@ -209,7 +207,6 @@ public class LabelTests
         var label = new Label ();
         Assert.Equal (string.Empty, label.Text);
         Assert.Equal (TextAlignment.Left, label.TextAlignment);
-        //Assert.True (label.AutoSize);
         Assert.False (label.CanFocus);
         Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
         Assert.Equal (KeyCode.Null, label.HotKey);

+ 0 - 1
UnitTests/Views/ScrollViewTests.cs

@@ -1080,7 +1080,6 @@ public class ScrollViewTests
             Width = width;
             Height = height;
 
-            //labelFill = new Label { AutoSize = false, X = Pos.Center (), Y = Pos.Center (), Width = Dim.Fill (), Height = Dim.Fill (), Visible = false };
             labelFill = new Label { Width = Dim.Fill (), Height = Dim.Fill (), Visible = false };
 
             labelFill.LayoutComplete += (s, e) =>