diff --git a/Terminal.Gui/View/View.Layout.cs b/Terminal.Gui/View/View.Layout.cs index b70420941..da65c51c4 100644 --- a/Terminal.Gui/View/View.Layout.cs +++ b/Terminal.Gui/View/View.Layout.cs @@ -165,8 +165,12 @@ public partial class View // Layout APIs { // Implicit layout is ok here because all Pos/Dim are Absolute values. Layout (); - // Ensure the next Application iteration tries to layout again - SetNeedsLayout (); + + if (SuperView is { } || this is Adornment { Parent: null }) + { + // Ensure the next Application iteration tries to layout again + SetNeedsLayout (); + } } } @@ -550,7 +554,7 @@ public partial class View // Layout APIs Size contentSize = GetContentSize (); OnSubviewLayout (new (contentSize)); - SubviewLayout?.Invoke(this, new (contentSize)); + SubviewLayout?.Invoke (this, new (contentSize)); // The Adornments already have their Frame's set by SetRelativeLayout so we call LayoutSubViews vs. Layout here. if (Margin is { Subviews.Count: > 0 }) @@ -619,7 +623,7 @@ public partial class View // Layout APIs /// /// Override to perform tasks when the layout is changing. /// - protected virtual void OnSubviewLayout (LayoutEventArgs args) { } + protected virtual void OnSubviewLayout (LayoutEventArgs args) { } /// Raised by before any subviews /// have been laid out. @@ -1036,7 +1040,7 @@ public partial class View // Layout APIs } ny = Math.Max (targetY, maxDimension); - + if (viewToMove?.SuperView is null || viewToMove == Application.Top || viewToMove?.SuperView == Application.Top) { maxDimension = statusVisible ? Application.Screen.Height - 1 : Application.Screen.Height; diff --git a/Terminal.Gui/Views/SpinnerView/SpinnerView.cs b/Terminal.Gui/Views/SpinnerView/SpinnerView.cs index e6bc981cc..9c9e28fae 100644 --- a/Terminal.Gui/Views/SpinnerView/SpinnerView.cs +++ b/Terminal.Gui/Views/SpinnerView/SpinnerView.cs @@ -171,8 +171,6 @@ public class SpinnerView : View, IDesignable _currentIdx = Sequence.Length - 1; } } - - // Text = "" + Sequence [_currentIdx]; //.EnumerateRunes; } _lastRender = DateTime.Now; @@ -190,7 +188,7 @@ public class SpinnerView : View, IDesignable /// protected override bool OnDrawingText (Rectangle viewport) { - if (Sequence is { Length: > 0 } && _currentIdx < Sequence.Length - 1) + if (Sequence is { Length: > 0 } && _currentIdx < Sequence.Length) { Move (Viewport.X, Viewport.Y); View.Driver?.AddStr (Sequence [_currentIdx]); diff --git a/UnitTests/Drawing/RulerTests.cs b/UnitTests/Drawing/RulerTests.cs index c7e6af008..be9dd9859 100644 --- a/UnitTests/Drawing/RulerTests.cs +++ b/UnitTests/Drawing/RulerTests.cs @@ -143,7 +143,8 @@ public class RulerTests _output ); - Application.Refresh (true); + f.SetNeedsDisplay(); + Application.Refresh (); r.Length = len; r.Draw (new (1, 0), 1); @@ -205,6 +206,7 @@ public class RulerTests ); // Postive offset + f.SetNeedsDisplay (); Application.Refresh (true); r.Draw (new (1, 1)); @@ -234,7 +236,8 @@ public class RulerTests ); // Negative offset - Application.Refresh (true); + f.SetNeedsDisplay (); + Application.Refresh (); r.Draw (new (1, -1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -263,7 +266,9 @@ public class RulerTests ); // Clip - Application.Refresh (true); + f.SetNeedsDisplay (); + + Application.Refresh (); r.Draw (new (1, 10)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -337,7 +342,7 @@ public class RulerTests └───┘", _output ); - + f.SetNeedsDisplay (); Application.Refresh (true); r.Length = len; r.Draw (new (0, 1), 1); diff --git a/UnitTests/View/Draw/NeedsDisplayTests.cs b/UnitTests/View/Draw/NeedsDisplayTests.cs index 77887219c..51574d338 100644 --- a/UnitTests/View/Draw/NeedsDisplayTests.cs +++ b/UnitTests/View/Draw/NeedsDisplayTests.cs @@ -118,7 +118,6 @@ public class NeedsDisplayTests () { var view = new View { Width = 2, Height = 2 }; Assert.True (view.NeedsDisplay); - Assert.False (view.NeedsLayout); view.Draw (); Assert.False (view.NeedsDisplay);