Gate-3 screenshot review (user): 'the chat tab looks like it is missing per window config' — Chat Window 1's header rendered over a void at the DEFAULT scroll offset because its 260px self-sized filter block straddled the viewport's bottom edge and UiScrollablePanel hid straddling rows WHOLE (AP-201's predicted symptom, now user-observed at scroll position zero, upgrading it from polish to blocking). By fix time the UI renderer HAD everything needed: UiRenderContext's clip stack (PushClip/PopClip with rect intersection + per-draw quad clipping) and UiElement's ClipsChildren hook, already honored by both the generic draw walk and hit-testing. The fix is therefore exactly the shape the filing asked for, in the panel itself: - ClipsChildren => true: children draw and hit-test clipped to the viewport rect. - The layout cull keeps any INTERSECTING row Visible (was: fully-inside only), with a half-pixel margin excluding zero-overlap edge rows; fully-outside rows stay hidden as the cheap skip. AP-201 retired in this commit (AP actives 142 -> 141); #371 closed; the gate script's Chat-tab steps re-written to expect clean edge clipping and to treat any whole-block vanish as a regression. Pinned by StraddlingRow_StaysVisible_AndClipsInsteadOfVanishing (the exact gate-3 geometry: header + 260px straddler in a 430px viewport) and ViewportClipsChildDrawingAndHitTesting (the clipped slice is not clickable). Full Release suite: 13,089 passed / 4 skipped / 0 failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
90 lines
3.8 KiB
C#
90 lines
3.8 KiB
C#
using AcDream.App.UI;
|
|
|
|
namespace AcDream.App.Tests.UI;
|
|
|
|
public sealed class UiScrollablePanelTests
|
|
{
|
|
[Fact]
|
|
public void LayoutScrollableChildren_ClipsRowsOutsideViewport()
|
|
{
|
|
var panel = new UiScrollablePanel { Width = 100, Height = 40, LineHeight = 20 };
|
|
for (int i = 0; i < 4; i++)
|
|
panel.AddChild(new UiPanel { Top = i * 20, Width = 100, Height = 20 });
|
|
|
|
panel.LayoutScrollableChildren();
|
|
Assert.True(panel.Children[0].Visible);
|
|
Assert.True(panel.Children[1].Visible);
|
|
Assert.False(panel.Children[2].Visible);
|
|
|
|
panel.Scroll.SetScrollY(20);
|
|
panel.LayoutScrollableChildren();
|
|
Assert.False(panel.Children[0].Visible);
|
|
Assert.True(panel.Children[1].Visible);
|
|
Assert.True(panel.Children[2].Visible);
|
|
}
|
|
|
|
[Fact]
|
|
public void StraddlingRow_StaysVisible_AndClipsInsteadOfVanishing()
|
|
{
|
|
// #371 (Campaign OP gate 3, the Chat tab's "missing per-window
|
|
// config"): a tall self-sized block (AP-195's 260px filter blocks)
|
|
// straddling the viewport's bottom edge used to be hidden WHOLE,
|
|
// leaving a void under its section header at the default scroll
|
|
// offset. It must stay Visible (the draw/hit walk clips it via
|
|
// ClipsChildren) — only rows with zero overlap are hidden.
|
|
var panel = new UiScrollablePanel { Width = 300, Height = 430, LineHeight = 20 };
|
|
var header = new UiPanel { Top = 0, Width = 300, Height = 18 };
|
|
var mainBlock = new UiPanel { Top = 18, Width = 300, Height = 260 };
|
|
var header2 = new UiPanel { Top = 278, Width = 300, Height = 18 };
|
|
var straddler = new UiPanel { Top = 296, Width = 300, Height = 260 }; // 296..556 in a 430 viewport
|
|
var below = new UiPanel { Top = 556, Width = 300, Height = 260 }; // fully outside
|
|
foreach (var c in new[] { header, mainBlock, header2, straddler, below })
|
|
panel.AddChild(c);
|
|
|
|
panel.LayoutScrollableChildren();
|
|
|
|
Assert.True(header.Visible);
|
|
Assert.True(mainBlock.Visible);
|
|
Assert.True(header2.Visible);
|
|
Assert.True(straddler.Visible); // the pre-fix bug: this was false
|
|
Assert.False(below.Visible);
|
|
|
|
// Scrolling far enough hides the first block entirely and keeps the
|
|
// straddler fully in view — intersection semantics on both edges.
|
|
panel.Scroll.SetScrollY(296);
|
|
panel.LayoutScrollableChildren();
|
|
Assert.False(mainBlock.Visible); // now fully above the viewport
|
|
Assert.True(straddler.Visible);
|
|
}
|
|
|
|
[Fact]
|
|
public void ViewportClipsChildDrawingAndHitTesting()
|
|
{
|
|
// The clip half of #371: ClipsChildren must gate the panel's hit-test
|
|
// so a straddling row's off-viewport portion cannot be clicked.
|
|
var root = new UiRoot { Width = 800, Height = 600 };
|
|
var panel = new UiScrollablePanel { Left = 0, Top = 0, Width = 300, Height = 100, LineHeight = 20 };
|
|
var row = new UiPanel { Top = 60, Width = 300, Height = 120 }; // 60..180, viewport ends at 100
|
|
panel.AddChild(row);
|
|
root.AddChild(panel);
|
|
panel.LayoutScrollableChildren();
|
|
|
|
Assert.True(row.Visible);
|
|
Assert.Same(row, root.Pick(150, 80)); // visible slice: clickable
|
|
Assert.NotSame(row, root.Pick(150, 140) ?? panel); // clipped slice: not the row
|
|
}
|
|
|
|
[Fact]
|
|
public void ScrollEvent_MovesByLineHeight()
|
|
{
|
|
var panel = new UiScrollablePanel { Width = 100, Height = 40, LineHeight = 20 };
|
|
for (int i = 0; i < 4; i++)
|
|
panel.AddChild(new UiPanel { Top = i * 20, Width = 100, Height = 20 });
|
|
panel.LayoutScrollableChildren();
|
|
|
|
var e = new UiEvent(0u, panel, UiEventType.Scroll, Data0: -1);
|
|
Assert.True(panel.OnEvent(in e));
|
|
|
|
Assert.Equal(20, panel.Scroll.ScrollY);
|
|
}
|
|
}
|