Fixed PosDim bug

This commit is contained in:
Tig
2024-10-27 14:06:56 -07:00
parent 74919832f7
commit a7040b8d6d
4 changed files with 19 additions and 13 deletions

View File

@@ -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
/// <remarks>
/// Override to perform tasks when the layout is changing.
/// </remarks>
protected virtual void OnSubviewLayout (LayoutEventArgs args) { }
protected virtual void OnSubviewLayout (LayoutEventArgs args) { }
/// <summary>Raised by <see cref="LayoutSubviews"/> before any subviews
/// have been laid out.</summary>
@@ -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;

View File

@@ -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
/// <inheritdoc />
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]);

View File

@@ -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);

View File

@@ -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);