Browse Source

Fix merge errors.

BDisp 11 months ago
parent
commit
9b4269e9ae

+ 13 - 11
Terminal.Gui/View/SuperViewChangedEventArgs.cs

@@ -1,26 +1,28 @@
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
 /// <summary>
 /// <summary>
-///     EventArgs for events where the state of the <see cref="View.SuperView"/> of a <see cref="View"/> is changing (e.g.
+///     Args for events where the <see cref="View.SuperView"/> of a <see cref="View"/> is changed (e.g.
 ///     <see cref="View.Removed"/> / <see cref="View.Added"/> events).
 ///     <see cref="View.Removed"/> / <see cref="View.Added"/> events).
 /// </summary>
 /// </summary>
 public class SuperViewChangedEventArgs : EventArgs
 public class SuperViewChangedEventArgs : EventArgs
 {
 {
     /// <summary>Creates a new instance of the <see cref="SuperViewChangedEventArgs"/> class.</summary>
     /// <summary>Creates a new instance of the <see cref="SuperViewChangedEventArgs"/> class.</summary>
-    /// <param name="superView"></param>
-    /// <param name="subView"></param>
-    public SuperViewChangedEventArgs (View superView, View subView)
+    /// <param name="parent"></param>
+    /// <param name="child"></param>
+    public SuperViewChangedEventArgs (View parent, View child)
     {
     {
-        SuperView = superView;
-        SubView = subView;
+        Parent = parent;
+        Child = child;
     }
     }
 
 
-    /// <summary>The SubView that is either being added or removed from <see cref="Parent"/>.</summary>
-    public View SubView { get; }
+    // TODO: Child is the wrong name. It should be View.
+    /// <summary>The view that is having it's <see cref="View.SuperView"/> changed</summary>
+    public View Child { get; }
 
 
+    // TODO: Parent is the wrong name. It should be SuperView.
     /// <summary>
     /// <summary>
-    ///     The SuperView that is changing state. For <see cref="View.Removed"/> this is the SuperView <see cref="SubView"/> is being removed from. For
-    ///     <see cref="View.Added"/> it is the SuperView <see cref="SubView"/> is being added to.
+    ///     The parent.  For <see cref="View.Removed"/> this is the old parent (new parent now being null).  For
+    ///     <see cref="View.Added"/> it is the new parent to whom view now belongs.
     /// </summary>
     /// </summary>
-    public View SuperView { get; }
+    public View Parent { get; }
 }
 }

+ 6 - 4
Terminal.Gui/Views/Scroll.cs

@@ -1,4 +1,6 @@
-using System.ComponentModel;
+#nullable enable
+
+using System.ComponentModel;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
@@ -206,7 +208,7 @@ public class Scroll : View
 
 
     private void Scroll_Added (object sender, SuperViewChangedEventArgs e)
     private void Scroll_Added (object sender, SuperViewChangedEventArgs e)
     {
     {
-        View parent = e.SuperView is Adornment adornment ? adornment.Parent : e.SuperView;
+        View parent = e.Parent is Adornment adornment ? adornment.Parent : e.Parent;
 
 
         parent.LayoutComplete += SuperView_LayoutComplete;
         parent.LayoutComplete += SuperView_LayoutComplete;
     }
     }
@@ -274,9 +276,9 @@ public class Scroll : View
 
 
     private void Scroll_Removed (object sender, SuperViewChangedEventArgs e)
     private void Scroll_Removed (object sender, SuperViewChangedEventArgs e)
     {
     {
-        if (e.SuperView is { })
+        if (e.Parent is { })
         {
         {
-            View parent = e.SuperView is Adornment adornment ? adornment.Parent : e.SuperView;
+            View parent = e.Parent is Adornment adornment ? adornment.Parent : e.Parent;
 
 
             parent.LayoutComplete -= SuperView_LayoutComplete;
             parent.LayoutComplete -= SuperView_LayoutComplete;
         }
         }

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

@@ -40,7 +40,7 @@ public class ScrollBarView : View
         WantContinuousButtonPressed = true;
         WantContinuousButtonPressed = true;
         ClearOnVisibleFalse = false;
         ClearOnVisibleFalse = false;
 
 
-        Added += (s, e) => CreateBottomRightCorner (e.SuperView);
+        Added += (s, e) => CreateBottomRightCorner (e.Parent);
         Initialized += ScrollBarView_Initialized;
         Initialized += ScrollBarView_Initialized;
     }
     }
 
 

+ 1 - 1
UICatalog/KeyBindingsDialog.cs

@@ -209,7 +209,7 @@ internal class KeyBindingsDialog : Dialog
             // (and always was wrong). Parents don't get to be told when new views are added
             // (and always was wrong). Parents don't get to be told when new views are added
             // to them
             // to them
 
 
-            view.Added += (s, e) => RecordView (e.SubView);
+            view.Added += (s, e) => RecordView (e.Child);
         }
         }
     }
     }
 }
 }

