@@ -15,26 +15,27 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
15
15
// to make the same mistakes our users make when they poke at the Subviews.
16
16
internal IList < View > InternalSubviews => _subviews ?? _empty ;
17
17
18
- /// <summary>This returns a list of the subviews contained by this view.</summary>
19
- /// <value>The subviews.</value>
18
+ /// <summary>Gets the list of Subviews.</summary>
19
+ /// <remarks>
20
+ /// Use <see cref="Add(Terminal.Gui.View?)"/> and <see cref="Remove(Terminal.Gui.View?)"/> to add or remove subviews.
21
+ /// </remarks>
20
22
public IList < View > Subviews => _subviews ? . AsReadOnly ( ) ?? _empty ;
21
23
22
24
private View ? _superView ;
23
25
24
- /// <summary>Returns the container for this view, or null if this view has not been added to a container.</summary>
25
- /// <value>The super view.</value>
26
- public virtual View ? SuperView
26
+ /// <summary>Gets this Views SuperView (the View's container), or <see langword="null"/> if this view has not been added as a Subview.</summary>
27
+ public View ? SuperView
27
28
{
28
29
get => _superView ! ;
29
- set => throw new NotImplementedException ( ) ;
30
+ set => throw new InvalidOperationException ( @"SuperView cannot be set." ) ;
30
31
}
31
32
32
33
#region AddRemove
33
34
34
35
/// <summary>Indicates whether the view was added to <see cref="SuperView"/>.</summary>
35
36
public bool IsAdded { get ; private set ; }
36
37
37
- /// <summary>Adds a subview (child) to this view.</summary>
38
+ /// <summary>Adds a Subview (child) to this view.</summary>
38
39
/// <remarks>
39
40
/// <para>
40
41
/// The Views that have been added to this view can be retrieved via the <see cref="Subviews"/> property. See also
@@ -94,7 +95,7 @@ public virtual View? SuperView
94
95
return view ;
95
96
}
96
97
97
- /// <summary>Adds the specified views (children) to the view.</summary>
98
+ /// <summary>Adds the specified Subview (children) to the view.</summary>
98
99
/// <param name="views">Array of one or more views (can be optional parameter).</param>
99
100
/// <remarks>
100
101
/// <para>
@@ -119,28 +120,29 @@ public void Add (params View []? views)
119
120
}
120
121
}
121
122
122
- /// <summary>Event fired when this view is added to another.</summary>
123
+ // TODO: Make these events follow the standard pattern
124
+ /// <summary>Raised when a Subview has been added to this View.</summary>
123
125
public event EventHandler < SuperViewChangedEventArgs > ? Added ;
124
126
125
- /// <summary>Method invoked when a subview is being added to this view.</summary>
127
+ /// <summary>Method invoked when a Subview has been added to this view.</summary>
126
128
/// <param name="e">Event where <see cref="ViewEventArgs.View"/> is the subview being added.</param>
127
- public virtual void OnAdded ( SuperViewChangedEventArgs e )
129
+ protected virtual void OnAdded ( SuperViewChangedEventArgs e )
128
130
{
129
131
View view = e . SubView ;
130
132
view . IsAdded = true ;
131
133
view . Added ? . Invoke ( this , e ) ;
132
134
}
133
135
134
- /// <summary>Method invoked when a subview is being removed from this view.</summary>
136
+ /// <summary>Method invoked when a Subview is being removed from this view.</summary>
135
137
/// <param name="e">Event args describing the subview being removed.</param>
136
- public virtual void OnRemoved ( SuperViewChangedEventArgs e )
138
+ protected virtual void OnRemoved ( SuperViewChangedEventArgs e )
137
139
{
138
140
View view = e . SubView ;
139
141
view . IsAdded = false ;
140
142
view . Removed ? . Invoke ( this , e ) ;
141
143
}
142
144
143
- /// <summary>Removes a subview added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.</summary>
145
+ /// <summary>Removes a Subview added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.</summary>
144
146
/// <remarks>
145
147
/// <para>
146
148
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
@@ -208,7 +210,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
208
210
}
209
211
210
212
/// <summary>
211
- /// Removes all subviews (children) added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.
213
+ /// Removes all Subview (children) added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.
212
214
/// </summary>
213
215
/// <remarks>
214
216
/// <para>
@@ -231,15 +233,15 @@ public virtual void RemoveAll ()
231
233
}
232
234
}
233
235
234
- /// <summary>Event fired when this view is removed from another .</summary>
236
+ /// <summary>Raised when a Subview has been removed from this View .</summary>
235
237
public event EventHandler < SuperViewChangedEventArgs > ? Removed ;
236
238
237
239
#endregion AddRemove
238
240
239
- // TODO: Mark as internal. Or nuke .
241
+ // TODO: This drives a weird coupling of Application.Top and View. It's not clear why this is needed .
240
242
/// <summary>Get the top superview of a given <see cref="View"/>.</summary>
241
243
/// <returns>The superview view.</returns>
242
- public View ? GetTopSuperView ( View ? view = null , View ? superview = null )
244
+ internal View ? GetTopSuperView ( View ? view = null , View ? superview = null )
243
245
{
244
246
View ? top = superview ?? Application . Top ;
245
247
@@ -275,7 +277,7 @@ public static bool IsInHierarchy (View? start, View? view, bool includeAdornment
275
277
return true ;
276
278
}
277
279
278
- foreach ( View subView in start . Subviews )
280
+ foreach ( View subView in start . InternalSubviews )
279
281
{
280
282
if ( view == subView )
281
283
{
0 commit comments