Fixed (again) SuperViewChangedEventArgs

This commit is contained in:
Tig
2024-08-29 16:16:06 -04:00
parent 13647bf104
commit d6651f6ecd
5 changed files with 24 additions and 26 deletions

View File

@@ -7,22 +7,20 @@
public class SuperViewChangedEventArgs : EventArgs
{
/// <summary>Creates a new instance of the <see cref="SuperViewChangedEventArgs"/> class.</summary>
/// <param name="parent"></param>
/// <param name="child"></param>
public SuperViewChangedEventArgs (View parent, View child)
/// <param name="superView"></param>
/// <param name="subView"></param>
public SuperViewChangedEventArgs (View superView, View subView)
{
Parent = parent;
Child = child;
SuperView = superView;
SubView = subView;
}
// 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; }
public View SubView { get; }
// TODO: Parent is the wrong name. It should be SuperView.
/// <summary>
/// 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>
public View Parent { get; }
public View SuperView { get; }
}

View File

@@ -122,7 +122,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
/// <param name="e">Event where <see cref="ViewEventArgs.View"/> is the subview being added.</param>
public virtual void OnAdded (SuperViewChangedEventArgs e)
{
View view = e.Child;
View view = e.SubView;
view.IsAdded = true;
view.OnResizeNeeded ();
view.Added?.Invoke (this, e);
@@ -132,7 +132,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
/// <param name="e">Event args describing the subview being removed.</param>
public virtual void OnRemoved (SuperViewChangedEventArgs e)
{
View view = e.Child;
View view = e.SubView;
view.IsAdded = false;
view.Removed?.Invoke (this, e);
}

View File

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

View File

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

View File

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