|
@@ -2435,7 +2435,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
if (edges.Any ()) {
|
|
if (edges.Any ()) {
|
|
(var from, var to) = edges.First ();
|
|
(var from, var to) = edges.First ();
|
|
- if (from != superView && from != Application.Top) {
|
|
|
|
|
|
+ if (from != superView?.GetTopSuperView (to, from)) {
|
|
if (!ReferenceEquals (from, to)) {
|
|
if (!ReferenceEquals (from, to)) {
|
|
throw new InvalidOperationException ($"TopologicalSort (for Pos/Dim) cannot find {from} linked with {to}. Did you forget to add it to {superView}?");
|
|
throw new InvalidOperationException ($"TopologicalSort (for Pos/Dim) cannot find {from} linked with {to}. Did you forget to add it to {superView}?");
|
|
} else {
|
|
} else {
|
|
@@ -2472,20 +2472,16 @@ namespace Terminal.Gui {
|
|
CollectAll (this, ref nodes, ref edges);
|
|
CollectAll (this, ref nodes, ref edges);
|
|
var ordered = View.TopologicalSort (SuperView, nodes, edges);
|
|
var ordered = View.TopologicalSort (SuperView, nodes, edges);
|
|
foreach (var v in ordered) {
|
|
foreach (var v in ordered) {
|
|
- if (v.LayoutStyle == LayoutStyle.Computed) {
|
|
|
|
- v.SetRelativeLayout (Frame);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- v.LayoutSubviews ();
|
|
|
|
- v.LayoutNeeded = false;
|
|
|
|
|
|
+ LayoutSubview (v, Frame);
|
|
}
|
|
}
|
|
|
|
|
|
- // If our SuperView is Application.Top and the layoutstyle is Computed it's a special-cass.
|
|
|
|
- // Use SetRelativeaLayout with the Frame of the Application.Top
|
|
|
|
- if (SuperView != null && SuperView == Application.Top && LayoutNeeded
|
|
|
|
- && ordered.Count == 0 && LayoutStyle == LayoutStyle.Computed) {
|
|
|
|
- Debug.Assert (Application.Top.Frame.Location == Point.Empty);
|
|
|
|
- SetRelativeLayout (Application.Top.Frame);
|
|
|
|
|
|
+ // If the 'to' is rooted to 'from' and the layoutstyle is Computed it's a special-case.
|
|
|
|
+ // Use LayoutSubview with the Frame of the 'from'
|
|
|
|
+ if (SuperView != null && GetTopSuperView () != null && LayoutNeeded
|
|
|
|
+ && ordered.Count == 0 && edges.Count > 0 && LayoutStyle == LayoutStyle.Computed) {
|
|
|
|
+
|
|
|
|
+ (var from, var to) = edges.First ();
|
|
|
|
+ LayoutSubview (to, from.Frame);
|
|
}
|
|
}
|
|
|
|
|
|
LayoutNeeded = false;
|
|
LayoutNeeded = false;
|
|
@@ -2493,6 +2489,16 @@ namespace Terminal.Gui {
|
|
OnLayoutComplete (new LayoutEventArgs () { OldBounds = oldBounds });
|
|
OnLayoutComplete (new LayoutEventArgs () { OldBounds = oldBounds });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void LayoutSubview (View v, Rect hostFrame)
|
|
|
|
+ {
|
|
|
|
+ if (v.LayoutStyle == LayoutStyle.Computed) {
|
|
|
|
+ v.SetRelativeLayout (hostFrame);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ v.LayoutSubviews ();
|
|
|
|
+ v.LayoutNeeded = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
ustring text;
|
|
ustring text;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -3162,11 +3168,14 @@ namespace Terminal.Gui {
|
|
/// Get the top superview of a given <see cref="View"/>.
|
|
/// Get the top superview of a given <see cref="View"/>.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>The superview view.</returns>
|
|
/// <returns>The superview view.</returns>
|
|
- public View GetTopSuperView ()
|
|
|
|
|
|
+ public View GetTopSuperView (View view = null, View superview = null)
|
|
{
|
|
{
|
|
- View top = Application.Top;
|
|
|
|
- for (var v = this?.SuperView; v != null; v = v.SuperView) {
|
|
|
|
|
|
+ View top = superview ?? Application.Top;
|
|
|
|
+ for (var v = view?.SuperView ?? (this?.SuperView); v != null; v = v.SuperView) {
|
|
top = v;
|
|
top = v;
|
|
|
|
+ if (top == superview) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return top;
|
|
return top;
|