Browse Source

More Toplevel cleanup

Tig 10 months ago
parent
commit
e2f671ce4e
2 changed files with 1 additions and 109 deletions
  1. 1 85
      Terminal.Gui/Views/Toplevel.cs
  2. 0 24
      UnitTests/Views/ToplevelTests.cs

+ 1 - 85
Terminal.Gui/Views/Toplevel.cs

@@ -76,29 +76,6 @@ public partial class Toplevel : View
     /// <summary>Gets the latest <see cref="StatusBar"/> added into this Toplevel.</summary>
     /// <summary>Gets the latest <see cref="StatusBar"/> added into this Toplevel.</summary>
     public StatusBar? StatusBar => (StatusBar?)Subviews?.LastOrDefault (s => s is StatusBar);
     public StatusBar? StatusBar => (StatusBar?)Subviews?.LastOrDefault (s => s is StatusBar);
 
 
-
-    // TODO: Overlapped - Rename to AllSubviewsClosed - Move to View?
-    /// <summary>
-    ///     Invoked when the last child of the Toplevel <see cref="RunState"/> is closed from by
-    ///     <see cref="Application.End(RunState)"/>.
-    /// </summary>
-    public event EventHandler? AllChildClosed;
-
-    // TODO: Overlapped - Rename to *Subviews* - Move to View?
-    /// <summary>
-    ///     Invoked when a child of the Toplevel <see cref="RunState"/> is closed by
-    ///     <see cref="Application.End(RunState)"/>.
-    /// </summary>
-    public event EventHandler<ToplevelEventArgs>? ChildClosed;
-
-    // TODO: Overlapped - Rename to *Subviews* - Move to View?
-    /// <summary>Invoked when a child Toplevel's <see cref="RunState"/> has been loaded.</summary>
-    public event EventHandler<ToplevelEventArgs>? ChildLoaded;
-
-    // TODO: Overlapped - Rename to *Subviews* - Move to View?
-    /// <summary>Invoked when a cjhild Toplevel's <see cref="RunState"/> has been unloaded.</summary>
-    public event EventHandler<ToplevelEventArgs>? ChildUnloaded;
-
     #endregion
     #endregion
 
 
     #region Life Cycle
     #region Life Cycle
@@ -186,23 +163,6 @@ public partial class Toplevel : View
 
 
     internal virtual void OnActivate (Toplevel deactivated) { Activate?.Invoke (this, new (deactivated)); }
     internal virtual void OnActivate (Toplevel deactivated) { Activate?.Invoke (this, new (deactivated)); }
 
 
-    /// <summary>
-    ///     Stops and closes the <see cref="Toplevel"/> specified by <paramref name="top"/>. If <paramref name="top"/> is
-    ///     the top-most Toplevel, <see cref="Application.RequestStop(Toplevel)"/> will be called, causing the application to
-    ///     exit.
-    /// </summary>
-    /// <param name="top">The Toplevel to request stop.</param>
-    //public virtual void RequestStop (Toplevel top) { top.RequestStop (); }
-
-    internal virtual void OnAllChildClosed () { AllChildClosed?.Invoke (this, EventArgs.Empty); }
-
-    internal virtual void OnChildClosed (Toplevel top)
-    {
-        ChildClosed?.Invoke (this, new (top));
-    }
-
-    internal virtual void OnChildLoaded (Toplevel top) { ChildLoaded?.Invoke (this, new (top)); }
-    internal virtual void OnChildUnloaded (Toplevel top) { ChildUnloaded?.Invoke (this, new (top)); }
     internal virtual void OnClosed (Toplevel top) { Closed?.Invoke (this, new (top)); }
     internal virtual void OnClosed (Toplevel top) { Closed?.Invoke (this, new (top)); }
 
 
     internal virtual bool OnClosing (ToplevelClosingEventArgs ev)
     internal virtual bool OnClosing (ToplevelClosingEventArgs ev)
@@ -242,41 +202,7 @@ public partial class Toplevel : View
     }
     }
 
 
     #endregion
     #endregion
