diff --git a/Terminal.Gui/Application/Application.Run.cs b/Terminal.Gui/Application/Application.Run.cs index c26804743..ee980a37f 100644 --- a/Terminal.Gui/Application/Application.Run.cs +++ b/Terminal.Gui/Application/Application.Run.cs @@ -514,7 +514,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) { if (clear) { - tl.SetNeedsDisplay(); + tl.SetNeedsDisplay(Screen); } tl.Draw (); } diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs index 6635f79c1..9099c406a 100644 --- a/Terminal.Gui/View/View.Drawing.cs +++ b/Terminal.Gui/View/View.Drawing.cs @@ -220,7 +220,7 @@ public partial class View // Drawing APIs if (IsLayoutNeeded ()) { - Debug.WriteLine ($"Layout should be de-coupled from drawing: {this}"); + //Debug.WriteLine ($"Layout should be de-coupled from drawing: {this}"); } //// TODO: This ensures overlapped views are drawn correctly. However, this is inefficient. @@ -573,7 +573,7 @@ public partial class View // Drawing APIs { if (view.IsLayoutNeeded ()) { - Debug.WriteLine ($"Layout should be de-coupled from drawing: {view}"); + //Debug.WriteLine ($"Layout should be de-coupled from drawing: {view}"); //view.LayoutSubviews (); } diff --git a/Terminal.Gui/View/View.Hierarchy.cs b/Terminal.Gui/View/View.Hierarchy.cs index 15bb745db..2334d2b12 100644 --- a/Terminal.Gui/View/View.Hierarchy.cs +++ b/Terminal.Gui/View/View.Hierarchy.cs @@ -85,15 +85,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView, view.EndInit (); } - SetLayoutNeeded(); - //CheckDimAuto (); - // view.SetRelativeLayout(Application.Screen.Size); - - //if (view.Visible) - //{ - // SetNeedsDisplay(); - //}; return view; } diff --git a/Terminal.Gui/View/View.Layout.cs b/Terminal.Gui/View/View.Layout.cs index d9108eaef..d143cf10b 100644 --- a/Terminal.Gui/View/View.Layout.cs +++ b/Terminal.Gui/View/View.Layout.cs @@ -657,7 +657,7 @@ public partial class View // Layout APIs SetTitleTextFormatterSize (); } - SetNeedsDisplay (); + //SetNeedsDisplay (); SuperView?.SetNeedsDisplay (); } @@ -821,6 +821,10 @@ public partial class View // Layout APIs if (!current.IsLayoutNeeded ()) { current._layoutNeeded = true; + current.Margin?.SetLayoutNeeded (); + current.Border?.SetLayoutNeeded (); + current.Padding?.SetLayoutNeeded (); + foreach (View subview in current.Subviews) { stack.Push (subview); diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs index 0aa1745a9..ef0ecbe21 100644 --- a/Terminal.Gui/View/View.cs +++ b/Terminal.Gui/View/View.cs @@ -229,6 +229,7 @@ public partial class View : Responder, ISupportInitializeNotification // These calls were moved from BeginInit as they access Viewport which is indeterminate until EndInit is called. UpdateTextDirection (TextDirection); UpdateTextFormatterText (); + SetLayoutNeeded (); if (_subviews is { }) @@ -242,6 +243,9 @@ public partial class View : Responder, ISupportInitializeNotification } } + // TOOD: Figure out how to move this out of here and just depend on IsLayoutNeeded in Mainloop + LayoutSubviews(); + Initialized?.Invoke (this, EventArgs.Empty); } diff --git a/Terminal.Gui/Views/Bar.cs b/Terminal.Gui/Views/Bar.cs index 21b483cba..be81134e2 100644 --- a/Terminal.Gui/Views/Bar.cs +++ b/Terminal.Gui/Views/Bar.cs @@ -82,7 +82,6 @@ public class Bar : View, IOrientation, IDesignable { base.EndInit (); ColorScheme = Colors.ColorSchemes ["Menu"]; - LayoutBarItems (GetContentSize ()); } /// @@ -121,7 +120,7 @@ public class Bar : View, IOrientation, IDesignable /// public void OnOrientationChanged (Orientation newOrientation) { - SetLayoutNeeded (); + LayoutBarItems (SuperView?.GetContentSize() ?? Application.Screen.Size); } #endregion diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index 026a18383..0392ee7a1 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -384,7 +384,6 @@ public class AllViewsTester : Scenario _curView = view; _hostPane.Add (_curView); - // Application.Refresh(); } private void DisposeCurrentView () @@ -558,12 +557,12 @@ public class AllViewsTester : Scenario return; } - if (!view.Width!.Has (out _) || (view.Width is null || view.Frame.Width == 0)) + if (!view.Width!.Has (out _) || (view.Width is null)) { view.Width = Dim.Fill (); } - if (!view.Height!.Has (out _) || (view.Height is null || view.Frame.Height == 0)) + if (!view.Height!.Has (out _) || (view.Height is null)) { view.Height = Dim.Fill (); }