+ 3 - 3
UICatalog/Scenarios/ScrollDemo.cs

@@ -46,7 +46,7 @@ public class ScrollDemo : Scenario
         };
         };
         view.Add (lblWidthHeight);
         view.Add (lblWidthHeight);
 
 
-        Buttons.NumericUpDown<int> scrollWidthHeight = new ()
+        NumericUpDown<int> scrollWidthHeight = new ()
         {
         {
             Value = scroll.Frame.Width,
             Value = scroll.Frame.Width,
             X = Pos.Right (lblWidthHeight) + 1,
             X = Pos.Right (lblWidthHeight) + 1,
@@ -115,7 +115,7 @@ public class ScrollDemo : Scenario
         };
         };
         view.Add (lblSize);
         view.Add (lblSize);
 
 
-        Buttons.NumericUpDown<int> scrollSize = new ()
+        NumericUpDown<int> scrollSize = new ()
         {
         {
             Value = scroll.Size,
             Value = scroll.Size,
             X = Pos.Right (lblSize) + 1,
             X = Pos.Right (lblSize) + 1,
@@ -145,7 +145,7 @@ public class ScrollDemo : Scenario
         };
         };
         view.Add (lblPosition);
         view.Add (lblPosition);
 
 
-        Buttons.NumericUpDown<int> scrollPosition = new ()
+        NumericUpDown<int> scrollPosition = new ()
         {
         {
             Value = scroll.Position,
             Value = scroll.Position,
             X = Pos.Right (lblPosition) + 1,
             X = Pos.Right (lblPosition) + 1,

+ 13 - 13
UnitTests/View/SubviewTests.cs

@@ -17,15 +17,15 @@ public class SubviewTests
 
 
         v.Added += (s, e) =>
         v.Added += (s, e) =>
                    {
                    {
-                       Assert.Same (v.SuperView, e.SuperView);
-                       Assert.Same (t, e.SuperView);
-                       Assert.Same (v, e.SubView);
+                       Assert.Same (v.SuperView, e.Parent);
+                       Assert.Same (t, e.Parent);
+                       Assert.Same (v, e.Child);
                    };
                    };
 
 
         v.Removed += (s, e) =>
         v.Removed += (s, e) =>
                      {
                      {
-                         Assert.Same (t, e.SuperView);
-                         Assert.Same (v, e.SubView);
+                         Assert.Same (t, e.Parent);
+                         Assert.Same (v, e.Child);
                          Assert.True (v.SuperView == null);
                          Assert.True (v.SuperView == null);
                      };
                      };
 
 
@@ -108,26 +108,26 @@ public class SubviewTests
 
 
         winAddedToTop.Added += (s, e) =>
         winAddedToTop.Added += (s, e) =>
                                {
                                {
-                                   Assert.Equal (e.SuperView.Frame.Width, winAddedToTop.Frame.Width);
-                                   Assert.Equal (e.SuperView.Frame.Height, winAddedToTop.Frame.Height);
+                                   Assert.Equal (e.Parent.Frame.Width, winAddedToTop.Frame.Width);
+                                   Assert.Equal (e.Parent.Frame.Height, winAddedToTop.Frame.Height);
                                };
                                };
 
 
         v1AddedToWin.Added += (s, e) =>
         v1AddedToWin.Added += (s, e) =>
                               {
                               {
-                                  Assert.Equal (e.SuperView.Frame.Width, v1AddedToWin.Frame.Width);
-                                  Assert.Equal (e.SuperView.Frame.Height, v1AddedToWin.Frame.Height);
+                                  Assert.Equal (e.Parent.Frame.Width, v1AddedToWin.Frame.Width);
+                                  Assert.Equal (e.Parent.Frame.Height, v1AddedToWin.Frame.Height);
                               };
                               };
 
 
         v2AddedToWin.Added += (s, e) =>
         v2AddedToWin.Added += (s, e) =>
                               {
                               {
-                                  Assert.Equal (e.SuperView.Frame.Width, v2AddedToWin.Frame.Width);
-                                  Assert.Equal (e.SuperView.Frame.Height, v2AddedToWin.Frame.Height);
+                                  Assert.Equal (e.Parent.Frame.Width, v2AddedToWin.Frame.Width);
+                                  Assert.Equal (e.Parent.Frame.Height, v2AddedToWin.Frame.Height);
                               };
                               };
 
 
         svAddedTov1.Added += (s, e) =>
         svAddedTov1.Added += (s, e) =>
                              {
                              {
-                                 Assert.Equal (e.SuperView.Frame.Width, svAddedTov1.Frame.Width);
-                                 Assert.Equal (e.SuperView.Frame.Height, svAddedTov1.Frame.Height);
+                                 Assert.Equal (e.Parent.Frame.Width, svAddedTov1.Frame.Width);
+                                 Assert.Equal (e.Parent.Frame.Height, svAddedTov1.Frame.Height);
                              };
                              };
 
 
         top.Initialized += (s, e) =>
         top.Initialized += (s, e) =>