From a6a3c997032943eb08e0dc824fcfdd64a1aeb00b Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 16 Jun 2020 15:06:53 +0100 Subject: [PATCH] Fixes #698 StatusBar position on resizing. (#699) * Fixes #698 StatusBar position on resizing. * Changed to LayoutComplete in StatusBar. --- Terminal.Gui/Core/Toplevel.cs | 46 ++++++++++++++++----------------- Terminal.Gui/Views/StatusBar.cs | 2 +- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs index 62354ef64..b9128854e 100644 --- a/Terminal.Gui/Core/Toplevel.cs +++ b/Terminal.Gui/Core/Toplevel.cs @@ -269,31 +269,28 @@ namespace Terminal.Gui { internal void PositionToplevels () { - if (this != Application.Top) { - EnsureVisibleBounds (this, Frame.X, Frame.Y, out int nx, out int ny); - if ((nx != Frame.X || ny != Frame.Y) && LayoutStyle != LayoutStyle.Computed) { - X = nx; - Y = ny; + foreach (var top in Subviews) { + if (top is Toplevel) { + PositionToplevel ((Toplevel)top); } - } else { - foreach (var top in Subviews) { - if (top is Toplevel) { - EnsureVisibleBounds ((Toplevel)top, top.Frame.X, top.Frame.Y, out int nx, out int ny); - if ((nx != top.Frame.X || ny != top.Frame.Y) && top.LayoutStyle != LayoutStyle.Computed) { - top.X = nx; - top.Y = ny; - } - if (StatusBar != null) { - if (ny + top.Frame.Height > Driver.Rows - 1) { - if (top.Height is Dim.DimFill) - top.Height = Dim.Fill () - 1; - } - if (StatusBar.Frame.Y != Driver.Rows - 1) { - StatusBar.Y = Driver.Rows - 1; - SetNeedsDisplay (); - } - } - } + } + } + + private void PositionToplevel (Toplevel top) + { + EnsureVisibleBounds (top, top.Frame.X, top.Frame.Y, out int nx, out int ny); + if ((nx != top.Frame.X || ny != top.Frame.Y) && top.LayoutStyle != LayoutStyle.Computed) { + top.X = nx; + top.Y = ny; + } + if (StatusBar != null) { + if (ny + top.Frame.Height > Driver.Rows - 1) { + if (top.Height is Dim.DimFill) + top.Height = Dim.Fill () - 1; + } + if (StatusBar.Frame.Y != Driver.Rows - 1) { + StatusBar.Y = Driver.Rows - 1; + SetNeedsDisplay (); } } } @@ -311,6 +308,7 @@ namespace Terminal.Gui { // (the bounds passed to us). Clear (bounds); Driver.SetAttribute (Colors.Base.Normal); + PositionToplevels (); } foreach (var view in Subviews) { if (view.Frame.IntersectsWith (bounds)) { diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 214e42ed2..d2def20fb 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -90,7 +90,7 @@ namespace Terminal.Gui { Width = Dim.Fill (); Height = 1; - Application.Resized += (e) => { + LayoutComplete += (e) => { X = 0; Height = 1; if (SuperView == null || SuperView == Application.Top) {