Removed TopLevel.Create

This commit is contained in:
Tig Kindel
2024-01-07 14:20:01 -07:00
parent 98024dc7f7
commit fe4b60a0b0
5 changed files with 7 additions and 15 deletions

View File

@@ -109,7 +109,7 @@ public static partial class Application {
/// </para>
/// <param name="driver">The <see cref="ConsoleDriver"/> to use. If neither <paramref name="driver"/> or <paramref name="driverName"/> are specified the default driver for the platform will be used.</param>
/// <param name="driverName">The short name (e.g. "net", "windows", "ansi", "fake", or "curses") of the <see cref="ConsoleDriver"/> to use. If neither <paramref name="driver"/> or <paramref name="driverName"/> are specified the default driver for the platform will be used.</param>
public static void Init (ConsoleDriver driver = null, string driverName = null) => InternalInit (Toplevel.Create, driver, driverName);
public static void Init (ConsoleDriver driver = null, string driverName = null) => InternalInit (() => new Toplevel(), driver, driverName);
internal static bool _initialized = false;
internal static int _mainThreadId = -1;
@@ -194,6 +194,10 @@ public static partial class Application {
Top = topLevelFactory ();
Current = Top;
// Ensure Top's layout is up to date.
Current.SetRelativeLayout (new Rect (0, 0, Driver.Cols, Driver.Rows));
_cachedSupportedCultures = GetSupportedCultures ();
_mainThreadId = Thread.CurrentThread.ManagedThreadId;
_initialized = true;

View File

@@ -52,16 +52,6 @@ public partial class Toplevel : View {
Height = Dim.Fill ();
}
/// <summary>
/// Convenience factory method that creates a new Toplevel.
/// </summary>
/// <remarks>
/// The <see cref="View.Width"/> and <see cref="View.Height"/> properties
/// will be set to the dimensions of the terminal using <see cref="Dim.Fill"/>.
/// </remarks>
/// <returns>The created Toplevel.</returns>
public static Toplevel Create () => new (); // BUGBUG: Should be ComputedLayout
/// <summary>
/// Gets or sets whether the main loop for this <see cref="Toplevel"/> is running or not.
/// </summary>

View File

@@ -570,8 +570,6 @@ public class ApplicationTests {
public void Begin_Sets_Application_Top_To_Console_Size ()
{
Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame);
((FakeDriver)Application.Driver).SetBufferSize (5, 5);
Application.Begin (Application.Top);
Assert.Equal (new Rect (0, 0, 80, 25), Application.Top.Frame);
((FakeDriver)Application.Driver).SetBufferSize (5, 5);

View File

@@ -1001,7 +1001,7 @@ namespace Terminal.Gui.ViewTests {
{
// Arrange
Application.Init ();
using var top = Toplevel.Create ();
using var top = new Toplevel ();
using var view = new View (
x: 0,
y: 1,

View File

@@ -36,7 +36,7 @@ public class ToplevelTests {
[AutoInitShutdown]
public void Create_Toplevel ()
{
var top = Toplevel.Create ();
var top = new Toplevel ();
Assert.Equal (Colors.TopLevel, top.ColorScheme);
Assert.Equal ("Fill(0)", top.Width.ToString ());