-
-    #region Draw
-
-    ///// <inheritdoc/>
-    //public override void OnDrawContent (Rectangle viewport)
-    //{
-    //    if (!Visible)
-    //    {
-    //        return;
-    //    }
-
-    //    if (NeedsDisplay || SubViewNeedsDisplay /*|| LayoutNeeded*/)
-    //    {
-    //        Clear ();
-
-    //        //LayoutSubviews ();
-    //        //PositionToplevels ();
-            
-    //        // BUGBUG: This appears to be a hack to get ScrollBarViews to render correctly.
-    //        foreach (View view in Subviews)
-    //        {
-    //            if (view.Frame.IntersectsWith (Viewport) && !OutsideTopFrame (this))
-    //            {
-    //                //view.SetNeedsLayout ();
-    //                view.SetNeedsDisplay ();
-    //                view.SetSubViewNeedsDisplay ();
-    //            }
-    //        }
-
-    //        base.OnDrawContent (viewport);
-    //    }
-    //}
-
-    #endregion
-
+    
     #region Size / Position Management
     #region Size / Position Management
 
 
     // TODO: Make cancelable?
     // TODO: Make cancelable?
@@ -359,16 +285,6 @@ public partial class Toplevel : View
     /// <summary>Invoked when the terminal has been resized. The new <see cref="Size"/> of the terminal is provided.</summary>
     /// <summary>Invoked when the terminal has been resized. The new <see cref="Size"/> of the terminal is provided.</summary>
     public event EventHandler<SizeChangedEventArgs>? SizeChanging;
     public event EventHandler<SizeChangedEventArgs>? SizeChanging;
 
 
-    private bool OutsideTopFrame (Toplevel top)
-    {
-        if (top.Frame.X > Driver.Cols || top.Frame.Y > Driver.Rows)
-        {
-            return true;
-        }
-
-        return false;
-    }
-
     #endregion
     #endregion
 }
 }
 
 

+ 0 - 24
UnitTests/Views/ToplevelTests.cs

@@ -33,30 +33,6 @@ public partial class ToplevelTests (ITestOutputHelper output)
 
 
         var eventInvoked = "";
         var eventInvoked = "";
 
 
-        top.ChildUnloaded += (s, e) => eventInvoked = "ChildUnloaded";
-        top.OnChildUnloaded (top);
-        Assert.Equal ("ChildUnloaded", eventInvoked);
-        top.ChildLoaded += (s, e) => eventInvoked = "ChildLoaded";
-        top.OnChildLoaded (top);
-        Assert.Equal ("ChildLoaded", eventInvoked);
-        top.Closed += (s, e) => eventInvoked = "Closed";
-        top.OnClosed (top);
-        Assert.Equal ("Closed", eventInvoked);
-        top.Closing += (s, e) => eventInvoked = "Closing";
-        top.OnClosing (new (top));
-        Assert.Equal ("Closing", eventInvoked);
-        top.AllChildClosed += (s, e) => eventInvoked = "AllChildClosed";
-        top.OnAllChildClosed ();
-        Assert.Equal ("AllChildClosed", eventInvoked);
-        top.ChildClosed += (s, e) => eventInvoked = "ChildClosed";
-        top.OnChildClosed (top);
-        Assert.Equal ("ChildClosed", eventInvoked);
-        top.Deactivate += (s, e) => eventInvoked = "Deactivate";
-        top.OnDeactivate (top);
-        Assert.Equal ("Deactivate", eventInvoked);
-        top.Activate += (s, e) => eventInvoked = "Activate";
-        top.OnActivate (top);
-        Assert.Equal ("Activate", eventInvoked);
         top.Loaded += (s, e) => eventInvoked = "Loaded";
         top.Loaded += (s, e) => eventInvoked = "Loaded";
         top.OnLoaded ();
         top.OnLoaded ();
         Assert.Equal ("Loaded", eventInvoked);
         Assert.Equal ("Loaded", eventInvoked);