fix(ui): complete retail inventory scroll polish
Preserve pixel scroll offsets across inventory rebuilds, crop partially visible rows with nested geometry/UV clips, and replace the obsolete 560px resize ceiling with available screen height. Keep retail's row-sized wheel step while allowing continuous scrollbar thumb positions. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
ea72c395c9
commit
15aa3b9aff
15 changed files with 379 additions and 34 deletions
36
tests/AcDream.App.Tests/UI/UiClipRectTests.cs
Normal file
36
tests/AcDream.App.Tests/UI/UiClipRectTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using AcDream.App.UI;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
public sealed class UiClipRectTests
|
||||
{
|
||||
[Fact]
|
||||
public void TryClipSprite_cropsGeometryAndMatchingUvs()
|
||||
{
|
||||
var clip = new UiClipRect(0f, 0f, 100f, 100f);
|
||||
float x = -8f, y = 88f, w = 32f, h = 32f;
|
||||
float u0 = 0f, v0 = 0f, u1 = 1f, v1 = 1f;
|
||||
|
||||
bool visible = UiClipRect.TryClipSprite(
|
||||
clip, ref x, ref y, ref w, ref h, ref u0, ref v0, ref u1, ref v1);
|
||||
|
||||
Assert.True(visible);
|
||||
Assert.Equal((0f, 88f, 24f, 12f), (x, y, w, h));
|
||||
Assert.Equal((0.25f, 0f, 1f, 0.375f), (u0, v0, u1, v1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Intersection_andFullyOutsideSprite_areEmpty()
|
||||
{
|
||||
UiClipRect intersection = UiClipRect.Intersect(
|
||||
new UiClipRect(0f, 0f, 20f, 20f),
|
||||
new UiClipRect(30f, 30f, 40f, 40f));
|
||||
float x = 0f, y = 0f, w = 10f, h = 10f;
|
||||
float u0 = 0f, v0 = 0f, u1 = 1f, v1 = 1f;
|
||||
|
||||
Assert.True(intersection.IsEmpty);
|
||||
Assert.False(UiClipRect.TryClipSprite(
|
||||
intersection, ref x, ref y, ref w, ref h, ref u0, ref v0, ref u1, ref v1));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue